1 # This shell script emits a C file. -*- C -*-
2 # It does some substitutions.
3 test -z "${ELFSIZE}" && ELFSIZE=32
4 if [ -z "$MACHINE" ]; then
7 OUTPUT_ARCH=${ARCH}:${MACHINE}
10 /* This file is is generated by a shell script. DO NOT EDIT! */
12 /* ${ELFSIZE} bit ELF emulation code for ${EMULATION_NAME}
13 Copyright (C) 1991-2019 Free Software Foundation, Inc.
14 Written by Steve Chamberlain <sac@cygnus.com>
15 ELF support by Ian Lance Taylor <ian@cygnus.com>
17 This file is part of the GNU Binutils.
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.
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.
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. */
34 #define TARGET_IS_${EMULATION_NAME}
38 #include "libiberty.h"
53 /* Declare functions used by various EXTRA_EM_FILEs. */
54 static void gld${EMULATION_NAME}_before_parse (void);
55 static void gld${EMULATION_NAME}_after_open (void);
56 static void gld${EMULATION_NAME}_before_allocation (void);
57 static void gld${EMULATION_NAME}_after_allocation (void);
60 # Import any needed special functions and/or overrides.
62 source_em ${srcdir}/emultempl/elf-generic.em
63 if test -n "$EXTRA_EM_FILE" ; then
64 source_em ${srcdir}/emultempl/${EXTRA_EM_FILE}.em
67 # Functions in this file can be overridden by setting the LDEMUL_* shell
68 # variables. If the name of the overriding function is the same as is
69 # defined in this file, then don't output this file's version.
70 # If a different overriding name is given then output the standard function
71 # as presumably it is called from the overriding function.
73 if test x"$LDEMUL_BEFORE_PARSE" != xgld"$EMULATION_NAME"_before_parse; then
77 gld${EMULATION_NAME}_before_parse (void)
79 ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
80 input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
81 config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
82 config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
83 link_info.check_relocs_after_open_input = TRUE;
84 link_info.relro = DEFAULT_LD_Z_RELRO;
85 link_info.separate_code = DEFAULT_LD_Z_SEPARATE_CODE;
93 /* These variables are used to implement target options */
95 static char *audit; /* colon (typically) separated list of libs */
96 static char *depaudit; /* colon (typically) separated list of libs */
100 if test x"$LDEMUL_AFTER_OPEN" != xgld"$EMULATION_NAME"_after_open; then
102 IS_LINUX_TARGET=FALSE
103 IS_FREEBSD_TARGET=FALSE
105 *-*-linux-* | *-*-k*bsd*-* | *-*-gnu*)
106 IS_LINUX_TARGET=TRUE ;;
107 *-*-freebsd* | *-*-dragonfly*)
108 IS_FREEBSD_TARGET=TRUE ;;
111 if test "x${USE_LIBPATH}" = xyes; then
115 if test "x${NATIVE}" = xyes; then
121 /* This is called after all the input files have been opened. */
124 gld${EMULATION_NAME}_after_open (void)
126 ldelf_after_open ($IS_LIBPATH, $IS_NATIVE,
127 $IS_LINUX_TARGET, $IS_FREEBSD_TARGET, $ELFSIZE);
133 if test x"$LDEMUL_BEFORE_ALLOCATION" != xgld"$EMULATION_NAME"_before_allocation; then
134 if test x"${ELF_INTERPRETER_NAME}" = x; then
135 ELF_INTERPRETER_NAME=NULL
139 /* This is called after the sections have been attached to output
140 sections, but before any sizes or addresses have been set. */
143 gld${EMULATION_NAME}_before_allocation (void)
145 ldelf_before_allocation (audit, depaudit, ${ELF_INTERPRETER_NAME});
151 if test x"$LDEMUL_AFTER_ALLOCATION" != xgld"$EMULATION_NAME"_after_allocation; then
155 gld${EMULATION_NAME}_after_allocation (void)
157 int need_layout = bfd_elf_discard_info (link_info.output_bfd, &link_info);
160 einfo (_("%X%P: .eh_frame/.stab edit: %E\n"));
162 ldelf_map_segments (need_layout);
167 if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then
171 gld${EMULATION_NAME}_get_script (int *isfile)
174 if test x"$COMPILE_IN" = xyes
176 # Scripts compiled in.
178 # sed commands to quote an ld script as a C string.
179 sc="-f stringify.sed"
185 if (bfd_link_relocatable (&link_info) && config.build_constructors)
188 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
189 echo ' ; else if (bfd_link_relocatable (&link_info)) return' >> e${EMULATION_NAME}.c
190 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
191 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
192 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
193 if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then : ; else
194 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
195 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
197 if test -n "$GENERATE_PIE_SCRIPT" ; then
198 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
199 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
200 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
201 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
202 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
203 sed $sc ldscripts/${EMULATION_NAME}.xdwe >> e${EMULATION_NAME}.c
204 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
205 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
206 echo ' && link_info.relro' >> e${EMULATION_NAME}.c
207 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
208 sed $sc ldscripts/${EMULATION_NAME}.xdw >> e${EMULATION_NAME}.c
209 if test -n "$GENERATE_RELRO_SCRIPT" ; then
210 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
211 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
212 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
213 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
214 sed $sc ldscripts/${EMULATION_NAME}.xdceo >> e${EMULATION_NAME}.c
216 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
217 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
218 echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c
219 sed $sc ldscripts/${EMULATION_NAME}.xdce >> e${EMULATION_NAME}.c
220 if test -n "$GENERATE_RELRO_SCRIPT" ; then
221 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
222 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
223 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
224 sed $sc ldscripts/${EMULATION_NAME}.xdco >> e${EMULATION_NAME}.c
226 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
227 echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c
228 sed $sc ldscripts/${EMULATION_NAME}.xdc >> e${EMULATION_NAME}.c
229 if test -n "$GENERATE_RELRO_SCRIPT" ; then
230 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
231 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
232 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
233 sed $sc ldscripts/${EMULATION_NAME}.xdeo >> e${EMULATION_NAME}.c
236 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
237 echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c
238 sed $sc ldscripts/${EMULATION_NAME}.xde >> e${EMULATION_NAME}.c
239 if test -n "$GENERATE_RELRO_SCRIPT" ; then
240 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
241 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
242 sed $sc ldscripts/${EMULATION_NAME}.xdo >> e${EMULATION_NAME}.c
244 echo ' ; else if (bfd_link_pie (&link_info)) return' >> e${EMULATION_NAME}.c
245 sed $sc ldscripts/${EMULATION_NAME}.xd >> e${EMULATION_NAME}.c
247 if test -n "$GENERATE_SHLIB_SCRIPT" ; then
248 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
249 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
250 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
251 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
252 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
253 sed $sc ldscripts/${EMULATION_NAME}.xswe >> e${EMULATION_NAME}.c
254 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
255 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
256 echo ' && link_info.relro' >> e${EMULATION_NAME}.c
257 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
258 sed $sc ldscripts/${EMULATION_NAME}.xsw >> e${EMULATION_NAME}.c
259 if test -n "$GENERATE_RELRO_SCRIPT" ; then
260 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
261 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
262 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
263 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
264 sed $sc ldscripts/${EMULATION_NAME}.xsceo >> e${EMULATION_NAME}.c
266 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
267 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
268 echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c
269 sed $sc ldscripts/${EMULATION_NAME}.xsce >> e${EMULATION_NAME}.c
270 if test -n "$GENERATE_RELRO_SCRIPT" ; then
271 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
272 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
273 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
274 sed $sc ldscripts/${EMULATION_NAME}.xsco >> e${EMULATION_NAME}.c
276 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
277 echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c
278 sed $sc ldscripts/${EMULATION_NAME}.xsc >> e${EMULATION_NAME}.c
279 if test -n "$GENERATE_RELRO_SCRIPT" ; then
280 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
281 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
282 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
283 sed $sc ldscripts/${EMULATION_NAME}.xseo >> e${EMULATION_NAME}.c
286 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
287 echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c
288 sed $sc ldscripts/${EMULATION_NAME}.xse >> e${EMULATION_NAME}.c
289 if test -n "$GENERATE_RELRO_SCRIPT" ; then
290 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
291 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
292 sed $sc ldscripts/${EMULATION_NAME}.xso >> e${EMULATION_NAME}.c
294 echo ' ; else if (bfd_link_dll (&link_info)) return' >> e${EMULATION_NAME}.c
295 sed $sc ldscripts/${EMULATION_NAME}.xs >> e${EMULATION_NAME}.c
297 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
298 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
299 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
300 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
301 sed $sc ldscripts/${EMULATION_NAME}.xwe >> e${EMULATION_NAME}.c
302 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
303 echo ' && link_info.relro' >> e${EMULATION_NAME}.c
304 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
305 sed $sc ldscripts/${EMULATION_NAME}.xw >> e${EMULATION_NAME}.c
306 if test -n "$GENERATE_RELRO_SCRIPT" ; then
307 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
308 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
309 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
310 sed $sc ldscripts/${EMULATION_NAME}.xceo >> e${EMULATION_NAME}.c
312 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
313 echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c
314 sed $sc ldscripts/${EMULATION_NAME}.xce >> e${EMULATION_NAME}.c
315 if test -n "$GENERATE_RELRO_SCRIPT" ; then
316 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
317 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
318 sed $sc ldscripts/${EMULATION_NAME}.xco >> e${EMULATION_NAME}.c
320 echo ' ; else if (link_info.combreloc) return' >> e${EMULATION_NAME}.c
321 sed $sc ldscripts/${EMULATION_NAME}.xc >> e${EMULATION_NAME}.c
323 if test -n "$GENERATE_RELRO_SCRIPT" ; then
324 echo ' ; else if (link_info.separate_code' >> e${EMULATION_NAME}.c
325 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
326 sed $sc ldscripts/${EMULATION_NAME}.xeo >> e${EMULATION_NAME}.c
328 echo ' ; else if (link_info.separate_code) return' >> e${EMULATION_NAME}.c
329 sed $sc ldscripts/${EMULATION_NAME}.xe >> e${EMULATION_NAME}.c
330 if test -n "$GENERATE_RELRO_SCRIPT" ; then
331 echo ' ; else if (link_info.relro) return' >> e${EMULATION_NAME}.c
332 sed $sc ldscripts/${EMULATION_NAME}.xo >> e${EMULATION_NAME}.c
334 echo ' ; else return' >> e${EMULATION_NAME}.c
335 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
336 echo '; }' >> e${EMULATION_NAME}.c
339 # Scripts read from the filesystem.
345 if (bfd_link_relocatable (&link_info) && config.build_constructors)
346 return "ldscripts/${EMULATION_NAME}.xu";
347 else if (bfd_link_relocatable (&link_info))
348 return "ldscripts/${EMULATION_NAME}.xr";
349 else if (!config.text_read_only)
350 return "ldscripts/${EMULATION_NAME}.xbn";
352 if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then :
355 else if (!config.magic_demand_paged)
356 return "ldscripts/${EMULATION_NAME}.xn";
359 if test -n "$GENERATE_PIE_SCRIPT" ; then
360 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
362 else if (bfd_link_pie (&link_info)
363 && link_info.combreloc
365 && (link_info.flags & DF_BIND_NOW))
367 if (link_info.separate_code)
368 return "ldscripts/${EMULATION_NAME}.xdwe";
370 return "ldscripts/${EMULATION_NAME}.xdw";
373 if test -n "$GENERATE_RELRO_SCRIPT" ; then
375 else if (bfd_link_pie (&link_info)
376 && link_info.combreloc
379 if (link_info.separate_code)
380 return "ldscripts/${EMULATION_NAME}.xdceo";
382 return "ldscripts/${EMULATION_NAME}.xdco";
387 else if (bfd_link_pie (&link_info)
388 && link_info.combreloc)
390 if (link_info.separate_code)
391 return "ldscripts/${EMULATION_NAME}.xdce";
393 return "ldscripts/${EMULATION_NAME}.xdc";
397 if test -n "$GENERATE_RELRO_SCRIPT" ; then
399 else if (bfd_link_pie (&link_info)
402 if (link_info.separate_code)
403 return "ldscripts/${EMULATION_NAME}.xdeo";
405 return "ldscripts/${EMULATION_NAME}.xdo";
410 else if (bfd_link_pie (&link_info))
412 if (link_info.separate_code)
413 return "ldscripts/${EMULATION_NAME}.xde";
415 return "ldscripts/${EMULATION_NAME}.xd";
419 if test -n "$GENERATE_SHLIB_SCRIPT" ; then
420 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
422 else if (bfd_link_dll (&link_info) && link_info.combreloc
423 && link_info.relro && (link_info.flags & DF_BIND_NOW))
425 if (link_info.separate_code)
426 return "ldscripts/${EMULATION_NAME}.xswe";
428 return "ldscripts/${EMULATION_NAME}.xsw";
431 if test -n "$GENERATE_RELRO_SCRIPT" ; then
433 else if (bfd_link_dll (&link_info)
434 && link_info.combreloc
437 if (link_info.separate_code)
438 return "ldscripts/${EMULATION_NAME}.xsceo";
440 return "ldscripts/${EMULATION_NAME}.xsco";
445 else if (bfd_link_dll (&link_info) && link_info.combreloc)
447 if (link_info.separate_code)
448 return "ldscripts/${EMULATION_NAME}.xsce";
450 return "ldscripts/${EMULATION_NAME}.xsc";
454 if test -n "$GENERATE_RELRO_SCRIPT" ; then
456 else if (bfd_link_dll (&link_info)
459 if (link_info.separate_code)
460 return "ldscripts/${EMULATION_NAME}.xseo";
462 return "ldscripts/${EMULATION_NAME}.xso";
467 else if (bfd_link_dll (&link_info))
469 if (link_info.separate_code)
470 return "ldscripts/${EMULATION_NAME}.xse";
472 return "ldscripts/${EMULATION_NAME}.xs";
476 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
478 else if (link_info.combreloc && link_info.relro
479 && (link_info.flags & DF_BIND_NOW))
481 if (link_info.separate_code)
482 return "ldscripts/${EMULATION_NAME}.xwe";
484 return "ldscripts/${EMULATION_NAME}.xw";
487 if test -n "$GENERATE_RELRO_SCRIPT" ; then
489 else if (link_info.combreloc
492 if (link_info.separate_code)
493 return "ldscripts/${EMULATION_NAME}.xceo";
495 return "ldscripts/${EMULATION_NAME}.xco";
500 else if (link_info.combreloc)
502 if (link_info.separate_code)
503 return "ldscripts/${EMULATION_NAME}.xce";
505 return "ldscripts/${EMULATION_NAME}.xc";
509 if test -n "$GENERATE_RELRO_SCRIPT" ; then
511 else if (link_info.relro)
513 if (link_info.separate_code)
514 return "ldscripts/${EMULATION_NAME}.xeo";
516 return "ldscripts/${EMULATION_NAME}.xo";
523 if (link_info.separate_code)
524 return "ldscripts/${EMULATION_NAME}.xe";
526 return "ldscripts/${EMULATION_NAME}.x";
534 if test -n "$PARSE_AND_LIST_PROLOGUE" ; then
536 $PARSE_AND_LIST_PROLOGUE
544 OPTION_DISABLE_NEW_DTAGS = 400,
545 OPTION_ENABLE_NEW_DTAGS,
548 OPTION_NO_EH_FRAME_HDR,
553 OPTION_COMPRESS_DEBUG
557 gld${EMULATION_NAME}_add_options
558 (int ns, char **shortopts, int nl, struct option **longopts,
559 int nrl ATTRIBUTE_UNUSED, struct option **really_longopts ATTRIBUTE_UNUSED)
562 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
564 static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:P:";
568 static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:";
572 static const struct option xtra_long[] = {
574 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
576 {"audit", required_argument, NULL, OPTION_AUDIT},
577 {"Bgroup", no_argument, NULL, OPTION_GROUP},
581 {"build-id", optional_argument, NULL, OPTION_BUILD_ID},
582 {"compress-debug-sections", required_argument, NULL, OPTION_COMPRESS_DEBUG},
584 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
586 {"depaudit", required_argument, NULL, 'P'},
587 {"disable-new-dtags", no_argument, NULL, OPTION_DISABLE_NEW_DTAGS},
588 {"enable-new-dtags", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS},
589 {"eh-frame-hdr", no_argument, NULL, OPTION_EH_FRAME_HDR},
590 {"no-eh-frame-hdr", no_argument, NULL, OPTION_NO_EH_FRAME_HDR},
591 {"exclude-libs", required_argument, NULL, OPTION_EXCLUDE_LIBS},
592 {"hash-style", required_argument, NULL, OPTION_HASH_STYLE},
595 if test -n "$PARSE_AND_LIST_LONGOPTS" ; then
597 $PARSE_AND_LIST_LONGOPTS
601 {NULL, no_argument, NULL, 0}
604 *shortopts = (char *) xrealloc (*shortopts, ns + sizeof (xtra_short));
605 memcpy (*shortopts + ns, &xtra_short, sizeof (xtra_short));
606 *longopts = (struct option *)
607 xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
608 memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
611 #define DEFAULT_BUILD_ID_STYLE "sha1"
614 gld${EMULATION_NAME}_handle_option (int optc)
621 case OPTION_BUILD_ID:
622 if (ldelf_emit_note_gnu_build_id != NULL)
624 free ((char *) ldelf_emit_note_gnu_build_id);
625 ldelf_emit_note_gnu_build_id = NULL;
628 optarg = DEFAULT_BUILD_ID_STYLE;
629 if (strcmp (optarg, "none"))
630 ldelf_emit_note_gnu_build_id = xstrdup (optarg);
633 case OPTION_COMPRESS_DEBUG:
634 if (strcasecmp (optarg, "none") == 0)
635 link_info.compress_debug = COMPRESS_DEBUG_NONE;
636 else if (strcasecmp (optarg, "zlib") == 0)
637 link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB;
638 else if (strcasecmp (optarg, "zlib-gnu") == 0)
639 link_info.compress_debug = COMPRESS_DEBUG_GNU_ZLIB;
640 else if (strcasecmp (optarg, "zlib-gabi") == 0)
641 link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB;
643 einfo (_("%F%P: invalid --compress-debug-sections option: \`%s'\n"),
648 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
651 ldelf_append_to_separated_string (&audit, optarg);
655 ldelf_append_to_separated_string (&depaudit, optarg);
658 case OPTION_DISABLE_NEW_DTAGS:
659 link_info.new_dtags = FALSE;
662 case OPTION_ENABLE_NEW_DTAGS:
663 link_info.new_dtags = TRUE;
666 case OPTION_EH_FRAME_HDR:
667 link_info.eh_frame_hdr_type = DWARF2_EH_HDR;
670 case OPTION_NO_EH_FRAME_HDR:
671 link_info.eh_frame_hdr_type = 0;
675 link_info.flags_1 |= (bfd_vma) DF_1_GROUP;
676 /* Groups must be self-contained. */
677 link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
678 link_info.unresolved_syms_in_shared_libs = RM_GENERATE_ERROR;
681 case OPTION_EXCLUDE_LIBS:
682 add_excluded_libs (optarg);
685 case OPTION_HASH_STYLE:
686 link_info.emit_hash = FALSE;
687 link_info.emit_gnu_hash = FALSE;
688 if (strcmp (optarg, "sysv") == 0)
689 link_info.emit_hash = TRUE;
690 else if (strcmp (optarg, "gnu") == 0)
691 link_info.emit_gnu_hash = TRUE;
692 else if (strcmp (optarg, "both") == 0)
694 link_info.emit_hash = TRUE;
695 link_info.emit_gnu_hash = TRUE;
698 einfo (_("%F%P: invalid hash style \`%s'\n"), optarg);
705 if (strcmp (optarg, "defs") == 0)
706 link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
707 else if (strcmp (optarg, "undefs") == 0)
708 link_info.unresolved_syms_in_objects = RM_IGNORE;
709 else if (strcmp (optarg, "muldefs") == 0)
710 link_info.allow_multiple_definition = TRUE;
711 else if (CONST_STRNEQ (optarg, "max-page-size="))
715 config.maxpagesize = strtoul (optarg + 14, &end, 0);
716 if (*end || (config.maxpagesize & (config.maxpagesize - 1)) != 0)
717 einfo (_("%F%P: invalid maximum page size \`%s'\n"),
720 else if (CONST_STRNEQ (optarg, "common-page-size="))
723 config.commonpagesize = strtoul (optarg + 17, &end, 0);
725 || (config.commonpagesize & (config.commonpagesize - 1)) != 0)
726 einfo (_("%F%P: invalid common page size \`%s'\n"),
729 else if (CONST_STRNEQ (optarg, "stack-size="))
732 link_info.stacksize = strtoul (optarg + 11, &end, 0);
733 if (*end || link_info.stacksize < 0)
734 einfo (_("%F%P: invalid stack size \`%s'\n"), optarg + 11);
735 if (!link_info.stacksize)
736 /* Use -1 for explicit no-stack, because zero means
738 link_info.stacksize = -1;
740 else if (strcmp (optarg, "execstack") == 0)
742 link_info.execstack = TRUE;
743 link_info.noexecstack = FALSE;
745 else if (strcmp (optarg, "noexecstack") == 0)
747 link_info.noexecstack = TRUE;
748 link_info.execstack = FALSE;
750 else if (strcmp (optarg, "globalaudit") == 0)
752 link_info.flags_1 |= DF_1_GLOBAUDIT;
756 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
758 else if (strcmp (optarg, "global") == 0)
759 link_info.flags_1 |= (bfd_vma) DF_1_GLOBAL;
760 else if (strcmp (optarg, "initfirst") == 0)
761 link_info.flags_1 |= (bfd_vma) DF_1_INITFIRST;
762 else if (strcmp (optarg, "interpose") == 0)
763 link_info.flags_1 |= (bfd_vma) DF_1_INTERPOSE;
764 else if (strcmp (optarg, "loadfltr") == 0)
765 link_info.flags_1 |= (bfd_vma) DF_1_LOADFLTR;
766 else if (strcmp (optarg, "nodefaultlib") == 0)
767 link_info.flags_1 |= (bfd_vma) DF_1_NODEFLIB;
768 else if (strcmp (optarg, "nodelete") == 0)
769 link_info.flags_1 |= (bfd_vma) DF_1_NODELETE;
770 else if (strcmp (optarg, "nodlopen") == 0)
771 link_info.flags_1 |= (bfd_vma) DF_1_NOOPEN;
772 else if (strcmp (optarg, "nodump") == 0)
773 link_info.flags_1 |= (bfd_vma) DF_1_NODUMP;
774 else if (strcmp (optarg, "now") == 0)
776 link_info.flags |= (bfd_vma) DF_BIND_NOW;
777 link_info.flags_1 |= (bfd_vma) DF_1_NOW;
779 else if (strcmp (optarg, "lazy") == 0)
781 link_info.flags &= ~(bfd_vma) DF_BIND_NOW;
782 link_info.flags_1 &= ~(bfd_vma) DF_1_NOW;
784 else if (strcmp (optarg, "origin") == 0)
786 link_info.flags |= (bfd_vma) DF_ORIGIN;
787 link_info.flags_1 |= (bfd_vma) DF_1_ORIGIN;
789 else if (strcmp (optarg, "combreloc") == 0)
790 link_info.combreloc = TRUE;
791 else if (strcmp (optarg, "nocombreloc") == 0)
792 link_info.combreloc = FALSE;
793 else if (strcmp (optarg, "nocopyreloc") == 0)
794 link_info.nocopyreloc = TRUE;
795 else if (strcmp (optarg, "relro") == 0)
796 link_info.relro = TRUE;
797 else if (strcmp (optarg, "norelro") == 0)
798 link_info.relro = FALSE;
799 else if (strcmp (optarg, "separate-code") == 0)
800 link_info.separate_code = TRUE;
801 else if (strcmp (optarg, "noseparate-code") == 0)
802 link_info.separate_code = FALSE;
803 else if (strcmp (optarg, "common") == 0)
804 link_info.elf_stt_common = elf_stt_common;
805 else if (strcmp (optarg, "nocommon") == 0)
806 link_info.elf_stt_common = no_elf_stt_common;
807 else if (strcmp (optarg, "text") == 0)
808 link_info.error_textrel = TRUE;
809 else if (strcmp (optarg, "notext") == 0)
810 link_info.error_textrel = FALSE;
811 else if (strcmp (optarg, "textoff") == 0)
812 link_info.error_textrel = FALSE;
816 if test -n "$PARSE_AND_LIST_ARGS_CASE_Z" ; then
818 $PARSE_AND_LIST_ARGS_CASE_Z
824 einfo (_("%P: warning: -z %s ignored\n"), optarg);
828 if test -n "$PARSE_AND_LIST_ARGS_CASES" ; then
830 $PARSE_AND_LIST_ARGS_CASES
842 if test x"$LDEMUL_LIST_OPTIONS" != xgld"$EMULATION_NAME"_list_options; then
843 gld_list_options="gld${EMULATION_NAME}_list_options"
844 if test -n "$PARSE_AND_LIST_OPTIONS"; then
848 gld${EMULATION_NAME}_list_options (FILE * file)
852 if test -n "$PARSE_AND_LIST_OPTIONS" ; then
854 $PARSE_AND_LIST_OPTIONS
862 gld_list_options="NULL"
865 if test -n "$PARSE_AND_LIST_EPILOGUE" ; then
867 $PARSE_AND_LIST_EPILOGUE
874 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
876 ${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse},
877 ${LDEMUL_SYSLIB-syslib_default},
878 ${LDEMUL_HLL-hll_default},
879 ${LDEMUL_AFTER_PARSE-ldelf_after_parse},
880 ${LDEMUL_AFTER_OPEN-gld${EMULATION_NAME}_after_open},
881 ${LDEMUL_AFTER_CHECK_RELOCS-after_check_relocs_default},
882 ${LDEMUL_AFTER_ALLOCATION-gld${EMULATION_NAME}_after_allocation},
883 ${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
884 ${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
885 ${LDEMUL_BEFORE_ALLOCATION-gld${EMULATION_NAME}_before_allocation},
886 ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
889 ${LDEMUL_FINISH-finish_default},
890 ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL},
891 ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-ldelf_open_dynamic_archive},
892 ${LDEMUL_PLACE_ORPHAN-ldelf_place_orphan},
893 ${LDEMUL_SET_SYMBOLS-NULL},
894 ${LDEMUL_PARSE_ARGS-NULL},
895 gld${EMULATION_NAME}_add_options,
896 gld${EMULATION_NAME}_handle_option,
897 ${LDEMUL_UNRECOGNIZED_FILE-NULL},
898 ${LDEMUL_LIST_OPTIONS-${gld_list_options}},
899 ${LDEMUL_RECOGNIZED_FILE-ldelf_load_symbols},
900 ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL},
901 ${LDEMUL_NEW_VERS_PATTERN-NULL},
902 ${LDEMUL_EXTRA_MAP_FILE_TEXT-NULL}