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.
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"
54 /* Declare functions used by various EXTRA_EM_FILEs. */
55 static void gld${EMULATION_NAME}_before_parse (void);
56 static void gld${EMULATION_NAME}_after_open (void);
57 static void gld${EMULATION_NAME}_before_allocation (void);
58 static void gld${EMULATION_NAME}_after_allocation (void);
61 # Import any needed special functions and/or overrides.
63 source_em ${srcdir}/emultempl/elf-generic.em
64 if test -n "$EXTRA_EM_FILE" ; then
65 source_em ${srcdir}/emultempl/${EXTRA_EM_FILE}.em
68 # Functions in this file can be overridden by setting the LDEMUL_* shell
69 # variables. If the name of the overriding function is the same as is
70 # defined in this file, then don't output this file's version.
71 # If a different overriding name is given then output the standard function
72 # as presumably it is called from the overriding function.
74 if test x"$LDEMUL_BEFORE_PARSE" != xgld"$EMULATION_NAME"_before_parse; then
78 gld${EMULATION_NAME}_before_parse (void)
80 ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
81 input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
82 config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
83 config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
84 link_info.check_relocs_after_open_input = TRUE;
85 link_info.relro = DEFAULT_LD_Z_RELRO;
86 link_info.separate_code = DEFAULT_LD_Z_SEPARATE_CODE;
94 /* These variables are used to implement target options */
96 static char *audit; /* colon (typically) separated list of libs */
97 static char *depaudit; /* colon (typically) separated list of libs */
101 if test x"$LDEMUL_AFTER_OPEN" != xgld"$EMULATION_NAME"_after_open; then
103 IS_LINUX_TARGET=FALSE
104 IS_FREEBSD_TARGET=FALSE
106 *-*-linux-* | *-*-k*bsd*-* | *-*-gnu*)
107 IS_LINUX_TARGET=TRUE ;;
108 *-*-freebsd* | *-*-dragonfly*)
109 IS_FREEBSD_TARGET=TRUE ;;
112 if test "x${USE_LIBPATH}" = xyes; then
116 if test "x${NATIVE}" = xyes; then
122 /* This is called after all the input files have been opened. */
125 gld${EMULATION_NAME}_after_open (void)
127 ldelf_after_open ($IS_LIBPATH, $IS_NATIVE,
128 $IS_LINUX_TARGET, $IS_FREEBSD_TARGET, $ELFSIZE);
134 if test x"$LDEMUL_BEFORE_ALLOCATION" != xgld"$EMULATION_NAME"_before_allocation; then
135 if test x"${ELF_INTERPRETER_NAME}" = x; then
136 ELF_INTERPRETER_NAME=NULL
140 /* This is called after the sections have been attached to output
141 sections, but before any sizes or addresses have been set. */
144 gld${EMULATION_NAME}_before_allocation (void)
146 ldelf_before_allocation (audit, depaudit, ${ELF_INTERPRETER_NAME});
152 if test x"$LDEMUL_AFTER_ALLOCATION" != xgld"$EMULATION_NAME"_after_allocation; then
156 gld${EMULATION_NAME}_after_allocation (void)
158 int need_layout = bfd_elf_discard_info (link_info.output_bfd, &link_info);
161 einfo (_("%X%P: .eh_frame/.stab edit: %E\n"));
163 ldelf_map_segments (need_layout);
168 if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then
172 gld${EMULATION_NAME}_get_script (int *isfile)
175 if test x"$COMPILE_IN" = xyes
177 # Scripts compiled in.
179 # sed commands to quote an ld script as a C string.
180 sc="-f stringify.sed"
186 if (bfd_link_relocatable (&link_info) && config.build_constructors)
189 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
190 echo ' ; else if (bfd_link_relocatable (&link_info)) return' >> e${EMULATION_NAME}.c
191 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
192 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
193 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
194 if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then : ; else
195 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
196 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
198 if test -n "$GENERATE_PIE_SCRIPT" ; then
199 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
200 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
201 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
202 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
203 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
204 sed $sc ldscripts/${EMULATION_NAME}.xdwe >> e${EMULATION_NAME}.c
205 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
206 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
207 echo ' && link_info.relro' >> e${EMULATION_NAME}.c
208 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
209 sed $sc ldscripts/${EMULATION_NAME}.xdw >> e${EMULATION_NAME}.c
210 if test -n "$GENERATE_RELRO_SCRIPT" ; then
211 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
212 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
213 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
214 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
215 sed $sc ldscripts/${EMULATION_NAME}.xdceo >> e${EMULATION_NAME}.c
217 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
218 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
219 echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c
220 sed $sc ldscripts/${EMULATION_NAME}.xdce >> e${EMULATION_NAME}.c
221 if test -n "$GENERATE_RELRO_SCRIPT" ; then
222 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
223 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
224 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
225 sed $sc ldscripts/${EMULATION_NAME}.xdco >> e${EMULATION_NAME}.c
227 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
228 echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c
229 sed $sc ldscripts/${EMULATION_NAME}.xdc >> e${EMULATION_NAME}.c
230 if test -n "$GENERATE_RELRO_SCRIPT" ; then
231 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
232 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
233 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
234 sed $sc ldscripts/${EMULATION_NAME}.xdeo >> e${EMULATION_NAME}.c
237 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
238 echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c
239 sed $sc ldscripts/${EMULATION_NAME}.xde >> e${EMULATION_NAME}.c
240 if test -n "$GENERATE_RELRO_SCRIPT" ; then
241 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
242 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
243 sed $sc ldscripts/${EMULATION_NAME}.xdo >> e${EMULATION_NAME}.c
245 echo ' ; else if (bfd_link_pie (&link_info)) return' >> e${EMULATION_NAME}.c
246 sed $sc ldscripts/${EMULATION_NAME}.xd >> e${EMULATION_NAME}.c
248 if test -n "$GENERATE_SHLIB_SCRIPT" ; then
249 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
250 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
251 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
252 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
253 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
254 sed $sc ldscripts/${EMULATION_NAME}.xswe >> e${EMULATION_NAME}.c
255 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
256 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
257 echo ' && link_info.relro' >> e${EMULATION_NAME}.c
258 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
259 sed $sc ldscripts/${EMULATION_NAME}.xsw >> e${EMULATION_NAME}.c
260 if test -n "$GENERATE_RELRO_SCRIPT" ; then
261 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
262 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
263 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
264 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
265 sed $sc ldscripts/${EMULATION_NAME}.xsceo >> e${EMULATION_NAME}.c
267 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
268 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
269 echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c
270 sed $sc ldscripts/${EMULATION_NAME}.xsce >> e${EMULATION_NAME}.c
271 if test -n "$GENERATE_RELRO_SCRIPT" ; then
272 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
273 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
274 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
275 sed $sc ldscripts/${EMULATION_NAME}.xsco >> e${EMULATION_NAME}.c
277 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
278 echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c
279 sed $sc ldscripts/${EMULATION_NAME}.xsc >> e${EMULATION_NAME}.c
280 if test -n "$GENERATE_RELRO_SCRIPT" ; then
281 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
282 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
283 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
284 sed $sc ldscripts/${EMULATION_NAME}.xseo >> e${EMULATION_NAME}.c
287 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
288 echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c
289 sed $sc ldscripts/${EMULATION_NAME}.xse >> e${EMULATION_NAME}.c
290 if test -n "$GENERATE_RELRO_SCRIPT" ; then
291 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
292 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
293 sed $sc ldscripts/${EMULATION_NAME}.xso >> e${EMULATION_NAME}.c
295 echo ' ; else if (bfd_link_dll (&link_info)) return' >> e${EMULATION_NAME}.c
296 sed $sc ldscripts/${EMULATION_NAME}.xs >> e${EMULATION_NAME}.c
298 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
299 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
300 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
301 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
302 sed $sc ldscripts/${EMULATION_NAME}.xwe >> e${EMULATION_NAME}.c
303 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
304 echo ' && link_info.relro' >> e${EMULATION_NAME}.c
305 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
306 sed $sc ldscripts/${EMULATION_NAME}.xw >> e${EMULATION_NAME}.c
307 if test -n "$GENERATE_RELRO_SCRIPT" ; then
308 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
309 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
310 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
311 sed $sc ldscripts/${EMULATION_NAME}.xceo >> e${EMULATION_NAME}.c
313 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
314 echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c
315 sed $sc ldscripts/${EMULATION_NAME}.xce >> e${EMULATION_NAME}.c
316 if test -n "$GENERATE_RELRO_SCRIPT" ; then
317 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
318 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
319 sed $sc ldscripts/${EMULATION_NAME}.xco >> e${EMULATION_NAME}.c
321 echo ' ; else if (link_info.combreloc) return' >> e${EMULATION_NAME}.c
322 sed $sc ldscripts/${EMULATION_NAME}.xc >> e${EMULATION_NAME}.c
324 if test -n "$GENERATE_RELRO_SCRIPT" ; then
325 echo ' ; else if (link_info.separate_code' >> e${EMULATION_NAME}.c
326 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
327 sed $sc ldscripts/${EMULATION_NAME}.xeo >> e${EMULATION_NAME}.c
329 echo ' ; else if (link_info.separate_code) return' >> e${EMULATION_NAME}.c
330 sed $sc ldscripts/${EMULATION_NAME}.xe >> e${EMULATION_NAME}.c
331 if test -n "$GENERATE_RELRO_SCRIPT" ; then
332 echo ' ; else if (link_info.relro) return' >> e${EMULATION_NAME}.c
333 sed $sc ldscripts/${EMULATION_NAME}.xo >> e${EMULATION_NAME}.c
335 echo ' ; else return' >> e${EMULATION_NAME}.c
336 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
337 echo '; }' >> e${EMULATION_NAME}.c
340 # Scripts read from the filesystem.
346 if (bfd_link_relocatable (&link_info) && config.build_constructors)
347 return "ldscripts/${EMULATION_NAME}.xu";
348 else if (bfd_link_relocatable (&link_info))
349 return "ldscripts/${EMULATION_NAME}.xr";
350 else if (!config.text_read_only)
351 return "ldscripts/${EMULATION_NAME}.xbn";
353 if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then :
356 else if (!config.magic_demand_paged)
357 return "ldscripts/${EMULATION_NAME}.xn";
360 if test -n "$GENERATE_PIE_SCRIPT" ; then
361 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
363 else if (bfd_link_pie (&link_info)
364 && link_info.combreloc
366 && (link_info.flags & DF_BIND_NOW))
368 if (link_info.separate_code)
369 return "ldscripts/${EMULATION_NAME}.xdwe";
371 return "ldscripts/${EMULATION_NAME}.xdw";
374 if test -n "$GENERATE_RELRO_SCRIPT" ; then
376 else if (bfd_link_pie (&link_info)
377 && link_info.combreloc
380 if (link_info.separate_code)
381 return "ldscripts/${EMULATION_NAME}.xdceo";
383 return "ldscripts/${EMULATION_NAME}.xdco";
388 else if (bfd_link_pie (&link_info)
389 && link_info.combreloc)
391 if (link_info.separate_code)
392 return "ldscripts/${EMULATION_NAME}.xdce";
394 return "ldscripts/${EMULATION_NAME}.xdc";
398 if test -n "$GENERATE_RELRO_SCRIPT" ; then
400 else if (bfd_link_pie (&link_info)
403 if (link_info.separate_code)
404 return "ldscripts/${EMULATION_NAME}.xdeo";
406 return "ldscripts/${EMULATION_NAME}.xdo";
411 else if (bfd_link_pie (&link_info))
413 if (link_info.separate_code)
414 return "ldscripts/${EMULATION_NAME}.xde";
416 return "ldscripts/${EMULATION_NAME}.xd";
420 if test -n "$GENERATE_SHLIB_SCRIPT" ; then
421 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
423 else if (bfd_link_dll (&link_info) && link_info.combreloc
424 && link_info.relro && (link_info.flags & DF_BIND_NOW))
426 if (link_info.separate_code)
427 return "ldscripts/${EMULATION_NAME}.xswe";
429 return "ldscripts/${EMULATION_NAME}.xsw";
432 if test -n "$GENERATE_RELRO_SCRIPT" ; then
434 else if (bfd_link_dll (&link_info)
435 && link_info.combreloc
438 if (link_info.separate_code)
439 return "ldscripts/${EMULATION_NAME}.xsceo";
441 return "ldscripts/${EMULATION_NAME}.xsco";
446 else if (bfd_link_dll (&link_info) && link_info.combreloc)
448 if (link_info.separate_code)
449 return "ldscripts/${EMULATION_NAME}.xsce";
451 return "ldscripts/${EMULATION_NAME}.xsc";
455 if test -n "$GENERATE_RELRO_SCRIPT" ; then
457 else if (bfd_link_dll (&link_info)
460 if (link_info.separate_code)
461 return "ldscripts/${EMULATION_NAME}.xseo";
463 return "ldscripts/${EMULATION_NAME}.xso";
468 else if (bfd_link_dll (&link_info))
470 if (link_info.separate_code)
471 return "ldscripts/${EMULATION_NAME}.xse";
473 return "ldscripts/${EMULATION_NAME}.xs";
477 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
479 else if (link_info.combreloc && link_info.relro
480 && (link_info.flags & DF_BIND_NOW))
482 if (link_info.separate_code)
483 return "ldscripts/${EMULATION_NAME}.xwe";
485 return "ldscripts/${EMULATION_NAME}.xw";
488 if test -n "$GENERATE_RELRO_SCRIPT" ; then
490 else if (link_info.combreloc
493 if (link_info.separate_code)
494 return "ldscripts/${EMULATION_NAME}.xceo";
496 return "ldscripts/${EMULATION_NAME}.xco";
501 else if (link_info.combreloc)
503 if (link_info.separate_code)
504 return "ldscripts/${EMULATION_NAME}.xce";
506 return "ldscripts/${EMULATION_NAME}.xc";
510 if test -n "$GENERATE_RELRO_SCRIPT" ; then
512 else if (link_info.relro)
514 if (link_info.separate_code)
515 return "ldscripts/${EMULATION_NAME}.xeo";
517 return "ldscripts/${EMULATION_NAME}.xo";
524 if (link_info.separate_code)
525 return "ldscripts/${EMULATION_NAME}.xe";
527 return "ldscripts/${EMULATION_NAME}.x";
535 if test -n "$PARSE_AND_LIST_PROLOGUE" ; then
537 $PARSE_AND_LIST_PROLOGUE
545 OPTION_DISABLE_NEW_DTAGS = 400,
546 OPTION_ENABLE_NEW_DTAGS,
549 OPTION_NO_EH_FRAME_HDR,
554 OPTION_COMPRESS_DEBUG
558 gld${EMULATION_NAME}_add_options
559 (int ns, char **shortopts, int nl, struct option **longopts,
560 int nrl ATTRIBUTE_UNUSED, struct option **really_longopts ATTRIBUTE_UNUSED)
563 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
565 static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:P:";
569 static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:";
573 static const struct option xtra_long[] = {
575 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
577 {"audit", required_argument, NULL, OPTION_AUDIT},
578 {"Bgroup", no_argument, NULL, OPTION_GROUP},
582 {"build-id", optional_argument, NULL, OPTION_BUILD_ID},
583 {"compress-debug-sections", required_argument, NULL, OPTION_COMPRESS_DEBUG},
585 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
587 {"depaudit", required_argument, NULL, 'P'},
588 {"disable-new-dtags", no_argument, NULL, OPTION_DISABLE_NEW_DTAGS},
589 {"enable-new-dtags", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS},
590 {"eh-frame-hdr", no_argument, NULL, OPTION_EH_FRAME_HDR},
591 {"no-eh-frame-hdr", no_argument, NULL, OPTION_NO_EH_FRAME_HDR},
592 {"exclude-libs", required_argument, NULL, OPTION_EXCLUDE_LIBS},
593 {"hash-style", required_argument, NULL, OPTION_HASH_STYLE},
596 if test -n "$PARSE_AND_LIST_LONGOPTS" ; then
598 $PARSE_AND_LIST_LONGOPTS
602 {NULL, no_argument, NULL, 0}
605 *shortopts = (char *) xrealloc (*shortopts, ns + sizeof (xtra_short));
606 memcpy (*shortopts + ns, &xtra_short, sizeof (xtra_short));
607 *longopts = (struct option *)
608 xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
609 memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
612 #define DEFAULT_BUILD_ID_STYLE "sha1"
615 gld${EMULATION_NAME}_handle_option (int optc)
622 case OPTION_BUILD_ID:
623 if (ldelf_emit_note_gnu_build_id != NULL)
625 free ((char *) ldelf_emit_note_gnu_build_id);
626 ldelf_emit_note_gnu_build_id = NULL;
629 optarg = DEFAULT_BUILD_ID_STYLE;
630 if (strcmp (optarg, "none"))
631 ldelf_emit_note_gnu_build_id = xstrdup (optarg);
634 case OPTION_COMPRESS_DEBUG:
635 if (strcasecmp (optarg, "none") == 0)
636 link_info.compress_debug = COMPRESS_DEBUG_NONE;
637 else if (strcasecmp (optarg, "zlib") == 0)
638 link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB;
639 else if (strcasecmp (optarg, "zlib-gnu") == 0)
640 link_info.compress_debug = COMPRESS_DEBUG_GNU_ZLIB;
641 else if (strcasecmp (optarg, "zlib-gabi") == 0)
642 link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB;
644 einfo (_("%F%P: invalid --compress-debug-sections option: \`%s'\n"),
649 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
652 ldelf_append_to_separated_string (&audit, optarg);
656 ldelf_append_to_separated_string (&depaudit, optarg);
659 case OPTION_DISABLE_NEW_DTAGS:
660 link_info.new_dtags = FALSE;
663 case OPTION_ENABLE_NEW_DTAGS:
664 link_info.new_dtags = TRUE;
667 case OPTION_EH_FRAME_HDR:
668 link_info.eh_frame_hdr_type = DWARF2_EH_HDR;
671 case OPTION_NO_EH_FRAME_HDR:
672 link_info.eh_frame_hdr_type = 0;
676 link_info.flags_1 |= (bfd_vma) DF_1_GROUP;
677 /* Groups must be self-contained. */
678 link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
679 link_info.unresolved_syms_in_shared_libs = RM_GENERATE_ERROR;
682 case OPTION_EXCLUDE_LIBS:
683 add_excluded_libs (optarg);
686 case OPTION_HASH_STYLE:
687 link_info.emit_hash = FALSE;
688 link_info.emit_gnu_hash = FALSE;
689 if (strcmp (optarg, "sysv") == 0)
690 link_info.emit_hash = TRUE;
691 else if (strcmp (optarg, "gnu") == 0)
692 link_info.emit_gnu_hash = TRUE;
693 else if (strcmp (optarg, "both") == 0)
695 link_info.emit_hash = TRUE;
696 link_info.emit_gnu_hash = TRUE;
699 einfo (_("%F%P: invalid hash style \`%s'\n"), optarg);
706 if (strcmp (optarg, "defs") == 0)
707 link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
708 else if (strcmp (optarg, "undefs") == 0)
709 link_info.unresolved_syms_in_objects = RM_IGNORE;
710 else if (strcmp (optarg, "muldefs") == 0)
711 link_info.allow_multiple_definition = TRUE;
712 else if (CONST_STRNEQ (optarg, "max-page-size="))
716 config.maxpagesize = strtoul (optarg + 14, &end, 0);
717 if (*end || (config.maxpagesize & (config.maxpagesize - 1)) != 0)
718 einfo (_("%F%P: invalid maximum page size \`%s'\n"),
721 else if (CONST_STRNEQ (optarg, "common-page-size="))
724 config.commonpagesize = strtoul (optarg + 17, &end, 0);
726 || (config.commonpagesize & (config.commonpagesize - 1)) != 0)
727 einfo (_("%F%P: invalid common page size \`%s'\n"),
730 else if (CONST_STRNEQ (optarg, "stack-size="))
733 link_info.stacksize = strtoul (optarg + 11, &end, 0);
734 if (*end || link_info.stacksize < 0)
735 einfo (_("%F%P: invalid stack size \`%s'\n"), optarg + 11);
736 if (!link_info.stacksize)
737 /* Use -1 for explicit no-stack, because zero means
739 link_info.stacksize = -1;
741 else if (strcmp (optarg, "execstack") == 0)
743 link_info.execstack = TRUE;
744 link_info.noexecstack = FALSE;
746 else if (strcmp (optarg, "noexecstack") == 0)
748 link_info.noexecstack = TRUE;
749 link_info.execstack = FALSE;
751 else if (strcmp (optarg, "globalaudit") == 0)
753 link_info.flags_1 |= DF_1_GLOBAUDIT;
757 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
759 else if (strcmp (optarg, "global") == 0)
760 link_info.flags_1 |= (bfd_vma) DF_1_GLOBAL;
761 else if (strcmp (optarg, "initfirst") == 0)
762 link_info.flags_1 |= (bfd_vma) DF_1_INITFIRST;
763 else if (strcmp (optarg, "interpose") == 0)
764 link_info.flags_1 |= (bfd_vma) DF_1_INTERPOSE;
765 else if (strcmp (optarg, "loadfltr") == 0)
766 link_info.flags_1 |= (bfd_vma) DF_1_LOADFLTR;
767 else if (strcmp (optarg, "nodefaultlib") == 0)
768 link_info.flags_1 |= (bfd_vma) DF_1_NODEFLIB;
769 else if (strcmp (optarg, "nodelete") == 0)
770 link_info.flags_1 |= (bfd_vma) DF_1_NODELETE;
771 else if (strcmp (optarg, "nodlopen") == 0)
772 link_info.flags_1 |= (bfd_vma) DF_1_NOOPEN;
773 else if (strcmp (optarg, "nodump") == 0)
774 link_info.flags_1 |= (bfd_vma) DF_1_NODUMP;
775 else if (strcmp (optarg, "now") == 0)
777 link_info.flags |= (bfd_vma) DF_BIND_NOW;
778 link_info.flags_1 |= (bfd_vma) DF_1_NOW;
780 else if (strcmp (optarg, "lazy") == 0)
782 link_info.flags &= ~(bfd_vma) DF_BIND_NOW;
783 link_info.flags_1 &= ~(bfd_vma) DF_1_NOW;
785 else if (strcmp (optarg, "origin") == 0)
787 link_info.flags |= (bfd_vma) DF_ORIGIN;
788 link_info.flags_1 |= (bfd_vma) DF_1_ORIGIN;
790 else if (strcmp (optarg, "combreloc") == 0)
791 link_info.combreloc = TRUE;
792 else if (strcmp (optarg, "nocombreloc") == 0)
793 link_info.combreloc = FALSE;
794 else if (strcmp (optarg, "nocopyreloc") == 0)
795 link_info.nocopyreloc = TRUE;
796 else if (strcmp (optarg, "relro") == 0)
797 link_info.relro = TRUE;
798 else if (strcmp (optarg, "norelro") == 0)
799 link_info.relro = FALSE;
800 else if (strcmp (optarg, "separate-code") == 0)
801 link_info.separate_code = TRUE;
802 else if (strcmp (optarg, "noseparate-code") == 0)
803 link_info.separate_code = FALSE;
804 else if (strcmp (optarg, "common") == 0)
805 link_info.elf_stt_common = elf_stt_common;
806 else if (strcmp (optarg, "nocommon") == 0)
807 link_info.elf_stt_common = no_elf_stt_common;
808 else if (strcmp (optarg, "text") == 0)
809 link_info.error_textrel = TRUE;
810 else if (strcmp (optarg, "notext") == 0)
811 link_info.error_textrel = FALSE;
812 else if (strcmp (optarg, "textoff") == 0)
813 link_info.error_textrel = FALSE;
817 if test -n "$PARSE_AND_LIST_ARGS_CASE_Z" ; then
819 $PARSE_AND_LIST_ARGS_CASE_Z
825 einfo (_("%P: warning: -z %s ignored\n"), optarg);
829 if test -n "$PARSE_AND_LIST_ARGS_CASES" ; then
831 $PARSE_AND_LIST_ARGS_CASES
843 if test x"$LDEMUL_LIST_OPTIONS" != xgld"$EMULATION_NAME"_list_options; then
844 gld_list_options="gld${EMULATION_NAME}_list_options"
845 if test -n "$PARSE_AND_LIST_OPTIONS"; then
849 gld${EMULATION_NAME}_list_options (FILE * file)
853 if test -n "$PARSE_AND_LIST_OPTIONS" ; then
855 $PARSE_AND_LIST_OPTIONS
863 gld_list_options="NULL"
866 if test -n "$PARSE_AND_LIST_EPILOGUE" ; then
868 $PARSE_AND_LIST_EPILOGUE
875 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
877 ${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse},
878 ${LDEMUL_SYSLIB-syslib_default},
879 ${LDEMUL_HLL-hll_default},
880 ${LDEMUL_AFTER_PARSE-ldelf_after_parse},
881 ${LDEMUL_AFTER_OPEN-gld${EMULATION_NAME}_after_open},
882 ${LDEMUL_AFTER_CHECK_RELOCS-after_check_relocs_default},
883 ${LDEMUL_AFTER_ALLOCATION-gld${EMULATION_NAME}_after_allocation},
884 ${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
885 ${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
886 ${LDEMUL_BEFORE_ALLOCATION-gld${EMULATION_NAME}_before_allocation},
887 ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
890 ${LDEMUL_FINISH-finish_default},
891 ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL},
892 ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-ldelf_open_dynamic_archive},
893 ${LDEMUL_PLACE_ORPHAN-ldelf_place_orphan},
894 ${LDEMUL_SET_SYMBOLS-NULL},
895 ${LDEMUL_PARSE_ARGS-NULL},
896 gld${EMULATION_NAME}_add_options,
897 gld${EMULATION_NAME}_handle_option,
898 ${LDEMUL_UNRECOGNIZED_FILE-NULL},
899 ${LDEMUL_LIST_OPTIONS-${gld_list_options}},
900 ${LDEMUL_RECOGNIZED_FILE-ldelf_load_symbols},
901 ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL},
902 ${LDEMUL_NEW_VERS_PATTERN-NULL},
903 ${LDEMUL_EXTRA_MAP_FILE_TEXT-NULL},
904 ${LDEMUL_EMIT_CTF_EARLY-NULL},
905 ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL}