1 # This shell script emits a C file. -*- C -*-
2 # Copyright (C) 2003-2024 Free Software Foundation, Inc.
4 # This file is part of the GNU Binutils.
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 3 of the License, or
9 # (at your option) any later version.
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.
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,
22 # This file is sourced from elf.em, and defines extra alpha
27 #include "elf/internal.h"
28 #include "elf/alpha.h"
31 static bool limit_32bit;
33 extern bool elf64_alpha_use_secureplt;
36 /* Set the start address as in the Tru64 ld. */
37 #define ALPHA_TEXT_START_32BIT 0x12000000
40 alpha_after_open (void)
42 if (bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour
43 && elf_object_id (link_info.output_bfd) == ALPHA_ELF_DATA)
46 lang_output_section_statement_type *os;
47 lang_output_section_statement_type *plt_os[2];
50 for (os = (void *) lang_os_list.head;
54 if (os->constraint == SPECIAL && strcmp (os->name, ".plt") == 0)
64 plt_os[0]->constraint = elf64_alpha_use_secureplt ? 0 : -1;
65 plt_os[1]->constraint = elf64_alpha_use_secureplt ? -1 : 0;
69 gld${EMULATION_NAME}_after_open ();
73 alpha_after_parse (void)
75 link_info.relax_pass = 2;
77 && !bfd_link_pic (&link_info)
78 && !bfd_link_relocatable (&link_info))
79 lang_section_start (".interp",
81 exp_intop (ALPHA_TEXT_START_32BIT),
82 exp_nameop (SIZEOF_HEADERS, NULL)),
89 alpha_before_allocation (void)
91 /* Call main function; we're just extending it. */
92 gld${EMULATION_NAME}_before_allocation ();
94 /* Add -relax if -O, not -r, and not explicitly disabled. */
95 if (link_info.optimize
96 && !bfd_link_relocatable (&link_info)
97 && ! RELAXATION_DISABLED_BY_USER)
105 elf_elfheader (link_info.output_bfd)->e_flags |= EF_ALPHA_32BIT;
111 # Define some shell vars to insert bits of code into the standard elf
112 # parse_args and list_options functions.
114 PARSE_AND_LIST_LONGOPTS='
115 { "taso", no_argument, NULL, OPTION_TASO },
116 { "secureplt", no_argument, NULL, OPTION_SECUREPLT },
117 { "no-secureplt", no_argument, NULL, OPTION_NO_SECUREPLT },
120 PARSE_AND_LIST_OPTIONS='
122 --taso Load executable in the lower 31-bit addressable\n\
123 virtual address range\n"));
125 --secureplt Force PLT in text segment\n"));
127 --no-secureplt Force PLT in data segment\n"));
130 PARSE_AND_LIST_ARGS_CASES='
134 case OPTION_SECUREPLT:
135 elf64_alpha_use_secureplt = true;
137 case OPTION_NO_SECUREPLT:
138 elf64_alpha_use_secureplt = false;
142 # Put these extra alpha routines in ld_${EMULATION_NAME}_emulation
144 LDEMUL_AFTER_OPEN=alpha_after_open
145 LDEMUL_AFTER_PARSE=alpha_after_parse
146 LDEMUL_BEFORE_ALLOCATION=alpha_before_allocation
147 LDEMUL_FINISH=alpha_finish