Commit | Line | Data |
---|---|---|
c279ca3e | 1 | # This shell script emits a C file. -*- C -*- |
aa820537 AM |
2 | # Copyright 2003, 2004, 2005, 2007, 2008, 2009 |
3 | # Free Software Foundation, Inc. | |
c279ca3e | 4 | # |
f96b4a7b | 5 | # This file is part of the GNU Binutils. |
c279ca3e AM |
6 | # |
7 | # This program is free software; you can redistribute it and/or modify | |
8 | # it under the terms of the GNU General Public License as published by | |
f96b4a7b | 9 | # the Free Software Foundation; either version 3 of the License, or |
c279ca3e AM |
10 | # (at your option) any later version. |
11 | # | |
12 | # This program is distributed in the hope that it will be useful, | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | # GNU General Public License for more details. | |
16 | # | |
17 | # You should have received a copy of the GNU General Public License | |
18 | # along with this program; if not, write to the Free Software | |
f96b4a7b NC |
19 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
20 | # MA 02110-1301, USA. | |
c279ca3e AM |
21 | # |
22 | ||
23 | # This file is sourced from elf32.em, and defines extra alpha | |
24 | # specific routines. | |
25 | # | |
92b93329 | 26 | fragment <<EOF |
c279ca3e AM |
27 | |
28 | #include "elf/internal.h" | |
29 | #include "elf/alpha.h" | |
30 | #include "elf-bfd.h" | |
31 | ||
8d6d53d4 RH |
32 | static bfd_boolean limit_32bit; |
33 | static bfd_boolean disable_relaxation; | |
34 | ||
35 | extern bfd_boolean elf64_alpha_use_secureplt; | |
8d6d53d4 | 36 | |
c279ca3e AM |
37 | |
38 | /* Set the start address as in the Tru64 ld. */ | |
39 | #define ALPHA_TEXT_START_32BIT 0x12000000 | |
40 | ||
8d6d53d4 RH |
41 | static void |
42 | alpha_after_open (void) | |
43 | { | |
5503fea1 AM |
44 | if (bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour |
45 | && elf_object_id (link_info.output_bfd) == ALPHA_ELF_TDATA) | |
8d6d53d4 RH |
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 | ||
c279ca3e | 74 | static void |
0c7a8e5a | 75 | alpha_after_parse (void) |
c279ca3e | 76 | { |
8d6d53d4 | 77 | if (limit_32bit && !link_info.shared && !link_info.relocatable) |
c279ca3e AM |
78 | lang_section_start (".interp", |
79 | exp_binop ('+', | |
80 | exp_intop (ALPHA_TEXT_START_32BIT), | |
7a5df8d0 NC |
81 | exp_nameop (SIZEOF_HEADERS, NULL)), |
82 | NULL); | |
97b11f40 AM |
83 | |
84 | after_parse_default (); | |
c279ca3e AM |
85 | } |
86 | ||
8d6d53d4 RH |
87 | static void |
88 | alpha_before_allocation (void) | |
89 | { | |
90 | /* Call main function; we're just extending it. */ | |
91 | gld${EMULATION_NAME}_before_allocation (); | |
92 | ||
93 | /* Add -relax if -O, not -r, and not explicitly disabled. */ | |
94 | if (link_info.optimize && !link_info.relocatable && !disable_relaxation) | |
95 | command_line.relax = TRUE; | |
96 | } | |
97 | ||
c279ca3e | 98 | static void |
0c7a8e5a | 99 | alpha_finish (void) |
c279ca3e | 100 | { |
8d6d53d4 | 101 | if (limit_32bit) |
f13a99db | 102 | elf_elfheader (link_info.output_bfd)->e_flags |= EF_ALPHA_32BIT; |
c279ca3e | 103 | |
eaeb0a9d | 104 | finish_default (); |
c279ca3e AM |
105 | } |
106 | EOF | |
107 | ||
108 | # Define some shell vars to insert bits of code into the standard elf | |
109 | # parse_args and list_options functions. | |
110 | # | |
111 | PARSE_AND_LIST_PROLOGUE=' | |
8d6d53d4 RH |
112 | #define OPTION_TASO 300 |
113 | #define OPTION_NO_RELAX (OPTION_TASO + 1) | |
114 | #define OPTION_SECUREPLT (OPTION_NO_RELAX + 1) | |
115 | #define OPTION_NO_SECUREPLT (OPTION_SECUREPLT + 1) | |
c279ca3e AM |
116 | ' |
117 | ||
118 | PARSE_AND_LIST_LONGOPTS=' | |
8d6d53d4 RH |
119 | { "taso", no_argument, NULL, OPTION_TASO }, |
120 | { "no-relax", no_argument, NULL, OPTION_NO_RELAX }, | |
121 | { "secureplt", no_argument, NULL, OPTION_SECUREPLT }, | |
122 | { "no-secureplt", no_argument, NULL, OPTION_NO_SECUREPLT }, | |
c279ca3e AM |
123 | ' |
124 | ||
125 | PARSE_AND_LIST_OPTIONS=' | |
8d6d53d4 | 126 | fprintf (file, _("\ |
442996ee AM |
127 | --taso Load executable in the lower 31-bit addressable\n\ |
128 | virtual address range.\n\ | |
129 | --no-relax Do not relax call and gp sequences.\n\ | |
130 | --secureplt Force PLT in text segment.\n\ | |
131 | --no-secureplt Force PLT in data segment.\n\ | |
8d6d53d4 | 132 | ")); |
c279ca3e AM |
133 | ' |
134 | ||
135 | PARSE_AND_LIST_ARGS_CASES=' | |
136 | case OPTION_TASO: | |
8d6d53d4 RH |
137 | limit_32bit = 1; |
138 | break; | |
139 | case OPTION_NO_RELAX: | |
140 | disable_relaxation = TRUE; | |
141 | break; | |
142 | case OPTION_SECUREPLT: | |
143 | elf64_alpha_use_secureplt = TRUE; | |
144 | break; | |
145 | case OPTION_NO_SECUREPLT: | |
146 | elf64_alpha_use_secureplt = FALSE; | |
c279ca3e AM |
147 | break; |
148 | ' | |
149 | ||
150 | # Put these extra alpha routines in ld_${EMULATION_NAME}_emulation | |
151 | # | |
8d6d53d4 | 152 | LDEMUL_AFTER_OPEN=alpha_after_open |
c279ca3e | 153 | LDEMUL_AFTER_PARSE=alpha_after_parse |
8d6d53d4 | 154 | LDEMUL_BEFORE_ALLOCATION=alpha_before_allocation |
c279ca3e | 155 | LDEMUL_FINISH=alpha_finish |