1# This shell script emits a C file. -*- C -*- 2# Copyright 2003, 2004, 2005 Free Software Foundation, Inc. 3# 4# This file is part of GLD, the Gnu Linker. 5# 6# This program is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 2 of the License, or 9# (at your option) any later version. 10# 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program; if not, write to the Free Software 18# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 19# 20 21# This file is sourced from elf32.em, and defines extra alpha 22# specific routines. 23# 24cat >>e${EMULATION_NAME}.c <<EOF 25 26#include "elf/internal.h" 27#include "elf/alpha.h" 28#include "elf-bfd.h" 29 30static bfd_boolean limit_32bit; 31static bfd_boolean disable_relaxation; 32 33extern bfd_boolean elf64_alpha_use_secureplt; 34extern const bfd_target bfd_elf64_alpha_vec; 35extern const bfd_target bfd_elf64_alpha_freebsd_vec; 36 37 38/* Set the start address as in the Tru64 ld. */ 39#define ALPHA_TEXT_START_32BIT 0x12000000 40 41static void 42alpha_after_open (void) 43{ 44 if (link_info.hash->creator == &bfd_elf64_alpha_vec 45 || link_info.hash->creator == &bfd_elf64_alpha_freebsd_vec) 46 { 47 unsigned int num_plt; 48 lang_output_section_statement_type *os; 49 lang_output_section_statement_type *plt_os[2]; 50 51 num_plt = 0; 52 for (os = &lang_output_section_statement.head->output_section_statement; 53 os != NULL; 54 os = os->next) 55 { 56 if (os->constraint == SPECIAL && strcmp (os->name, ".plt") == 0) 57 { 58 if (num_plt < 2) 59 plt_os[num_plt] = os; 60 ++num_plt; 61 } 62 } 63 64 if (num_plt == 2) 65 { 66 plt_os[0]->constraint = elf64_alpha_use_secureplt ? 0 : -1; 67 plt_os[1]->constraint = elf64_alpha_use_secureplt ? -1 : 0; 68 } 69 } 70 71 gld${EMULATION_NAME}_after_open (); 72} 73 74static void 75alpha_after_parse (void) 76{ 77 if (limit_32bit && !link_info.shared && !link_info.relocatable) 78 lang_section_start (".interp", 79 exp_binop ('+', 80 exp_intop (ALPHA_TEXT_START_32BIT), 81 exp_nameop (SIZEOF_HEADERS, NULL)), 82 NULL); 83} 84 85static void 86alpha_before_allocation (void) 87{ 88 /* Call main function; we're just extending it. */ 89 gld${EMULATION_NAME}_before_allocation (); 90 91 /* Add -relax if -O, not -r, and not explicitly disabled. */ 92 if (link_info.optimize && !link_info.relocatable && !disable_relaxation) 93 command_line.relax = TRUE; 94} 95 96static void 97alpha_finish (void) 98{ 99 if (limit_32bit) 100 elf_elfheader (output_bfd)->e_flags |= EF_ALPHA_32BIT; 101 102 gld${EMULATION_NAME}_finish (); 103} 104EOF 105 106# Define some shell vars to insert bits of code into the standard elf 107# parse_args and list_options functions. 108# 109PARSE_AND_LIST_PROLOGUE=' 110#define OPTION_TASO 300 111#define OPTION_NO_RELAX (OPTION_TASO + 1) 112#define OPTION_SECUREPLT (OPTION_NO_RELAX + 1) 113#define OPTION_NO_SECUREPLT (OPTION_SECUREPLT + 1) 114' 115 116PARSE_AND_LIST_LONGOPTS=' 117 { "taso", no_argument, NULL, OPTION_TASO }, 118 { "no-relax", no_argument, NULL, OPTION_NO_RELAX }, 119 { "secureplt", no_argument, NULL, OPTION_SECUREPLT }, 120 { "no-secureplt", no_argument, NULL, OPTION_NO_SECUREPLT }, 121' 122 123PARSE_AND_LIST_OPTIONS=' 124 fprintf (file, _("\ 125 --taso Load executable in the lower 31-bit addressable\n\ 126 virtual address range.\n\ 127 --no-relax Do not relax call and gp sequences.\n\ 128 --secureplt Force PLT in text segment.\n\ 129 --no-secureplt Force PLT in data segment.\n\ 130")); 131' 132 133PARSE_AND_LIST_ARGS_CASES=' 134 case OPTION_TASO: 135 limit_32bit = 1; 136 break; 137 case OPTION_NO_RELAX: 138 disable_relaxation = TRUE; 139 break; 140 case OPTION_SECUREPLT: 141 elf64_alpha_use_secureplt = TRUE; 142 break; 143 case OPTION_NO_SECUREPLT: 144 elf64_alpha_use_secureplt = FALSE; 145 break; 146' 147 148# Put these extra alpha routines in ld_${EMULATION_NAME}_emulation 149# 150LDEMUL_AFTER_OPEN=alpha_after_open 151LDEMUL_AFTER_PARSE=alpha_after_parse 152LDEMUL_BEFORE_ALLOCATION=alpha_before_allocation 153LDEMUL_FINISH=alpha_finish 154