]>
Commit | Line | Data |
---|---|---|
252b5132 RH |
1 | # This shell script emits a C file. -*- C -*- |
2 | # It does some substitutions. | |
252b5132 | 3 | test -z "${ELFSIZE}" && ELFSIZE=32 |
86af25fe L |
4 | if [ -z "$MACHINE" ]; then |
5 | OUTPUT_ARCH=${ARCH} | |
6 | else | |
7 | OUTPUT_ARCH=${ARCH}:${MACHINE} | |
8 | fi | |
92b93329 | 9 | fragment <<EOF |
252b5132 RH |
10 | /* This file is is generated by a shell script. DO NOT EDIT! */ |
11 | ||
12 | /* ${ELFSIZE} bit ELF emulation code for ${EMULATION_NAME} | |
a2c58332 | 13 | Copyright (C) 1991-2022 Free Software Foundation, Inc. |
252b5132 RH |
14 | Written by Steve Chamberlain <sac@cygnus.com> |
15 | ELF support by Ian Lance Taylor <ian@cygnus.com> | |
16 | ||
f96b4a7b NC |
17 | This file is part of the GNU Binutils. |
18 | ||
19 | This program is free software; you can redistribute it and/or modify | |
20 | it under the terms of the GNU General Public License as published by | |
21 | the Free Software Foundation; either version 3 of the License, or | |
22 | (at your option) any later version. | |
23 | ||
24 | This program is distributed in the hope that it will be useful, | |
25 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
27 | GNU General Public License for more details. | |
28 | ||
29 | You should have received a copy of the GNU General Public License | |
30 | along with this program; if not, write to the Free Software | |
31 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, | |
32 | MA 02110-1301, USA. */ | |
252b5132 RH |
33 | |
34 | #define TARGET_IS_${EMULATION_NAME} | |
35 | ||
252b5132 | 36 | #include "sysdep.h" |
3db64b00 | 37 | #include "bfd.h" |
1c9acd94 | 38 | #include "libiberty.h" |
fcf65871 | 39 | #include "getopt.h" |
252b5132 | 40 | #include "bfdlink.h" |
1ff6de03 | 41 | #include "ctf-api.h" |
252b5132 RH |
42 | #include "ld.h" |
43 | #include "ldmain.h" | |
252b5132 RH |
44 | #include "ldmisc.h" |
45 | #include "ldexp.h" | |
46 | #include "ldlang.h" | |
b71e2778 AM |
47 | #include "ldfile.h" |
48 | #include "ldemul.h" | |
df2a7313 | 49 | #include <ldgram.h> |
ecca9871 | 50 | #include "elf-bfd.h" |
d871d478 AM |
51 | #include "ldelf.h" |
52 | #include "ldelfgen.h" | |
252b5132 | 53 | |
0c7a8e5a AM |
54 | /* Declare functions used by various EXTRA_EM_FILEs. */ |
55 | static void gld${EMULATION_NAME}_before_parse (void); | |
320fdefe L |
56 | static void gld${EMULATION_NAME}_before_plugin_all_symbols_read |
57 | (void); | |
0c7a8e5a AM |
58 | static void gld${EMULATION_NAME}_after_open (void); |
59 | static void gld${EMULATION_NAME}_before_allocation (void); | |
eaeb0a9d | 60 | static void gld${EMULATION_NAME}_after_allocation (void); |
d3989512 | 61 | EOF |
d3989512 | 62 | |
41392f03 AM |
63 | # Import any needed special functions and/or overrides. |
64 | # | |
92b93329 | 65 | source_em ${srcdir}/emultempl/elf-generic.em |
41392f03 | 66 | if test -n "$EXTRA_EM_FILE" ; then |
92b93329 | 67 | source_em ${srcdir}/emultempl/${EXTRA_EM_FILE}.em |
41392f03 AM |
68 | fi |
69 | ||
f813923c | 70 | # Functions in this file can be overridden by setting the LDEMUL_* shell |
41392f03 AM |
71 | # variables. If the name of the overriding function is the same as is |
72 | # defined in this file, then don't output this file's version. | |
73 | # If a different overriding name is given then output the standard function | |
74 | # as presumably it is called from the overriding function. | |
75 | # | |
76 | if test x"$LDEMUL_BEFORE_PARSE" != xgld"$EMULATION_NAME"_before_parse; then | |
92b93329 | 77 | fragment <<EOF |
41392f03 | 78 | |
252b5132 | 79 | static void |
0c7a8e5a | 80 | gld${EMULATION_NAME}_before_parse (void) |
252b5132 | 81 | { |
5e2f1575 | 82 | ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`); |
f38a2680 AM |
83 | input_flags.dynamic = ${DYNAMIC_LINK-true}; |
84 | config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo true ; else echo false ; fi`; | |
85 | config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo true ; else echo false ; fi`; | |
86 | link_info.check_relocs_after_open_input = true; | |
5fd104ad AM |
87 | EOF |
88 | if test -n "$COMMONPAGESIZE"; then | |
89 | fragment <<EOF | |
647e4d46 | 90 | link_info.relro = DEFAULT_LD_Z_RELRO; |
5fd104ad AM |
91 | EOF |
92 | fi | |
93 | fragment <<EOF | |
f6aec96d | 94 | link_info.separate_code = DEFAULT_LD_Z_SEPARATE_CODE; |
ba951afb NC |
95 | link_info.warn_execstack = DEFAULT_LD_WARN_EXECSTACK; |
96 | link_info.no_warn_rwx_segments = ! DEFAULT_LD_WARN_RWX_SEGMENTS; | |
97 | link_info.default_execstack = DEFAULT_LD_EXECSTACK; | |
663fa543 L |
98 | } |
99 | ||
822b8bf4 | 100 | EOF |
663fa543 | 101 | fi |
822b8bf4 | 102 | |
92b93329 | 103 | fragment <<EOF |
252b5132 | 104 | |
7ee314fa AM |
105 | /* These variables are used to implement target options */ |
106 | ||
107 | static char *audit; /* colon (typically) separated list of libs */ | |
108 | static char *depaudit; /* colon (typically) separated list of libs */ | |
252b5132 | 109 | |
04925e1e | 110 | EOF |
316a1245 | 111 | |
d871d478 | 112 | if test x"$LDEMUL_AFTER_OPEN" != xgld"$EMULATION_NAME"_after_open; then |
04925e1e | 113 | |
f38a2680 AM |
114 | IS_LINUX_TARGET=false |
115 | IS_FREEBSD_TARGET=false | |
3dc16cab | 116 | case ${target} in |
a5244b7e | 117 | *-*-linux-* | *-*-k*bsd*-* | *-*-gnu*) |
f38a2680 | 118 | IS_LINUX_TARGET=true ;; |
d871d478 | 119 | *-*-freebsd* | *-*-dragonfly*) |
f38a2680 | 120 | IS_FREEBSD_TARGET=true ;; |
d871d478 | 121 | esac |
f38a2680 | 122 | IS_LIBPATH=false |
d871d478 | 123 | if test "x${USE_LIBPATH}" = xyes; then |
f38a2680 | 124 | IS_LIBPATH=true |
d871d478 | 125 | fi |
f38a2680 | 126 | IS_NATIVE=false |
d871d478 | 127 | if test "x${NATIVE}" = xyes; then |
f38a2680 | 128 | IS_NATIVE=true |
d871d478 | 129 | fi |
04925e1e | 130 | |
d871d478 | 131 | fragment <<EOF |
04925e1e | 132 | |
320fdefe L |
133 | /* This is called before calling plugin 'all symbols read' hook. */ |
134 | ||
135 | static void | |
136 | gld${EMULATION_NAME}_before_plugin_all_symbols_read (void) | |
137 | { | |
138 | ldelf_before_plugin_all_symbols_read ($IS_LIBPATH, $IS_NATIVE, | |
139 | $IS_LINUX_TARGET, | |
140 | $IS_FREEBSD_TARGET, | |
141 | $ELFSIZE, "$prefix"); | |
142 | } | |
143 | ||
d871d478 | 144 | /* This is called after all the input files have been opened. */ |
d3989512 JJ |
145 | |
146 | static void | |
d871d478 | 147 | gld${EMULATION_NAME}_after_open (void) |
d3989512 | 148 | { |
d871d478 | 149 | ldelf_after_open ($IS_LIBPATH, $IS_NATIVE, |
ef8f08ca | 150 | $IS_LINUX_TARGET, $IS_FREEBSD_TARGET, $ELFSIZE, "$prefix"); |
252b5132 RH |
151 | } |
152 | ||
04925e1e | 153 | EOF |
04925e1e | 154 | fi |
d871d478 AM |
155 | |
156 | if test x"$LDEMUL_BEFORE_ALLOCATION" != xgld"$EMULATION_NAME"_before_allocation; then | |
157 | if test x"${ELF_INTERPRETER_NAME}" = x; then | |
158 | ELF_INTERPRETER_NAME=NULL | |
159 | fi | |
92b93329 | 160 | fragment <<EOF |
04925e1e | 161 | |
d871d478 AM |
162 | /* This is called after the sections have been attached to output |
163 | sections, but before any sizes or addresses have been set. */ | |
252b5132 RH |
164 | |
165 | static void | |
d871d478 | 166 | gld${EMULATION_NAME}_before_allocation (void) |
252b5132 | 167 | { |
d871d478 AM |
168 | ldelf_before_allocation (audit, depaudit, ${ELF_INTERPRETER_NAME}); |
169 | } | |
7cedef86 | 170 | |
c56feb2b AM |
171 | EOF |
172 | fi | |
173 | ||
eaeb0a9d | 174 | if test x"$LDEMUL_AFTER_ALLOCATION" != xgld"$EMULATION_NAME"_after_allocation; then |
92b93329 | 175 | fragment <<EOF |
252b5132 | 176 | |
deb04cdb | 177 | static void |
eaeb0a9d | 178 | gld${EMULATION_NAME}_after_allocation (void) |
deb04cdb | 179 | { |
75938853 AM |
180 | int need_layout = bfd_elf_discard_info (link_info.output_bfd, &link_info); |
181 | ||
182 | if (need_layout < 0) | |
d003af55 | 183 | einfo (_("%X%P: .eh_frame/.stab edit: %E\n")); |
75938853 | 184 | else |
d871d478 | 185 | ldelf_map_segments (need_layout); |
73d074b4 | 186 | } |
41392f03 AM |
187 | EOF |
188 | fi | |
189 | ||
190 | if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then | |
92b93329 | 191 | fragment <<EOF |
252b5132 RH |
192 | |
193 | static char * | |
0c7a8e5a | 194 | gld${EMULATION_NAME}_get_script (int *isfile) |
252b5132 RH |
195 | EOF |
196 | ||
7225345d | 197 | if test x"$COMPILE_IN" = xyes |
252b5132 RH |
198 | then |
199 | # Scripts compiled in. | |
200 | ||
201 | # sed commands to quote an ld script as a C string. | |
597e2591 | 202 | sc="-f stringify.sed" |
252b5132 | 203 | |
92b93329 | 204 | fragment <<EOF |
60bcf0fa | 205 | { |
252b5132 RH |
206 | *isfile = 0; |
207 | ||
0e1862bb | 208 | if (bfd_link_relocatable (&link_info) && config.build_constructors) |
597e2591 | 209 | return |
252b5132 | 210 | EOF |
afd7a018 | 211 | sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c |
0e1862bb | 212 | echo ' ; else if (bfd_link_relocatable (&link_info)) return' >> e${EMULATION_NAME}.c |
afd7a018 AM |
213 | sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c |
214 | echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c | |
215 | sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c | |
61585df2 | 216 | if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then : ; else |
afd7a018 AM |
217 | echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c |
218 | sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c | |
db6751f2 | 219 | fi |
36af4a4e JJ |
220 | if test -n "$GENERATE_PIE_SCRIPT" ; then |
221 | if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then | |
0e1862bb L |
222 | echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c |
223 | echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c | |
47acac12 L |
224 | echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c |
225 | echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c | |
226 | sed $sc ldscripts/${EMULATION_NAME}.xdwe >> e${EMULATION_NAME}.c | |
227 | echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c | |
228 | echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c | |
0e1862bb | 229 | echo ' && link_info.relro' >> e${EMULATION_NAME}.c |
fbfca19e | 230 | echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c |
afd7a018 | 231 | sed $sc ldscripts/${EMULATION_NAME}.xdw >> e${EMULATION_NAME}.c |
a3813728 AK |
232 | if test -n "$GENERATE_RELRO_SCRIPT" ; then |
233 | echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c | |
234 | echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c | |
235 | echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c | |
236 | echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c | |
237 | sed $sc ldscripts/${EMULATION_NAME}.xdceo >> e${EMULATION_NAME}.c | |
238 | fi | |
0e1862bb | 239 | echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c |
47acac12 L |
240 | echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c |
241 | echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c | |
242 | sed $sc ldscripts/${EMULATION_NAME}.xdce >> e${EMULATION_NAME}.c | |
a3813728 AK |
243 | if test -n "$GENERATE_RELRO_SCRIPT" ; then |
244 | echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c | |
245 | echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c | |
246 | echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c | |
247 | sed $sc ldscripts/${EMULATION_NAME}.xdco >> e${EMULATION_NAME}.c | |
248 | fi | |
47acac12 | 249 | echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c |
0e1862bb | 250 | echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c |
afd7a018 | 251 | sed $sc ldscripts/${EMULATION_NAME}.xdc >> e${EMULATION_NAME}.c |
a3813728 AK |
252 | if test -n "$GENERATE_RELRO_SCRIPT" ; then |
253 | echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c | |
254 | echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c | |
255 | echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c | |
256 | sed $sc ldscripts/${EMULATION_NAME}.xdeo >> e${EMULATION_NAME}.c | |
257 | fi | |
36af4a4e | 258 | fi |
47acac12 L |
259 | echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c |
260 | echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c | |
261 | sed $sc ldscripts/${EMULATION_NAME}.xde >> e${EMULATION_NAME}.c | |
a3813728 AK |
262 | if test -n "$GENERATE_RELRO_SCRIPT" ; then |
263 | echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c | |
264 | echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c | |
265 | sed $sc ldscripts/${EMULATION_NAME}.xdo >> e${EMULATION_NAME}.c | |
266 | fi | |
0e1862bb | 267 | echo ' ; else if (bfd_link_pie (&link_info)) return' >> e${EMULATION_NAME}.c |
afd7a018 | 268 | sed $sc ldscripts/${EMULATION_NAME}.xd >> e${EMULATION_NAME}.c |
36af4a4e | 269 | fi |
252b5132 | 270 | if test -n "$GENERATE_SHLIB_SCRIPT" ; then |
82434356 | 271 | if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then |
fb24d531 L |
272 | echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c |
273 | echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c | |
47acac12 L |
274 | echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c |
275 | echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c | |
276 | sed $sc ldscripts/${EMULATION_NAME}.xswe >> e${EMULATION_NAME}.c | |
277 | echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c | |
278 | echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c | |
fb24d531 | 279 | echo ' && link_info.relro' >> e${EMULATION_NAME}.c |
fbfca19e | 280 | echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c |
afd7a018 | 281 | sed $sc ldscripts/${EMULATION_NAME}.xsw >> e${EMULATION_NAME}.c |
a3813728 AK |
282 | if test -n "$GENERATE_RELRO_SCRIPT" ; then |
283 | echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c | |
284 | echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c | |
285 | echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c | |
286 | echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c | |
287 | sed $sc ldscripts/${EMULATION_NAME}.xsceo >> e${EMULATION_NAME}.c | |
288 | fi | |
fb24d531 | 289 | echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c |
47acac12 L |
290 | echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c |
291 | echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c | |
292 | sed $sc ldscripts/${EMULATION_NAME}.xsce >> e${EMULATION_NAME}.c | |
a3813728 AK |
293 | if test -n "$GENERATE_RELRO_SCRIPT" ; then |
294 | echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c | |
295 | echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c | |
296 | echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c | |
297 | sed $sc ldscripts/${EMULATION_NAME}.xsco >> e${EMULATION_NAME}.c | |
298 | fi | |
47acac12 | 299 | echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c |
fb24d531 | 300 | echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c |
afd7a018 | 301 | sed $sc ldscripts/${EMULATION_NAME}.xsc >> e${EMULATION_NAME}.c |
a3813728 AK |
302 | if test -n "$GENERATE_RELRO_SCRIPT" ; then |
303 | echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c | |
304 | echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c | |
305 | echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c | |
306 | sed $sc ldscripts/${EMULATION_NAME}.xseo >> e${EMULATION_NAME}.c | |
307 | fi | |
82434356 | 308 | fi |
47acac12 L |
309 | echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c |
310 | echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c | |
311 | sed $sc ldscripts/${EMULATION_NAME}.xse >> e${EMULATION_NAME}.c | |
a3813728 AK |
312 | if test -n "$GENERATE_RELRO_SCRIPT" ; then |
313 | echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c | |
314 | echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c | |
315 | sed $sc ldscripts/${EMULATION_NAME}.xso >> e${EMULATION_NAME}.c | |
316 | fi | |
0e1862bb | 317 | echo ' ; else if (bfd_link_dll (&link_info)) return' >> e${EMULATION_NAME}.c |
afd7a018 | 318 | sed $sc ldscripts/${EMULATION_NAME}.xs >> e${EMULATION_NAME}.c |
252b5132 | 319 | fi |
82434356 | 320 | if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then |
fb24d531 | 321 | echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c |
47acac12 L |
322 | echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c |
323 | echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c | |
324 | sed $sc ldscripts/${EMULATION_NAME}.xwe >> e${EMULATION_NAME}.c | |
325 | echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c | |
fb24d531 | 326 | echo ' && link_info.relro' >> e${EMULATION_NAME}.c |
fbfca19e | 327 | echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c |
afd7a018 | 328 | sed $sc ldscripts/${EMULATION_NAME}.xw >> e${EMULATION_NAME}.c |
a3813728 AK |
329 | if test -n "$GENERATE_RELRO_SCRIPT" ; then |
330 | echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c | |
331 | echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c | |
332 | echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c | |
333 | sed $sc ldscripts/${EMULATION_NAME}.xceo >> e${EMULATION_NAME}.c | |
334 | fi | |
47acac12 L |
335 | echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c |
336 | echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c | |
337 | sed $sc ldscripts/${EMULATION_NAME}.xce >> e${EMULATION_NAME}.c | |
a3813728 AK |
338 | if test -n "$GENERATE_RELRO_SCRIPT" ; then |
339 | echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c | |
340 | echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c | |
341 | sed $sc ldscripts/${EMULATION_NAME}.xco >> e${EMULATION_NAME}.c | |
342 | fi | |
afd7a018 AM |
343 | echo ' ; else if (link_info.combreloc) return' >> e${EMULATION_NAME}.c |
344 | sed $sc ldscripts/${EMULATION_NAME}.xc >> e${EMULATION_NAME}.c | |
82434356 | 345 | fi |
a3813728 AK |
346 | if test -n "$GENERATE_RELRO_SCRIPT" ; then |
347 | echo ' ; else if (link_info.separate_code' >> e${EMULATION_NAME}.c | |
348 | echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c | |
349 | sed $sc ldscripts/${EMULATION_NAME}.xeo >> e${EMULATION_NAME}.c | |
350 | fi | |
351 | echo ' ; else if (link_info.separate_code) return' >> e${EMULATION_NAME}.c | |
47acac12 | 352 | sed $sc ldscripts/${EMULATION_NAME}.xe >> e${EMULATION_NAME}.c |
a3813728 AK |
353 | if test -n "$GENERATE_RELRO_SCRIPT" ; then |
354 | echo ' ; else if (link_info.relro) return' >> e${EMULATION_NAME}.c | |
355 | sed $sc ldscripts/${EMULATION_NAME}.xo >> e${EMULATION_NAME}.c | |
356 | fi | |
afd7a018 AM |
357 | echo ' ; else return' >> e${EMULATION_NAME}.c |
358 | sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c | |
359 | echo '; }' >> e${EMULATION_NAME}.c | |
252b5132 RH |
360 | |
361 | else | |
362 | # Scripts read from the filesystem. | |
363 | ||
92b93329 | 364 | fragment <<EOF |
60bcf0fa | 365 | { |
252b5132 RH |
366 | *isfile = 1; |
367 | ||
0e1862bb | 368 | if (bfd_link_relocatable (&link_info) && config.build_constructors) |
252b5132 | 369 | return "ldscripts/${EMULATION_NAME}.xu"; |
0e1862bb | 370 | else if (bfd_link_relocatable (&link_info)) |
252b5132 RH |
371 | return "ldscripts/${EMULATION_NAME}.xr"; |
372 | else if (!config.text_read_only) | |
373 | return "ldscripts/${EMULATION_NAME}.xbn"; | |
a060b769 AM |
374 | EOF |
375 | if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then : | |
376 | else | |
92b93329 | 377 | fragment <<EOF |
252b5132 RH |
378 | else if (!config.magic_demand_paged) |
379 | return "ldscripts/${EMULATION_NAME}.xn"; | |
a060b769 AM |
380 | EOF |
381 | fi | |
36af4a4e JJ |
382 | if test -n "$GENERATE_PIE_SCRIPT" ; then |
383 | if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then | |
92b93329 | 384 | fragment <<EOF |
0e1862bb L |
385 | else if (bfd_link_pie (&link_info) |
386 | && link_info.combreloc | |
387 | && link_info.relro | |
388 | && (link_info.flags & DF_BIND_NOW)) | |
47acac12 L |
389 | { |
390 | if (link_info.separate_code) | |
391 | return "ldscripts/${EMULATION_NAME}.xdwe"; | |
392 | else | |
393 | return "ldscripts/${EMULATION_NAME}.xdw"; | |
394 | } | |
a3813728 AK |
395 | EOF |
396 | if test -n "$GENERATE_RELRO_SCRIPT" ; then | |
397 | fragment <<EOF | |
398 | else if (bfd_link_pie (&link_info) | |
399 | && link_info.combreloc | |
400 | && link_info.relro) | |
401 | { | |
402 | if (link_info.separate_code) | |
403 | return "ldscripts/${EMULATION_NAME}.xdceo"; | |
404 | else | |
405 | return "ldscripts/${EMULATION_NAME}.xdco"; | |
406 | } | |
407 | EOF | |
408 | fi | |
409 | fragment <<EOF | |
0e1862bb L |
410 | else if (bfd_link_pie (&link_info) |
411 | && link_info.combreloc) | |
47acac12 L |
412 | { |
413 | if (link_info.separate_code) | |
414 | return "ldscripts/${EMULATION_NAME}.xdce"; | |
415 | else | |
416 | return "ldscripts/${EMULATION_NAME}.xdc"; | |
417 | } | |
36af4a4e JJ |
418 | EOF |
419 | fi | |
a3813728 AK |
420 | if test -n "$GENERATE_RELRO_SCRIPT" ; then |
421 | fragment <<EOF | |
422 | else if (bfd_link_pie (&link_info) | |
423 | && link_info.relro) | |
424 | { | |
425 | if (link_info.separate_code) | |
426 | return "ldscripts/${EMULATION_NAME}.xdeo"; | |
427 | else | |
428 | return "ldscripts/${EMULATION_NAME}.xdo"; | |
429 | } | |
430 | EOF | |
431 | fi | |
92b93329 | 432 | fragment <<EOF |
0e1862bb | 433 | else if (bfd_link_pie (&link_info)) |
47acac12 L |
434 | { |
435 | if (link_info.separate_code) | |
436 | return "ldscripts/${EMULATION_NAME}.xde"; | |
437 | else | |
438 | return "ldscripts/${EMULATION_NAME}.xd"; | |
439 | } | |
36af4a4e JJ |
440 | EOF |
441 | fi | |
a060b769 AM |
442 | if test -n "$GENERATE_SHLIB_SCRIPT" ; then |
443 | if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then | |
92b93329 | 444 | fragment <<EOF |
0e1862bb | 445 | else if (bfd_link_dll (&link_info) && link_info.combreloc |
fbfca19e | 446 | && link_info.relro && (link_info.flags & DF_BIND_NOW)) |
47acac12 L |
447 | { |
448 | if (link_info.separate_code) | |
449 | return "ldscripts/${EMULATION_NAME}.xswe"; | |
450 | else | |
451 | return "ldscripts/${EMULATION_NAME}.xsw"; | |
452 | } | |
a3813728 AK |
453 | EOF |
454 | if test -n "$GENERATE_RELRO_SCRIPT" ; then | |
455 | fragment <<EOF | |
456 | else if (bfd_link_dll (&link_info) | |
457 | && link_info.combreloc | |
458 | && link_info.relro) | |
459 | { | |
460 | if (link_info.separate_code) | |
461 | return "ldscripts/${EMULATION_NAME}.xsceo"; | |
462 | else | |
463 | return "ldscripts/${EMULATION_NAME}.xsco"; | |
464 | } | |
465 | EOF | |
466 | fi | |
467 | fragment <<EOF | |
0e1862bb | 468 | else if (bfd_link_dll (&link_info) && link_info.combreloc) |
47acac12 L |
469 | { |
470 | if (link_info.separate_code) | |
471 | return "ldscripts/${EMULATION_NAME}.xsce"; | |
472 | else | |
473 | return "ldscripts/${EMULATION_NAME}.xsc"; | |
474 | } | |
a060b769 AM |
475 | EOF |
476 | fi | |
a3813728 AK |
477 | if test -n "$GENERATE_RELRO_SCRIPT" ; then |
478 | fragment <<EOF | |
479 | else if (bfd_link_dll (&link_info) | |
480 | && link_info.relro) | |
481 | { | |
482 | if (link_info.separate_code) | |
483 | return "ldscripts/${EMULATION_NAME}.xseo"; | |
484 | else | |
485 | return "ldscripts/${EMULATION_NAME}.xso"; | |
486 | } | |
487 | EOF | |
488 | fi | |
92b93329 | 489 | fragment <<EOF |
0e1862bb | 490 | else if (bfd_link_dll (&link_info)) |
47acac12 L |
491 | { |
492 | if (link_info.separate_code) | |
493 | return "ldscripts/${EMULATION_NAME}.xse"; | |
494 | else | |
495 | return "ldscripts/${EMULATION_NAME}.xs"; | |
496 | } | |
a060b769 AM |
497 | EOF |
498 | fi | |
499 | if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then | |
92b93329 | 500 | fragment <<EOF |
8c37241b | 501 | else if (link_info.combreloc && link_info.relro |
fbfca19e | 502 | && (link_info.flags & DF_BIND_NOW)) |
47acac12 L |
503 | { |
504 | if (link_info.separate_code) | |
505 | return "ldscripts/${EMULATION_NAME}.xwe"; | |
506 | else | |
507 | return "ldscripts/${EMULATION_NAME}.xw"; | |
508 | } | |
a3813728 AK |
509 | EOF |
510 | if test -n "$GENERATE_RELRO_SCRIPT" ; then | |
511 | fragment <<EOF | |
512 | else if (link_info.combreloc | |
513 | && link_info.relro) | |
514 | { | |
515 | if (link_info.separate_code) | |
516 | return "ldscripts/${EMULATION_NAME}.xceo"; | |
517 | else | |
518 | return "ldscripts/${EMULATION_NAME}.xco"; | |
519 | } | |
520 | EOF | |
521 | fi | |
522 | fragment <<EOF | |
a060b769 | 523 | else if (link_info.combreloc) |
47acac12 L |
524 | { |
525 | if (link_info.separate_code) | |
526 | return "ldscripts/${EMULATION_NAME}.xce"; | |
527 | else | |
528 | return "ldscripts/${EMULATION_NAME}.xc"; | |
529 | } | |
a060b769 AM |
530 | EOF |
531 | fi | |
a3813728 AK |
532 | if test -n "$GENERATE_RELRO_SCRIPT" ; then |
533 | fragment <<EOF | |
534 | else if (link_info.relro) | |
535 | { | |
536 | if (link_info.separate_code) | |
537 | return "ldscripts/${EMULATION_NAME}.xeo"; | |
538 | else | |
539 | return "ldscripts/${EMULATION_NAME}.xo"; | |
540 | } | |
541 | EOF | |
542 | fi | |
92b93329 | 543 | fragment <<EOF |
252b5132 | 544 | else |
47acac12 L |
545 | { |
546 | if (link_info.separate_code) | |
547 | return "ldscripts/${EMULATION_NAME}.xe"; | |
548 | else | |
549 | return "ldscripts/${EMULATION_NAME}.x"; | |
550 | } | |
252b5132 | 551 | } |
252b5132 | 552 | |
3b108066 | 553 | EOF |
41392f03 AM |
554 | fi |
555 | fi | |
3b108066 | 556 | |
e0ee487b | 557 | if test -n "$PARSE_AND_LIST_PROLOGUE" ; then |
92b93329 | 558 | fragment <<EOF |
e0ee487b L |
559 | $PARSE_AND_LIST_PROLOGUE |
560 | EOF | |
561 | fi | |
562 | ||
92b93329 | 563 | fragment <<EOF |
e0ee487b | 564 | |
29063f8b NC |
565 | enum elf_options |
566 | { | |
567 | OPTION_DISABLE_NEW_DTAGS = 400, | |
568 | OPTION_ENABLE_NEW_DTAGS, | |
569 | OPTION_GROUP, | |
570 | OPTION_EH_FRAME_HDR, | |
571 | OPTION_NO_EH_FRAME_HDR, | |
572 | OPTION_EXCLUDE_LIBS, | |
573 | OPTION_HASH_STYLE, | |
574 | OPTION_BUILD_ID, | |
575 | OPTION_AUDIT, | |
576 | OPTION_COMPRESS_DEBUG | |
577 | }; | |
e13629bc | 578 | |
3bcf5557 | 579 | static void |
0c7a8e5a AM |
580 | gld${EMULATION_NAME}_add_options |
581 | (int ns, char **shortopts, int nl, struct option **longopts, | |
582 | int nrl ATTRIBUTE_UNUSED, struct option **really_longopts ATTRIBUTE_UNUSED) | |
e0ee487b | 583 | { |
fb42df5e AM |
584 | EOF |
585 | if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then | |
586 | fragment <<EOF | |
7ee314fa | 587 | static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:P:"; |
fb42df5e AM |
588 | EOF |
589 | else | |
590 | fragment <<EOF | |
591 | static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:"; | |
592 | EOF | |
593 | fi | |
594 | fragment <<EOF | |
3bcf5557 | 595 | static const struct option xtra_long[] = { |
fb42df5e AM |
596 | EOF |
597 | if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then | |
598 | fragment <<EOF | |
7ee314fa | 599 | {"audit", required_argument, NULL, OPTION_AUDIT}, |
fb42df5e AM |
600 | {"Bgroup", no_argument, NULL, OPTION_GROUP}, |
601 | EOF | |
602 | fi | |
603 | fragment <<EOF | |
604 | {"build-id", optional_argument, NULL, OPTION_BUILD_ID}, | |
0ce398f1 | 605 | {"compress-debug-sections", required_argument, NULL, OPTION_COMPRESS_DEBUG}, |
e0ee487b | 606 | EOF |
e0ee487b | 607 | if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then |
92b93329 | 608 | fragment <<EOF |
fb42df5e | 609 | {"depaudit", required_argument, NULL, 'P'}, |
3bcf5557 AM |
610 | {"disable-new-dtags", no_argument, NULL, OPTION_DISABLE_NEW_DTAGS}, |
611 | {"enable-new-dtags", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS}, | |
612 | {"eh-frame-hdr", no_argument, NULL, OPTION_EH_FRAME_HDR}, | |
29063f8b | 613 | {"no-eh-frame-hdr", no_argument, NULL, OPTION_NO_EH_FRAME_HDR}, |
b58f81ae | 614 | {"exclude-libs", required_argument, NULL, OPTION_EXCLUDE_LIBS}, |
fdc90cb4 | 615 | {"hash-style", required_argument, NULL, OPTION_HASH_STYLE}, |
e0ee487b L |
616 | EOF |
617 | fi | |
e0ee487b | 618 | if test -n "$PARSE_AND_LIST_LONGOPTS" ; then |
92b93329 | 619 | fragment <<EOF |
3bcf5557 | 620 | $PARSE_AND_LIST_LONGOPTS |
e0ee487b L |
621 | EOF |
622 | fi | |
92b93329 | 623 | fragment <<EOF |
3bcf5557 AM |
624 | {NULL, no_argument, NULL, 0} |
625 | }; | |
626 | ||
627 | *shortopts = (char *) xrealloc (*shortopts, ns + sizeof (xtra_short)); | |
628 | memcpy (*shortopts + ns, &xtra_short, sizeof (xtra_short)); | |
629 | *longopts = (struct option *) | |
630 | xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long)); | |
631 | memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long)); | |
632 | } | |
04925e1e | 633 | |
24382dca | 634 | #define DEFAULT_BUILD_ID_STYLE "sha1" |
c0065db7 | 635 | |
f38a2680 | 636 | static bool |
0c7a8e5a | 637 | gld${EMULATION_NAME}_handle_option (int optc) |
e0ee487b | 638 | { |
e0ee487b L |
639 | switch (optc) |
640 | { | |
641 | default: | |
f38a2680 | 642 | return false; |
6c1439be | 643 | |
c0065db7 | 644 | case OPTION_BUILD_ID: |
5e2ab612 AM |
645 | free ((char *) ldelf_emit_note_gnu_build_id); |
646 | ldelf_emit_note_gnu_build_id = NULL; | |
c0065db7 RM |
647 | if (optarg == NULL) |
648 | optarg = DEFAULT_BUILD_ID_STYLE; | |
649 | if (strcmp (optarg, "none")) | |
d871d478 | 650 | ldelf_emit_note_gnu_build_id = xstrdup (optarg); |
c0065db7 | 651 | break; |
fb42df5e | 652 | |
0ce398f1 L |
653 | case OPTION_COMPRESS_DEBUG: |
654 | if (strcasecmp (optarg, "none") == 0) | |
655 | link_info.compress_debug = COMPRESS_DEBUG_NONE; | |
656 | else if (strcasecmp (optarg, "zlib") == 0) | |
19a7fe52 | 657 | link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB; |
0ce398f1 L |
658 | else if (strcasecmp (optarg, "zlib-gnu") == 0) |
659 | link_info.compress_debug = COMPRESS_DEBUG_GNU_ZLIB; | |
660 | else if (strcasecmp (optarg, "zlib-gabi") == 0) | |
661 | link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB; | |
662 | else | |
df5f2391 | 663 | einfo (_("%F%P: invalid --compress-debug-sections option: \`%s'\n"), |
0ce398f1 L |
664 | optarg); |
665 | break; | |
fb42df5e AM |
666 | EOF |
667 | ||
668 | if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then | |
669 | fragment <<EOF | |
7ee314fa | 670 | case OPTION_AUDIT: |
d871d478 | 671 | ldelf_append_to_separated_string (&audit, optarg); |
7ee314fa | 672 | break; |
fb42df5e | 673 | |
7ee314fa | 674 | case 'P': |
d871d478 | 675 | ldelf_append_to_separated_string (&depaudit, optarg); |
7ee314fa | 676 | break; |
c0065db7 | 677 | |
6c1439be | 678 | case OPTION_DISABLE_NEW_DTAGS: |
f38a2680 | 679 | link_info.new_dtags = false; |
6c1439be L |
680 | break; |
681 | ||
682 | case OPTION_ENABLE_NEW_DTAGS: | |
f38a2680 | 683 | link_info.new_dtags = true; |
6c1439be L |
684 | break; |
685 | ||
65765700 | 686 | case OPTION_EH_FRAME_HDR: |
2f0c68f2 | 687 | link_info.eh_frame_hdr_type = DWARF2_EH_HDR; |
65765700 JJ |
688 | break; |
689 | ||
29063f8b NC |
690 | case OPTION_NO_EH_FRAME_HDR: |
691 | link_info.eh_frame_hdr_type = 0; | |
692 | break; | |
693 | ||
a1ab1d2a UD |
694 | case OPTION_GROUP: |
695 | link_info.flags_1 |= (bfd_vma) DF_1_GROUP; | |
696 | /* Groups must be self-contained. */ | |
95a51568 FS |
697 | link_info.unresolved_syms_in_objects = RM_DIAGNOSE; |
698 | link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE; | |
a1ab1d2a UD |
699 | break; |
700 | ||
b58f81ae DJ |
701 | case OPTION_EXCLUDE_LIBS: |
702 | add_excluded_libs (optarg); | |
703 | break; | |
704 | ||
fdc90cb4 | 705 | case OPTION_HASH_STYLE: |
f38a2680 AM |
706 | link_info.emit_hash = false; |
707 | link_info.emit_gnu_hash = false; | |
fdc90cb4 | 708 | if (strcmp (optarg, "sysv") == 0) |
f38a2680 | 709 | link_info.emit_hash = true; |
fdc90cb4 | 710 | else if (strcmp (optarg, "gnu") == 0) |
f38a2680 | 711 | link_info.emit_gnu_hash = true; |
fdc90cb4 JJ |
712 | else if (strcmp (optarg, "both") == 0) |
713 | { | |
f38a2680 AM |
714 | link_info.emit_hash = true; |
715 | link_info.emit_gnu_hash = true; | |
fdc90cb4 JJ |
716 | } |
717 | else | |
df5f2391 | 718 | einfo (_("%F%P: invalid hash style \`%s'\n"), optarg); |
fdc90cb4 JJ |
719 | break; |
720 | ||
fb42df5e AM |
721 | EOF |
722 | fi | |
723 | fragment <<EOF | |
e0ee487b | 724 | case 'z': |
fb42df5e | 725 | if (strcmp (optarg, "defs") == 0) |
95a51568 | 726 | link_info.unresolved_syms_in_objects = RM_DIAGNOSE; |
97a232d7 NC |
727 | else if (strcmp (optarg, "undefs") == 0) |
728 | link_info.unresolved_syms_in_objects = RM_IGNORE; | |
fb42df5e | 729 | else if (strcmp (optarg, "muldefs") == 0) |
f38a2680 | 730 | link_info.allow_multiple_definition = true; |
08dedd66 | 731 | else if (startswith (optarg, "max-page-size=")) |
fb42df5e AM |
732 | { |
733 | char *end; | |
734 | ||
c410035d AM |
735 | link_info.maxpagesize = strtoul (optarg + 14, &end, 0); |
736 | if (*end | |
737 | || (link_info.maxpagesize & (link_info.maxpagesize - 1)) != 0) | |
eca4b721 | 738 | einfo (_("%F%P: invalid maximum page size \`%s'\n"), |
fb42df5e | 739 | optarg + 14); |
74e315db | 740 | link_info.maxpagesize_is_set = true; |
fb42df5e | 741 | } |
08dedd66 | 742 | else if (startswith (optarg, "common-page-size=")) |
fb42df5e AM |
743 | { |
744 | char *end; | |
c410035d | 745 | link_info.commonpagesize = strtoul (optarg + 17, &end, 0); |
fb42df5e | 746 | if (*end |
c410035d | 747 | || (link_info.commonpagesize & (link_info.commonpagesize - 1)) != 0) |
df5f2391 | 748 | einfo (_("%F%P: invalid common page size \`%s'\n"), |
fb42df5e | 749 | optarg + 17); |
ff66e8c5 | 750 | link_info.commonpagesize_is_set = true; |
fb42df5e | 751 | } |
08dedd66 | 752 | else if (startswith (optarg, "stack-size=")) |
04c3a755 NS |
753 | { |
754 | char *end; | |
755 | link_info.stacksize = strtoul (optarg + 11, &end, 0); | |
756 | if (*end || link_info.stacksize < 0) | |
df5f2391 | 757 | einfo (_("%F%P: invalid stack size \`%s'\n"), optarg + 11); |
04c3a755 NS |
758 | if (!link_info.stacksize) |
759 | /* Use -1 for explicit no-stack, because zero means | |
760 | 'default'. */ | |
761 | link_info.stacksize = -1; | |
762 | } | |
fb42df5e AM |
763 | else if (strcmp (optarg, "execstack") == 0) |
764 | { | |
f38a2680 AM |
765 | link_info.execstack = true; |
766 | link_info.noexecstack = false; | |
fb42df5e AM |
767 | } |
768 | else if (strcmp (optarg, "noexecstack") == 0) | |
769 | { | |
f38a2680 AM |
770 | link_info.noexecstack = true; |
771 | link_info.execstack = false; | |
fb42df5e | 772 | } |
496afd17 | 773 | else if (strcmp (optarg, "unique-symbol") == 0) |
f38a2680 | 774 | link_info.unique_symbol = true; |
496afd17 | 775 | else if (strcmp (optarg, "nounique-symbol") == 0) |
f38a2680 | 776 | link_info.unique_symbol = false; |
93ab9c0d NC |
777 | else if (strcmp (optarg, "globalaudit") == 0) |
778 | { | |
779 | link_info.flags_1 |= DF_1_GLOBAUDIT; | |
780 | } | |
08dedd66 | 781 | else if (startswith (optarg, "start-stop-gc")) |
f38a2680 | 782 | link_info.start_stop_gc = true; |
08dedd66 | 783 | else if (startswith (optarg, "nostart-stop-gc")) |
f38a2680 | 784 | link_info.start_stop_gc = false; |
08dedd66 | 785 | else if (startswith (optarg, "start-stop-visibility=")) |
cae64165 RM |
786 | { |
787 | if (strcmp (optarg, "start-stop-visibility=default") == 0) | |
788 | link_info.start_stop_visibility = STV_DEFAULT; | |
789 | else if (strcmp (optarg, "start-stop-visibility=internal") == 0) | |
790 | link_info.start_stop_visibility = STV_INTERNAL; | |
791 | else if (strcmp (optarg, "start-stop-visibility=hidden") == 0) | |
792 | link_info.start_stop_visibility = STV_HIDDEN; | |
793 | else if (strcmp (optarg, "start-stop-visibility=protected") == 0) | |
794 | link_info.start_stop_visibility = STV_PROTECTED; | |
795 | else | |
796 | einfo (_("%F%P: invalid visibility in \`-z %s'; " | |
797 | "must be default, internal, hidden, or protected"), | |
798 | optarg); | |
799 | } | |
fb42df5e | 800 | EOF |
d258b828 | 801 | |
fb42df5e AM |
802 | if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then |
803 | fragment <<EOF | |
b039ef04 L |
804 | else if (strcmp (optarg, "global") == 0) |
805 | link_info.flags_1 |= (bfd_vma) DF_1_GLOBAL; | |
fb42df5e | 806 | else if (strcmp (optarg, "initfirst") == 0) |
e0ee487b L |
807 | link_info.flags_1 |= (bfd_vma) DF_1_INITFIRST; |
808 | else if (strcmp (optarg, "interpose") == 0) | |
809 | link_info.flags_1 |= (bfd_vma) DF_1_INTERPOSE; | |
810 | else if (strcmp (optarg, "loadfltr") == 0) | |
811 | link_info.flags_1 |= (bfd_vma) DF_1_LOADFLTR; | |
812 | else if (strcmp (optarg, "nodefaultlib") == 0) | |
813 | link_info.flags_1 |= (bfd_vma) DF_1_NODEFLIB; | |
814 | else if (strcmp (optarg, "nodelete") == 0) | |
815 | link_info.flags_1 |= (bfd_vma) DF_1_NODELETE; | |
816 | else if (strcmp (optarg, "nodlopen") == 0) | |
817 | link_info.flags_1 |= (bfd_vma) DF_1_NOOPEN; | |
818 | else if (strcmp (optarg, "nodump") == 0) | |
819 | link_info.flags_1 |= (bfd_vma) DF_1_NODUMP; | |
820 | else if (strcmp (optarg, "now") == 0) | |
821 | { | |
822 | link_info.flags |= (bfd_vma) DF_BIND_NOW; | |
823 | link_info.flags_1 |= (bfd_vma) DF_1_NOW; | |
824 | } | |
5fa222e4 AM |
825 | else if (strcmp (optarg, "lazy") == 0) |
826 | { | |
827 | link_info.flags &= ~(bfd_vma) DF_BIND_NOW; | |
828 | link_info.flags_1 &= ~(bfd_vma) DF_1_NOW; | |
829 | } | |
e0ee487b L |
830 | else if (strcmp (optarg, "origin") == 0) |
831 | { | |
832 | link_info.flags |= (bfd_vma) DF_ORIGIN; | |
833 | link_info.flags_1 |= (bfd_vma) DF_1_ORIGIN; | |
834 | } | |
6a0a0dd0 VDM |
835 | else if (strcmp (optarg, "unique") == 0) |
836 | link_info.gnu_flags_1 |= (bfd_vma) DF_GNU_1_UNIQUE; | |
837 | else if (strcmp (optarg, "nounique") == 0) | |
838 | link_info.gnu_flags_1 &= ~(bfd_vma) DF_GNU_1_UNIQUE; | |
db6751f2 | 839 | else if (strcmp (optarg, "combreloc") == 0) |
f38a2680 | 840 | link_info.combreloc = true; |
db6751f2 | 841 | else if (strcmp (optarg, "nocombreloc") == 0) |
f38a2680 | 842 | link_info.combreloc = false; |
8bd621d8 | 843 | else if (strcmp (optarg, "nocopyreloc") == 0) |
f38a2680 | 844 | link_info.nocopyreloc = true; |
5fd104ad AM |
845 | EOF |
846 | if test -n "$COMMONPAGESIZE"; then | |
847 | fragment <<EOF | |
8c37241b | 848 | else if (strcmp (optarg, "relro") == 0) |
f38a2680 | 849 | link_info.relro = true; |
8c37241b | 850 | else if (strcmp (optarg, "norelro") == 0) |
f38a2680 | 851 | link_info.relro = false; |
5fd104ad AM |
852 | EOF |
853 | fi | |
854 | fragment <<EOF | |
47acac12 | 855 | else if (strcmp (optarg, "separate-code") == 0) |
f38a2680 | 856 | link_info.separate_code = true; |
47acac12 | 857 | else if (strcmp (optarg, "noseparate-code") == 0) |
f38a2680 | 858 | link_info.separate_code = false; |
b8871f35 L |
859 | else if (strcmp (optarg, "common") == 0) |
860 | link_info.elf_stt_common = elf_stt_common; | |
861 | else if (strcmp (optarg, "nocommon") == 0) | |
862 | link_info.elf_stt_common = no_elf_stt_common; | |
c192a133 | 863 | else if (strcmp (optarg, "text") == 0) |
a6dbf402 | 864 | link_info.textrel_check = textrel_check_error; |
c192a133 | 865 | else if (strcmp (optarg, "notext") == 0) |
a6dbf402 | 866 | link_info.textrel_check = textrel_check_none; |
c192a133 | 867 | else if (strcmp (optarg, "textoff") == 0) |
a6dbf402 | 868 | link_info.textrel_check = textrel_check_none; |
88b882e9 | 869 | EOF |
fb42df5e | 870 | fi |
88b882e9 | 871 | |
eba27bd7 L |
872 | if test -n "$PARSE_AND_LIST_ARGS_CASE_Z" ; then |
873 | fragment <<EOF | |
874 | $PARSE_AND_LIST_ARGS_CASE_Z | |
875 | EOF | |
876 | fi | |
877 | ||
92b93329 | 878 | fragment <<EOF |
fb42df5e | 879 | else |
df5f2391 | 880 | einfo (_("%P: warning: -z %s ignored\n"), optarg); |
6c1439be | 881 | break; |
e0ee487b | 882 | EOF |
e0ee487b L |
883 | |
884 | if test -n "$PARSE_AND_LIST_ARGS_CASES" ; then | |
92b93329 | 885 | fragment <<EOF |
e0ee487b L |
886 | $PARSE_AND_LIST_ARGS_CASES |
887 | EOF | |
888 | fi | |
889 | ||
92b93329 | 890 | fragment <<EOF |
e0ee487b L |
891 | } |
892 | ||
f38a2680 | 893 | return true; |
e0ee487b L |
894 | } |
895 | ||
41392f03 | 896 | EOF |
41392f03 | 897 | |
4b209b22 | 898 | if test x"$LDEMUL_LIST_OPTIONS" != xgld"$EMULATION_NAME"_list_options; then |
c58212ea | 899 | gld_list_options="gld${EMULATION_NAME}_list_options" |
eba27bd7 | 900 | if test -n "$PARSE_AND_LIST_OPTIONS"; then |
92b93329 | 901 | fragment <<EOF |
41392f03 | 902 | |
e0ee487b | 903 | static void |
0c7a8e5a | 904 | gld${EMULATION_NAME}_list_options (FILE * file) |
e0ee487b | 905 | { |
fb42df5e | 906 | EOF |
e0ee487b L |
907 | |
908 | if test -n "$PARSE_AND_LIST_OPTIONS" ; then | |
92b93329 | 909 | fragment <<EOF |
e0ee487b L |
910 | $PARSE_AND_LIST_OPTIONS |
911 | EOF | |
912 | fi | |
913 | ||
92b93329 | 914 | fragment <<EOF |
e0ee487b L |
915 | } |
916 | EOF | |
c58212ea L |
917 | else |
918 | gld_list_options="NULL" | |
919 | fi | |
e0ee487b L |
920 | |
921 | if test -n "$PARSE_AND_LIST_EPILOGUE" ; then | |
92b93329 | 922 | fragment <<EOF |
e0ee487b L |
923 | $PARSE_AND_LIST_EPILOGUE |
924 | EOF | |
925 | fi | |
41392f03 | 926 | fi |
e0ee487b | 927 | |
a9261391 | 928 | LDEMUL_AFTER_PARSE=${LDEMUL_AFTER_PARSE-ldelf_after_parse} |
320fdefe | 929 | LDEMUL_BEFORE_PLUGIN_ALL_SYMBOLS_READ=${LDEMUL_BEFORE_PLUGIN_ALL_SYMBOLS_READ-gld${EMULATION_NAME}_before_plugin_all_symbols_read} |
a9261391 L |
930 | LDEMUL_AFTER_OPEN=${LDEMUL_AFTER_OPEN-gld${EMULATION_NAME}_after_open} |
931 | LDEMUL_BEFORE_PLACE_ORPHANS=${LDEMUL_BEFORE_PLACE_ORPHANS-ldelf_before_place_orphans} | |
932 | LDEMUL_AFTER_ALLOCATION=${LDEMUL_AFTER_ALLOCATION-gld${EMULATION_NAME}_after_allocation} | |
933 | LDEMUL_SET_OUTPUT_ARCH=${LDEMUL_SET_OUTPUT_ARCH-ldelf_set_output_arch} | |
934 | LDEMUL_BEFORE_ALLOCATION=${LDEMUL_BEFORE_ALLOCATION-gld${EMULATION_NAME}_before_allocation} | |
935 | LDEMUL_OPEN_DYNAMIC_ARCHIVE=${LDEMUL_OPEN_DYNAMIC_ARCHIVE-ldelf_open_dynamic_archive} | |
936 | LDEMUL_PLACE_ORPHAN=${LDEMUL_PLACE_ORPHAN-ldelf_place_orphan} | |
937 | LDEMUL_ADD_OPTIONS=gld${EMULATION_NAME}_add_options | |
938 | LDEMUL_HANDLE_OPTION=gld${EMULATION_NAME}_handle_option | |
939 | LDEMUL_LIST_OPTIONS=${LDEMUL_LIST_OPTIONS-${gld_list_options}} | |
940 | LDEMUL_RECOGNIZED_FILE=${LDEMUL_RECOGNIZED_FILE-ldelf_load_symbols} | |
941 | ||
942 | source_em ${srcdir}/emultempl/emulation.em |