]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/emultempl/alphaelf.em
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / emultempl / alphaelf.em
CommitLineData
c279ca3e 1# This shell script emits a C file. -*- C -*-
250d07de 2# Copyright (C) 2003-2021 Free Software Foundation, Inc.
c279ca3e 3#
f96b4a7b 4# This file is part of the GNU Binutils.
c279ca3e
AM
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
f96b4a7b 8# the Free Software Foundation; either version 3 of the License, or
c279ca3e
AM
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
f96b4a7b
NC
18# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19# MA 02110-1301, USA.
c279ca3e
AM
20#
21
075a2b89 22# This file is sourced from elf.em, and defines extra alpha
c279ca3e
AM
23# specific routines.
24#
92b93329 25fragment <<EOF
c279ca3e
AM
26
27#include "elf/internal.h"
28#include "elf/alpha.h"
29#include "elf-bfd.h"
30
8d6d53d4 31static bfd_boolean limit_32bit;
8d6d53d4
RH
32
33extern bfd_boolean elf64_alpha_use_secureplt;
8d6d53d4 34
c279ca3e
AM
35
36/* Set the start address as in the Tru64 ld. */
37#define ALPHA_TEXT_START_32BIT 0x12000000
38
8d6d53d4
RH
39static void
40alpha_after_open (void)
41{
5503fea1 42 if (bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour
4dfe6ac6 43 && elf_object_id (link_info.output_bfd) == ALPHA_ELF_DATA)
8d6d53d4
RH
44 {
45 unsigned int num_plt;
46 lang_output_section_statement_type *os;
47 lang_output_section_statement_type *plt_os[2];
48
49 num_plt = 0;
8ce18f9c 50 for (os = (void *) lang_os_list.head;
8d6d53d4
RH
51 os != NULL;
52 os = os->next)
53 {
54 if (os->constraint == SPECIAL && strcmp (os->name, ".plt") == 0)
55 {
56 if (num_plt < 2)
57 plt_os[num_plt] = os;
58 ++num_plt;
59 }
60 }
61
62 if (num_plt == 2)
63 {
64 plt_os[0]->constraint = elf64_alpha_use_secureplt ? 0 : -1;
65 plt_os[1]->constraint = elf64_alpha_use_secureplt ? -1 : 0;
66 }
67 }
68
69 gld${EMULATION_NAME}_after_open ();
70}
71
c279ca3e 72static void
0c7a8e5a 73alpha_after_parse (void)
c279ca3e 74{
d1c109de 75 link_info.relax_pass = 2;
0e1862bb
L
76 if (limit_32bit
77 && !bfd_link_pic (&link_info)
78 && !bfd_link_relocatable (&link_info))
c279ca3e
AM
79 lang_section_start (".interp",
80 exp_binop ('+',
81 exp_intop (ALPHA_TEXT_START_32BIT),
7a5df8d0
NC
82 exp_nameop (SIZEOF_HEADERS, NULL)),
83 NULL);
97b11f40 84
d871d478 85 ldelf_after_parse ();
c279ca3e
AM
86}
87
8d6d53d4
RH
88static void
89alpha_before_allocation (void)
90{
91 /* Call main function; we're just extending it. */
92 gld${EMULATION_NAME}_before_allocation ();
93
94 /* Add -relax if -O, not -r, and not explicitly disabled. */
0e1862bb
L
95 if (link_info.optimize
96 && !bfd_link_relocatable (&link_info)
97 && ! RELAXATION_DISABLED_BY_USER)
28d5f677 98 ENABLE_RELAXATION;
8d6d53d4
RH
99}
100
c279ca3e 101static void
0c7a8e5a 102alpha_finish (void)
c279ca3e 103{
8d6d53d4 104 if (limit_32bit)
f13a99db 105 elf_elfheader (link_info.output_bfd)->e_flags |= EF_ALPHA_32BIT;
c279ca3e 106
eaeb0a9d 107 finish_default ();
c279ca3e
AM
108}
109EOF
110
111# Define some shell vars to insert bits of code into the standard elf
112# parse_args and list_options functions.
113#
114PARSE_AND_LIST_PROLOGUE='
8d6d53d4 115#define OPTION_TASO 300
28d5f677 116#define OPTION_SECUREPLT (OPTION_TASO + 1)
8d6d53d4 117#define OPTION_NO_SECUREPLT (OPTION_SECUREPLT + 1)
c279ca3e
AM
118'
119
120PARSE_AND_LIST_LONGOPTS='
8d6d53d4 121 { "taso", no_argument, NULL, OPTION_TASO },
8d6d53d4
RH
122 { "secureplt", no_argument, NULL, OPTION_SECUREPLT },
123 { "no-secureplt", no_argument, NULL, OPTION_NO_SECUREPLT },
c279ca3e
AM
124'
125
126PARSE_AND_LIST_OPTIONS='
8d6d53d4 127 fprintf (file, _("\
442996ee 128 --taso Load executable in the lower 31-bit addressable\n\
df5f2391
AM
129 virtual address range\n"));
130 fprintf (file, _("\
131 --secureplt Force PLT in text segment\n"));
132 fprintf (file, _("\
133 --no-secureplt Force PLT in data segment\n"));
c279ca3e
AM
134'
135
136PARSE_AND_LIST_ARGS_CASES='
137 case OPTION_TASO:
8d6d53d4
RH
138 limit_32bit = 1;
139 break;
8d6d53d4
RH
140 case OPTION_SECUREPLT:
141 elf64_alpha_use_secureplt = TRUE;
142 break;
143 case OPTION_NO_SECUREPLT:
144 elf64_alpha_use_secureplt = FALSE;
c279ca3e
AM
145 break;
146'
147
148# Put these extra alpha routines in ld_${EMULATION_NAME}_emulation
149#
8d6d53d4 150LDEMUL_AFTER_OPEN=alpha_after_open
c279ca3e 151LDEMUL_AFTER_PARSE=alpha_after_parse
8d6d53d4 152LDEMUL_BEFORE_ALLOCATION=alpha_before_allocation
c279ca3e 153LDEMUL_FINISH=alpha_finish