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-2020 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"
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;
86 if test -n "$COMMONPAGESIZE"; then
88 link_info.relro = DEFAULT_LD_Z_RELRO;
92 link_info.separate_code = DEFAULT_LD_Z_SEPARATE_CODE;
100 /* These variables are used to implement target options */
102 static char *audit; /* colon (typically) separated list of libs */
103 static char *depaudit; /* colon (typically) separated list of libs */
107 if test x"$LDEMUL_AFTER_OPEN" != xgld"$EMULATION_NAME"_after_open; then
109 IS_LINUX_TARGET=FALSE
110 IS_FREEBSD_TARGET=FALSE
112 *-*-linux-* | *-*-k*bsd*-* | *-*-gnu*)
113 IS_LINUX_TARGET=TRUE ;;
114 *-*-freebsd* | *-*-dragonfly*)
115 IS_FREEBSD_TARGET=TRUE ;;
118 if test "x${USE_LIBPATH}" = xyes; then
122 if test "x${NATIVE}" = xyes; then
128 /* This is called after all the input files have been opened. */
131 gld${EMULATION_NAME}_after_open (void)
133 ldelf_after_open ($IS_LIBPATH, $IS_NATIVE,
134 $IS_LINUX_TARGET, $IS_FREEBSD_TARGET, $ELFSIZE, "$prefix");
140 if test x"$LDEMUL_BEFORE_ALLOCATION" != xgld"$EMULATION_NAME"_before_allocation; then
141 if test x"${ELF_INTERPRETER_NAME}" = x; then
142 ELF_INTERPRETER_NAME=NULL
146 /* This is called after the sections have been attached to output
147 sections, but before any sizes or addresses have been set. */
150 gld${EMULATION_NAME}_before_allocation (void)
152 ldelf_before_allocation (audit, depaudit, ${ELF_INTERPRETER_NAME});
158 if test x"$LDEMUL_AFTER_ALLOCATION" != xgld"$EMULATION_NAME"_after_allocation; then
162 gld${EMULATION_NAME}_after_allocation (void)
164 int need_layout = bfd_elf_discard_info (link_info.output_bfd, &link_info);
167 einfo (_("%X%P: .eh_frame/.stab edit: %E\n"));
169 ldelf_map_segments (need_layout);
174 if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then
178 gld${EMULATION_NAME}_get_script (int *isfile)
181 if test x"$COMPILE_IN" = xyes
183 # Scripts compiled in.
185 # sed commands to quote an ld script as a C string.
186 sc="-f stringify.sed"
192 if (bfd_link_relocatable (&link_info) && config.build_constructors)
195 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
196 echo ' ; else if (bfd_link_relocatable (&link_info)) return' >> e${EMULATION_NAME}.c
197 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
198 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
199 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
200 if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then : ; else
201 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
202 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
204 if test -n "$GENERATE_PIE_SCRIPT" ; then
205 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
206 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
207 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
208 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
209 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
210 sed $sc ldscripts/${EMULATION_NAME}.xdwe >> e${EMULATION_NAME}.c
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.relro' >> e${EMULATION_NAME}.c
214 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
215 sed $sc ldscripts/${EMULATION_NAME}.xdw >> e${EMULATION_NAME}.c
216 if test -n "$GENERATE_RELRO_SCRIPT" ; then
217 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
218 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
219 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
220 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
221 sed $sc ldscripts/${EMULATION_NAME}.xdceo >> e${EMULATION_NAME}.c
223 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
224 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
225 echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c
226 sed $sc ldscripts/${EMULATION_NAME}.xdce >> e${EMULATION_NAME}.c
227 if test -n "$GENERATE_RELRO_SCRIPT" ; then
228 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
229 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
230 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
231 sed $sc ldscripts/${EMULATION_NAME}.xdco >> e${EMULATION_NAME}.c
233 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
234 echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c
235 sed $sc ldscripts/${EMULATION_NAME}.xdc >> e${EMULATION_NAME}.c
236 if test -n "$GENERATE_RELRO_SCRIPT" ; then
237 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
238 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
239 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
240 sed $sc ldscripts/${EMULATION_NAME}.xdeo >> e${EMULATION_NAME}.c
243 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
244 echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c
245 sed $sc ldscripts/${EMULATION_NAME}.xde >> e${EMULATION_NAME}.c
246 if test -n "$GENERATE_RELRO_SCRIPT" ; then
247 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
248 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
249 sed $sc ldscripts/${EMULATION_NAME}.xdo >> e${EMULATION_NAME}.c
251 echo ' ; else if (bfd_link_pie (&link_info)) return' >> e${EMULATION_NAME}.c
252 sed $sc ldscripts/${EMULATION_NAME}.xd >> e${EMULATION_NAME}.c
254 if test -n "$GENERATE_SHLIB_SCRIPT" ; then
255 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
256 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
257 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
258 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
259 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
260 sed $sc ldscripts/${EMULATION_NAME}.xswe >> e${EMULATION_NAME}.c
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.relro' >> e${EMULATION_NAME}.c
264 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
265 sed $sc ldscripts/${EMULATION_NAME}.xsw >> e${EMULATION_NAME}.c
266 if test -n "$GENERATE_RELRO_SCRIPT" ; then
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' >> e${EMULATION_NAME}.c
270 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
271 sed $sc ldscripts/${EMULATION_NAME}.xsceo >> e${EMULATION_NAME}.c
273 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
274 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
275 echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c
276 sed $sc ldscripts/${EMULATION_NAME}.xsce >> e${EMULATION_NAME}.c
277 if test -n "$GENERATE_RELRO_SCRIPT" ; then
278 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
279 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
280 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
281 sed $sc ldscripts/${EMULATION_NAME}.xsco >> e${EMULATION_NAME}.c
283 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
284 echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c
285 sed $sc ldscripts/${EMULATION_NAME}.xsc >> e${EMULATION_NAME}.c
286 if test -n "$GENERATE_RELRO_SCRIPT" ; then
287 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
288 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
289 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
290 sed $sc ldscripts/${EMULATION_NAME}.xseo >> e${EMULATION_NAME}.c
293 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
294 echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c
295 sed $sc ldscripts/${EMULATION_NAME}.xse >> e${EMULATION_NAME}.c
296 if test -n "$GENERATE_RELRO_SCRIPT" ; then
297 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
298 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
299 sed $sc ldscripts/${EMULATION_NAME}.xso >> e${EMULATION_NAME}.c
301 echo ' ; else if (bfd_link_dll (&link_info)) return' >> e${EMULATION_NAME}.c
302 sed $sc ldscripts/${EMULATION_NAME}.xs >> e${EMULATION_NAME}.c
304 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
305 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
306 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
307 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
308 sed $sc ldscripts/${EMULATION_NAME}.xwe >> e${EMULATION_NAME}.c
309 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
310 echo ' && link_info.relro' >> e${EMULATION_NAME}.c
311 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
312 sed $sc ldscripts/${EMULATION_NAME}.xw >> e${EMULATION_NAME}.c
313 if test -n "$GENERATE_RELRO_SCRIPT" ; then
314 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
315 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
316 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
317 sed $sc ldscripts/${EMULATION_NAME}.xceo >> e${EMULATION_NAME}.c
319 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
320 echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c
321 sed $sc ldscripts/${EMULATION_NAME}.xce >> e${EMULATION_NAME}.c
322 if test -n "$GENERATE_RELRO_SCRIPT" ; then
323 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
324 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
325 sed $sc ldscripts/${EMULATION_NAME}.xco >> e${EMULATION_NAME}.c
327 echo ' ; else if (link_info.combreloc) return' >> e${EMULATION_NAME}.c
328 sed $sc ldscripts/${EMULATION_NAME}.xc >> e${EMULATION_NAME}.c
330 if test -n "$GENERATE_RELRO_SCRIPT" ; then
331 echo ' ; else if (link_info.separate_code' >> e${EMULATION_NAME}.c
332 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
333 sed $sc ldscripts/${EMULATION_NAME}.xeo >> e${EMULATION_NAME}.c
335 echo ' ; else if (link_info.separate_code) return' >> e${EMULATION_NAME}.c
336 sed $sc ldscripts/${EMULATION_NAME}.xe >> e${EMULATION_NAME}.c
337 if test -n "$GENERATE_RELRO_SCRIPT" ; then
338 echo ' ; else if (link_info.relro) return' >> e${EMULATION_NAME}.c
339 sed $sc ldscripts/${EMULATION_NAME}.xo >> e${EMULATION_NAME}.c
341 echo ' ; else return' >> e${EMULATION_NAME}.c
342 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
343 echo '; }' >> e${EMULATION_NAME}.c
346 # Scripts read from the filesystem.
352 if (bfd_link_relocatable (&link_info) && config.build_constructors)
353 return "ldscripts/${EMULATION_NAME}.xu";
354 else if (bfd_link_relocatable (&link_info))
355 return "ldscripts/${EMULATION_NAME}.xr";
356 else if (!config.text_read_only)
357 return "ldscripts/${EMULATION_NAME}.xbn";
359 if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then :
362 else if (!config.magic_demand_paged)
363 return "ldscripts/${EMULATION_NAME}.xn";
366 if test -n "$GENERATE_PIE_SCRIPT" ; then
367 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
369 else if (bfd_link_pie (&link_info)
370 && link_info.combreloc
372 && (link_info.flags & DF_BIND_NOW))
374 if (link_info.separate_code)
375 return "ldscripts/${EMULATION_NAME}.xdwe";
377 return "ldscripts/${EMULATION_NAME}.xdw";
380 if test -n "$GENERATE_RELRO_SCRIPT" ; then
382 else if (bfd_link_pie (&link_info)
383 && link_info.combreloc
386 if (link_info.separate_code)
387 return "ldscripts/${EMULATION_NAME}.xdceo";
389 return "ldscripts/${EMULATION_NAME}.xdco";
394 else if (bfd_link_pie (&link_info)
395 && link_info.combreloc)
397 if (link_info.separate_code)
398 return "ldscripts/${EMULATION_NAME}.xdce";
400 return "ldscripts/${EMULATION_NAME}.xdc";
404 if test -n "$GENERATE_RELRO_SCRIPT" ; then
406 else if (bfd_link_pie (&link_info)
409 if (link_info.separate_code)
410 return "ldscripts/${EMULATION_NAME}.xdeo";
412 return "ldscripts/${EMULATION_NAME}.xdo";
417 else if (bfd_link_pie (&link_info))
419 if (link_info.separate_code)
420 return "ldscripts/${EMULATION_NAME}.xde";
422 return "ldscripts/${EMULATION_NAME}.xd";
426 if test -n "$GENERATE_SHLIB_SCRIPT" ; then
427 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
429 else if (bfd_link_dll (&link_info) && link_info.combreloc
430 && link_info.relro && (link_info.flags & DF_BIND_NOW))
432 if (link_info.separate_code)
433 return "ldscripts/${EMULATION_NAME}.xswe";
435 return "ldscripts/${EMULATION_NAME}.xsw";
438 if test -n "$GENERATE_RELRO_SCRIPT" ; then
440 else if (bfd_link_dll (&link_info)
441 && link_info.combreloc
444 if (link_info.separate_code)
445 return "ldscripts/${EMULATION_NAME}.xsceo";
447 return "ldscripts/${EMULATION_NAME}.xsco";
452 else if (bfd_link_dll (&link_info) && link_info.combreloc)
454 if (link_info.separate_code)
455 return "ldscripts/${EMULATION_NAME}.xsce";
457 return "ldscripts/${EMULATION_NAME}.xsc";
461 if test -n "$GENERATE_RELRO_SCRIPT" ; then
463 else if (bfd_link_dll (&link_info)
466 if (link_info.separate_code)
467 return "ldscripts/${EMULATION_NAME}.xseo";
469 return "ldscripts/${EMULATION_NAME}.xso";
474 else if (bfd_link_dll (&link_info))
476 if (link_info.separate_code)
477 return "ldscripts/${EMULATION_NAME}.xse";
479 return "ldscripts/${EMULATION_NAME}.xs";
483 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
485 else if (link_info.combreloc && link_info.relro
486 && (link_info.flags & DF_BIND_NOW))
488 if (link_info.separate_code)
489 return "ldscripts/${EMULATION_NAME}.xwe";
491 return "ldscripts/${EMULATION_NAME}.xw";
494 if test -n "$GENERATE_RELRO_SCRIPT" ; then
496 else if (link_info.combreloc
499 if (link_info.separate_code)
500 return "ldscripts/${EMULATION_NAME}.xceo";
502 return "ldscripts/${EMULATION_NAME}.xco";
507 else if (link_info.combreloc)
509 if (link_info.separate_code)
510 return "ldscripts/${EMULATION_NAME}.xce";
512 return "ldscripts/${EMULATION_NAME}.xc";
516 if test -n "$GENERATE_RELRO_SCRIPT" ; then
518 else if (link_info.relro)
520 if (link_info.separate_code)
521 return "ldscripts/${EMULATION_NAME}.xeo";
523 return "ldscripts/${EMULATION_NAME}.xo";
530 if (link_info.separate_code)
531 return "ldscripts/${EMULATION_NAME}.xe";
533 return "ldscripts/${EMULATION_NAME}.x";
541 if test -n "$PARSE_AND_LIST_PROLOGUE" ; then
543 $PARSE_AND_LIST_PROLOGUE
551 OPTION_DISABLE_NEW_DTAGS = 400,
552 OPTION_ENABLE_NEW_DTAGS,
555 OPTION_NO_EH_FRAME_HDR,
560 OPTION_COMPRESS_DEBUG
564 gld${EMULATION_NAME}_add_options
565 (int ns, char **shortopts, int nl, struct option **longopts,
566 int nrl ATTRIBUTE_UNUSED, struct option **really_longopts ATTRIBUTE_UNUSED)
569 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
571 static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:P:";
575 static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:";
579 static const struct option xtra_long[] = {
581 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
583 {"audit", required_argument, NULL, OPTION_AUDIT},
584 {"Bgroup", no_argument, NULL, OPTION_GROUP},
588 {"build-id", optional_argument, NULL, OPTION_BUILD_ID},
589 {"compress-debug-sections", required_argument, NULL, OPTION_COMPRESS_DEBUG},
591 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
593 {"depaudit", required_argument, NULL, 'P'},
594 {"disable-new-dtags", no_argument, NULL, OPTION_DISABLE_NEW_DTAGS},
595 {"enable-new-dtags", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS},
596 {"eh-frame-hdr", no_argument, NULL, OPTION_EH_FRAME_HDR},
597 {"no-eh-frame-hdr", no_argument, NULL, OPTION_NO_EH_FRAME_HDR},
598 {"exclude-libs", required_argument, NULL, OPTION_EXCLUDE_LIBS},
599 {"hash-style", required_argument, NULL, OPTION_HASH_STYLE},
602 if test -n "$PARSE_AND_LIST_LONGOPTS" ; then
604 $PARSE_AND_LIST_LONGOPTS
608 {NULL, no_argument, NULL, 0}
611 *shortopts = (char *) xrealloc (*shortopts, ns + sizeof (xtra_short));
612 memcpy (*shortopts + ns, &xtra_short, sizeof (xtra_short));
613 *longopts = (struct option *)
614 xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
615 memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
618 #define DEFAULT_BUILD_ID_STYLE "sha1"
621 gld${EMULATION_NAME}_handle_option (int optc)
628 case OPTION_BUILD_ID:
629 free ((char *) ldelf_emit_note_gnu_build_id);
630 ldelf_emit_note_gnu_build_id = NULL;
632 optarg = DEFAULT_BUILD_ID_STYLE;
633 if (strcmp (optarg, "none"))
634 ldelf_emit_note_gnu_build_id = xstrdup (optarg);
637 case OPTION_COMPRESS_DEBUG:
638 if (strcasecmp (optarg, "none") == 0)
639 link_info.compress_debug = COMPRESS_DEBUG_NONE;
640 else if (strcasecmp (optarg, "zlib") == 0)
641 link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB;
642 else if (strcasecmp (optarg, "zlib-gnu") == 0)
643 link_info.compress_debug = COMPRESS_DEBUG_GNU_ZLIB;
644 else if (strcasecmp (optarg, "zlib-gabi") == 0)
645 link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB;
647 einfo (_("%F%P: invalid --compress-debug-sections option: \`%s'\n"),
652 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
655 ldelf_append_to_separated_string (&audit, optarg);
659 ldelf_append_to_separated_string (&depaudit, optarg);
662 case OPTION_DISABLE_NEW_DTAGS:
663 link_info.new_dtags = FALSE;
666 case OPTION_ENABLE_NEW_DTAGS:
667 link_info.new_dtags = TRUE;
670 case OPTION_EH_FRAME_HDR:
671 link_info.eh_frame_hdr_type = DWARF2_EH_HDR;
674 case OPTION_NO_EH_FRAME_HDR:
675 link_info.eh_frame_hdr_type = 0;
679 link_info.flags_1 |= (bfd_vma) DF_1_GROUP;
680 /* Groups must be self-contained. */
681 link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
682 link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
685 case OPTION_EXCLUDE_LIBS:
686 add_excluded_libs (optarg);
689 case OPTION_HASH_STYLE:
690 link_info.emit_hash = FALSE;
691 link_info.emit_gnu_hash = FALSE;
692 if (strcmp (optarg, "sysv") == 0)
693 link_info.emit_hash = TRUE;
694 else if (strcmp (optarg, "gnu") == 0)
695 link_info.emit_gnu_hash = TRUE;
696 else if (strcmp (optarg, "both") == 0)
698 link_info.emit_hash = TRUE;
699 link_info.emit_gnu_hash = TRUE;
702 einfo (_("%F%P: invalid hash style \`%s'\n"), optarg);
709 if (strcmp (optarg, "defs") == 0)
710 link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
711 else if (strcmp (optarg, "undefs") == 0)
712 link_info.unresolved_syms_in_objects = RM_IGNORE;
713 else if (strcmp (optarg, "muldefs") == 0)
714 link_info.allow_multiple_definition = TRUE;
715 else if (CONST_STRNEQ (optarg, "max-page-size="))
719 config.maxpagesize = strtoul (optarg + 14, &end, 0);
720 if (*end || (config.maxpagesize & (config.maxpagesize - 1)) != 0)
721 einfo (_("%F%P: invalid maximum page size \`%s'\n"),
724 else if (CONST_STRNEQ (optarg, "common-page-size="))
727 config.commonpagesize = strtoul (optarg + 17, &end, 0);
729 || (config.commonpagesize & (config.commonpagesize - 1)) != 0)
730 einfo (_("%F%P: invalid common page size \`%s'\n"),
733 else if (CONST_STRNEQ (optarg, "stack-size="))
736 link_info.stacksize = strtoul (optarg + 11, &end, 0);
737 if (*end || link_info.stacksize < 0)
738 einfo (_("%F%P: invalid stack size \`%s'\n"), optarg + 11);
739 if (!link_info.stacksize)
740 /* Use -1 for explicit no-stack, because zero means
742 link_info.stacksize = -1;
744 else if (strcmp (optarg, "execstack") == 0)
746 link_info.execstack = TRUE;
747 link_info.noexecstack = FALSE;
749 else if (strcmp (optarg, "noexecstack") == 0)
751 link_info.noexecstack = TRUE;
752 link_info.execstack = FALSE;
754 else if (strcmp (optarg, "globalaudit") == 0)
756 link_info.flags_1 |= DF_1_GLOBAUDIT;
758 else if (CONST_STRNEQ (optarg, "start-stop-visibility="))
760 if (strcmp (optarg, "start-stop-visibility=default") == 0)
761 link_info.start_stop_visibility = STV_DEFAULT;
762 else if (strcmp (optarg, "start-stop-visibility=internal") == 0)
763 link_info.start_stop_visibility = STV_INTERNAL;
764 else if (strcmp (optarg, "start-stop-visibility=hidden") == 0)
765 link_info.start_stop_visibility = STV_HIDDEN;
766 else if (strcmp (optarg, "start-stop-visibility=protected") == 0)
767 link_info.start_stop_visibility = STV_PROTECTED;
769 einfo (_("%F%P: invalid visibility in \`-z %s'; "
770 "must be default, internal, hidden, or protected"),
775 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
777 else if (strcmp (optarg, "global") == 0)
778 link_info.flags_1 |= (bfd_vma) DF_1_GLOBAL;
779 else if (strcmp (optarg, "initfirst") == 0)
780 link_info.flags_1 |= (bfd_vma) DF_1_INITFIRST;
781 else if (strcmp (optarg, "interpose") == 0)
782 link_info.flags_1 |= (bfd_vma) DF_1_INTERPOSE;
783 else if (strcmp (optarg, "loadfltr") == 0)
784 link_info.flags_1 |= (bfd_vma) DF_1_LOADFLTR;
785 else if (strcmp (optarg, "nodefaultlib") == 0)
786 link_info.flags_1 |= (bfd_vma) DF_1_NODEFLIB;
787 else if (strcmp (optarg, "nodelete") == 0)
788 link_info.flags_1 |= (bfd_vma) DF_1_NODELETE;
789 else if (strcmp (optarg, "nodlopen") == 0)
790 link_info.flags_1 |= (bfd_vma) DF_1_NOOPEN;
791 else if (strcmp (optarg, "nodump") == 0)
792 link_info.flags_1 |= (bfd_vma) DF_1_NODUMP;
793 else if (strcmp (optarg, "now") == 0)
795 link_info.flags |= (bfd_vma) DF_BIND_NOW;
796 link_info.flags_1 |= (bfd_vma) DF_1_NOW;
798 else if (strcmp (optarg, "lazy") == 0)
800 link_info.flags &= ~(bfd_vma) DF_BIND_NOW;
801 link_info.flags_1 &= ~(bfd_vma) DF_1_NOW;
803 else if (strcmp (optarg, "origin") == 0)
805 link_info.flags |= (bfd_vma) DF_ORIGIN;
806 link_info.flags_1 |= (bfd_vma) DF_1_ORIGIN;
808 else if (strcmp (optarg, "combreloc") == 0)
809 link_info.combreloc = TRUE;
810 else if (strcmp (optarg, "nocombreloc") == 0)
811 link_info.combreloc = FALSE;
812 else if (strcmp (optarg, "nocopyreloc") == 0)
813 link_info.nocopyreloc = TRUE;
815 if test -n "$COMMONPAGESIZE"; then
817 else if (strcmp (optarg, "relro") == 0)
818 link_info.relro = TRUE;
819 else if (strcmp (optarg, "norelro") == 0)
820 link_info.relro = FALSE;
824 else if (strcmp (optarg, "separate-code") == 0)
825 link_info.separate_code = TRUE;
826 else if (strcmp (optarg, "noseparate-code") == 0)
827 link_info.separate_code = FALSE;
828 else if (strcmp (optarg, "common") == 0)
829 link_info.elf_stt_common = elf_stt_common;
830 else if (strcmp (optarg, "nocommon") == 0)
831 link_info.elf_stt_common = no_elf_stt_common;
832 else if (strcmp (optarg, "text") == 0)
833 link_info.textrel_check = textrel_check_error;
834 else if (strcmp (optarg, "notext") == 0)
835 link_info.textrel_check = textrel_check_none;
836 else if (strcmp (optarg, "textoff") == 0)
837 link_info.textrel_check = textrel_check_none;
841 if test -n "$PARSE_AND_LIST_ARGS_CASE_Z" ; then
843 $PARSE_AND_LIST_ARGS_CASE_Z
849 einfo (_("%P: warning: -z %s ignored\n"), optarg);
853 if test -n "$PARSE_AND_LIST_ARGS_CASES" ; then
855 $PARSE_AND_LIST_ARGS_CASES
867 if test x"$LDEMUL_LIST_OPTIONS" != xgld"$EMULATION_NAME"_list_options; then
868 gld_list_options="gld${EMULATION_NAME}_list_options"
869 if test -n "$PARSE_AND_LIST_OPTIONS"; then
873 gld${EMULATION_NAME}_list_options (FILE * file)
877 if test -n "$PARSE_AND_LIST_OPTIONS" ; then
879 $PARSE_AND_LIST_OPTIONS
887 gld_list_options="NULL"
890 if test -n "$PARSE_AND_LIST_EPILOGUE" ; then
892 $PARSE_AND_LIST_EPILOGUE
899 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
901 ${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse},
902 ${LDEMUL_SYSLIB-syslib_default},
903 ${LDEMUL_HLL-hll_default},
904 ${LDEMUL_AFTER_PARSE-ldelf_after_parse},
905 ${LDEMUL_AFTER_OPEN-gld${EMULATION_NAME}_after_open},
906 ${LDEMUL_AFTER_CHECK_RELOCS-after_check_relocs_default},
907 ${LDEMUL_BEFORE_PLACE_ORPHANS-ldelf_before_place_orphans},
908 ${LDEMUL_AFTER_ALLOCATION-gld${EMULATION_NAME}_after_allocation},
909 ${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
910 ${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
911 ${LDEMUL_BEFORE_ALLOCATION-gld${EMULATION_NAME}_before_allocation},
912 ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
915 ${LDEMUL_FINISH-finish_default},
916 ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL},
917 ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-ldelf_open_dynamic_archive},
918 ${LDEMUL_PLACE_ORPHAN-ldelf_place_orphan},
919 ${LDEMUL_SET_SYMBOLS-NULL},
920 ${LDEMUL_PARSE_ARGS-NULL},
921 gld${EMULATION_NAME}_add_options,
922 gld${EMULATION_NAME}_handle_option,
923 ${LDEMUL_UNRECOGNIZED_FILE-NULL},
924 ${LDEMUL_LIST_OPTIONS-${gld_list_options}},
925 ${LDEMUL_RECOGNIZED_FILE-ldelf_load_symbols},
926 ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL},
927 ${LDEMUL_NEW_VERS_PATTERN-NULL},
928 ${LDEMUL_EXTRA_MAP_FILE_TEXT-NULL},
929 ${LDEMUL_EMIT_CTF_EARLY-NULL},
930 ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL},
931 ${LDEMUL_PRINT_SYMBOL-NULL}