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-2023 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}_before_plugin_all_symbols_read
58 static void gld${EMULATION_NAME}_after_open (void);
59 static void gld${EMULATION_NAME}_before_allocation (void);
60 static void gld${EMULATION_NAME}_after_allocation (void);
63 # Import any needed special functions and/or overrides.
65 source_em ${srcdir}/emultempl/elf-generic.em
66 if test -n "$EXTRA_EM_FILE" ; then
67 source_em ${srcdir}/emultempl/${EXTRA_EM_FILE}.em
70 # Functions in this file can be overridden by setting the LDEMUL_* shell
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.
76 if test x"$LDEMUL_BEFORE_PARSE" != xgld"$EMULATION_NAME"_before_parse; then
80 gld${EMULATION_NAME}_before_parse (void)
82 ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
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;
88 if test -n "$COMMONPAGESIZE"; then
90 link_info.relro = DEFAULT_LD_Z_RELRO;
94 link_info.separate_code = DEFAULT_LD_Z_SEPARATE_CODE;
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;
98 link_info.error_execstack = DEFAULT_LD_ERROR_EXECSTACK;
99 link_info.warn_is_error_for_rwx_segments = DEFAULT_LD_ERROR_RWX_SEGMENTS;
107 /* These variables are used to implement target options */
109 static char *audit; /* colon (typically) separated list of libs */
110 static char *depaudit; /* colon (typically) separated list of libs */
114 if test x"$LDEMUL_AFTER_OPEN" != xgld"$EMULATION_NAME"_after_open; then
116 IS_LINUX_TARGET=false
117 IS_FREEBSD_TARGET=false
119 *-*-linux-* | *-*-k*bsd*-* | *-*-gnu*)
120 IS_LINUX_TARGET=true ;;
121 *-*-freebsd* | *-*-dragonfly*)
122 IS_FREEBSD_TARGET=true ;;
125 if test "x${USE_LIBPATH}" = xyes; then
129 if test "x${NATIVE}" = xyes; then
135 /* This is called before calling plugin 'all symbols read' hook. */
138 gld${EMULATION_NAME}_before_plugin_all_symbols_read (void)
140 ldelf_before_plugin_all_symbols_read ($IS_LIBPATH, $IS_NATIVE,
143 $ELFSIZE, "$prefix");
146 /* This is called after all the input files have been opened. */
149 gld${EMULATION_NAME}_after_open (void)
151 ldelf_after_open ($IS_LIBPATH, $IS_NATIVE,
152 $IS_LINUX_TARGET, $IS_FREEBSD_TARGET, $ELFSIZE, "$prefix");
158 if test x"$LDEMUL_BEFORE_ALLOCATION" != xgld"$EMULATION_NAME"_before_allocation; then
159 if test x"${ELF_INTERPRETER_NAME}" = x; then
160 ELF_INTERPRETER_NAME=NULL
164 /* This is called after the sections have been attached to output
165 sections, but before any sizes or addresses have been set. */
168 gld${EMULATION_NAME}_before_allocation (void)
170 ldelf_before_allocation (audit, depaudit, ${ELF_INTERPRETER_NAME});
176 if test x"$LDEMUL_AFTER_ALLOCATION" != xgld"$EMULATION_NAME"_after_allocation; then
180 gld${EMULATION_NAME}_after_allocation (void)
182 int need_layout = bfd_elf_discard_info (link_info.output_bfd, &link_info);
185 einfo (_("%X%P: .eh_frame/.stab edit: %E\n"));
187 ldelf_map_segments (need_layout);
192 if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then
196 gld${EMULATION_NAME}_get_script (int *isfile)
199 if test x"$COMPILE_IN" = xyes
201 # Scripts compiled in.
203 # sed commands to quote an ld script as a C string.
204 sc="-f ${srcdir}/emultempl/stringify.sed"
210 if (bfd_link_relocatable (&link_info) && config.build_constructors)
213 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
214 echo ' ; else if (bfd_link_relocatable (&link_info)) return' >> e${EMULATION_NAME}.c
215 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
216 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
217 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
218 if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then : ; else
219 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
220 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
222 if test -n "$GENERATE_PIE_SCRIPT" ; then
223 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
224 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
225 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
226 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
227 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
228 sed $sc ldscripts/${EMULATION_NAME}.xdwe >> e${EMULATION_NAME}.c
229 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
230 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
231 echo ' && link_info.relro' >> e${EMULATION_NAME}.c
232 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
233 sed $sc ldscripts/${EMULATION_NAME}.xdw >> e${EMULATION_NAME}.c
234 if test -n "$GENERATE_RELRO_SCRIPT" ; then
235 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
236 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
237 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
238 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
239 sed $sc ldscripts/${EMULATION_NAME}.xdceo >> e${EMULATION_NAME}.c
241 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
242 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
243 echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c
244 sed $sc ldscripts/${EMULATION_NAME}.xdce >> e${EMULATION_NAME}.c
245 if test -n "$GENERATE_RELRO_SCRIPT" ; then
246 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
247 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
248 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
249 sed $sc ldscripts/${EMULATION_NAME}.xdco >> e${EMULATION_NAME}.c
251 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
252 echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c
253 sed $sc ldscripts/${EMULATION_NAME}.xdc >> e${EMULATION_NAME}.c
254 if test -n "$GENERATE_RELRO_SCRIPT" ; then
255 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
256 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
257 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
258 sed $sc ldscripts/${EMULATION_NAME}.xdeo >> e${EMULATION_NAME}.c
261 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
262 echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c
263 sed $sc ldscripts/${EMULATION_NAME}.xde >> e${EMULATION_NAME}.c
264 if test -n "$GENERATE_RELRO_SCRIPT" ; then
265 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
266 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
267 sed $sc ldscripts/${EMULATION_NAME}.xdo >> e${EMULATION_NAME}.c
269 echo ' ; else if (bfd_link_pie (&link_info)) return' >> e${EMULATION_NAME}.c
270 sed $sc ldscripts/${EMULATION_NAME}.xd >> e${EMULATION_NAME}.c
272 if test -n "$GENERATE_SHLIB_SCRIPT" ; then
273 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
274 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
275 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
276 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
277 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
278 sed $sc ldscripts/${EMULATION_NAME}.xswe >> e${EMULATION_NAME}.c
279 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
280 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
281 echo ' && link_info.relro' >> e${EMULATION_NAME}.c
282 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
283 sed $sc ldscripts/${EMULATION_NAME}.xsw >> e${EMULATION_NAME}.c
284 if test -n "$GENERATE_RELRO_SCRIPT" ; then
285 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
286 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
287 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
288 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
289 sed $sc ldscripts/${EMULATION_NAME}.xsceo >> e${EMULATION_NAME}.c
291 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
292 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
293 echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c
294 sed $sc ldscripts/${EMULATION_NAME}.xsce >> e${EMULATION_NAME}.c
295 if test -n "$GENERATE_RELRO_SCRIPT" ; then
296 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
297 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
298 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
299 sed $sc ldscripts/${EMULATION_NAME}.xsco >> e${EMULATION_NAME}.c
301 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
302 echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c
303 sed $sc ldscripts/${EMULATION_NAME}.xsc >> e${EMULATION_NAME}.c
304 if test -n "$GENERATE_RELRO_SCRIPT" ; then
305 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
306 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
307 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
308 sed $sc ldscripts/${EMULATION_NAME}.xseo >> e${EMULATION_NAME}.c
311 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
312 echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c
313 sed $sc ldscripts/${EMULATION_NAME}.xse >> e${EMULATION_NAME}.c
314 if test -n "$GENERATE_RELRO_SCRIPT" ; then
315 echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c
316 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
317 sed $sc ldscripts/${EMULATION_NAME}.xso >> e${EMULATION_NAME}.c
319 echo ' ; else if (bfd_link_dll (&link_info)) return' >> e${EMULATION_NAME}.c
320 sed $sc ldscripts/${EMULATION_NAME}.xs >> e${EMULATION_NAME}.c
322 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
323 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
324 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
325 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
326 sed $sc ldscripts/${EMULATION_NAME}.xwe >> e${EMULATION_NAME}.c
327 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
328 echo ' && link_info.relro' >> e${EMULATION_NAME}.c
329 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
330 sed $sc ldscripts/${EMULATION_NAME}.xw >> e${EMULATION_NAME}.c
331 if test -n "$GENERATE_RELRO_SCRIPT" ; then
332 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
333 echo ' && link_info.separate_code' >> e${EMULATION_NAME}.c
334 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
335 sed $sc ldscripts/${EMULATION_NAME}.xceo >> e${EMULATION_NAME}.c
337 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
338 echo ' && link_info.separate_code) return' >> e${EMULATION_NAME}.c
339 sed $sc ldscripts/${EMULATION_NAME}.xce >> e${EMULATION_NAME}.c
340 if test -n "$GENERATE_RELRO_SCRIPT" ; then
341 echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c
342 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
343 sed $sc ldscripts/${EMULATION_NAME}.xco >> e${EMULATION_NAME}.c
345 echo ' ; else if (link_info.combreloc) return' >> e${EMULATION_NAME}.c
346 sed $sc ldscripts/${EMULATION_NAME}.xc >> e${EMULATION_NAME}.c
348 if test -n "$GENERATE_RELRO_SCRIPT" ; then
349 echo ' ; else if (link_info.separate_code' >> e${EMULATION_NAME}.c
350 echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c
351 sed $sc ldscripts/${EMULATION_NAME}.xeo >> e${EMULATION_NAME}.c
353 echo ' ; else if (link_info.separate_code) return' >> e${EMULATION_NAME}.c
354 sed $sc ldscripts/${EMULATION_NAME}.xe >> e${EMULATION_NAME}.c
355 if test -n "$GENERATE_RELRO_SCRIPT" ; then
356 echo ' ; else if (link_info.relro) return' >> e${EMULATION_NAME}.c
357 sed $sc ldscripts/${EMULATION_NAME}.xo >> e${EMULATION_NAME}.c
359 echo ' ; else return' >> e${EMULATION_NAME}.c
360 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
361 echo '; }' >> e${EMULATION_NAME}.c
364 # Scripts read from the filesystem.
370 if (bfd_link_relocatable (&link_info) && config.build_constructors)
371 return "ldscripts/${EMULATION_NAME}.xu";
372 else if (bfd_link_relocatable (&link_info))
373 return "ldscripts/${EMULATION_NAME}.xr";
374 else if (!config.text_read_only)
375 return "ldscripts/${EMULATION_NAME}.xbn";
377 if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then :
380 else if (!config.magic_demand_paged)
381 return "ldscripts/${EMULATION_NAME}.xn";
384 if test -n "$GENERATE_PIE_SCRIPT" ; then
385 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
387 else if (bfd_link_pie (&link_info)
388 && link_info.combreloc
390 && (link_info.flags & DF_BIND_NOW))
392 if (link_info.separate_code)
393 return "ldscripts/${EMULATION_NAME}.xdwe";
395 return "ldscripts/${EMULATION_NAME}.xdw";
398 if test -n "$GENERATE_RELRO_SCRIPT" ; then
400 else if (bfd_link_pie (&link_info)
401 && link_info.combreloc
404 if (link_info.separate_code)
405 return "ldscripts/${EMULATION_NAME}.xdceo";
407 return "ldscripts/${EMULATION_NAME}.xdco";
412 else if (bfd_link_pie (&link_info)
413 && link_info.combreloc)
415 if (link_info.separate_code)
416 return "ldscripts/${EMULATION_NAME}.xdce";
418 return "ldscripts/${EMULATION_NAME}.xdc";
422 if test -n "$GENERATE_RELRO_SCRIPT" ; then
424 else if (bfd_link_pie (&link_info)
427 if (link_info.separate_code)
428 return "ldscripts/${EMULATION_NAME}.xdeo";
430 return "ldscripts/${EMULATION_NAME}.xdo";
435 else if (bfd_link_pie (&link_info))
437 if (link_info.separate_code)
438 return "ldscripts/${EMULATION_NAME}.xde";
440 return "ldscripts/${EMULATION_NAME}.xd";
444 if test -n "$GENERATE_SHLIB_SCRIPT" ; then
445 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
447 else if (bfd_link_dll (&link_info) && link_info.combreloc
448 && link_info.relro && (link_info.flags & DF_BIND_NOW))
450 if (link_info.separate_code)
451 return "ldscripts/${EMULATION_NAME}.xswe";
453 return "ldscripts/${EMULATION_NAME}.xsw";
456 if test -n "$GENERATE_RELRO_SCRIPT" ; then
458 else if (bfd_link_dll (&link_info)
459 && link_info.combreloc
462 if (link_info.separate_code)
463 return "ldscripts/${EMULATION_NAME}.xsceo";
465 return "ldscripts/${EMULATION_NAME}.xsco";
470 else if (bfd_link_dll (&link_info) && link_info.combreloc)
472 if (link_info.separate_code)
473 return "ldscripts/${EMULATION_NAME}.xsce";
475 return "ldscripts/${EMULATION_NAME}.xsc";
479 if test -n "$GENERATE_RELRO_SCRIPT" ; then
481 else if (bfd_link_dll (&link_info)
484 if (link_info.separate_code)
485 return "ldscripts/${EMULATION_NAME}.xseo";
487 return "ldscripts/${EMULATION_NAME}.xso";
492 else if (bfd_link_dll (&link_info))
494 if (link_info.separate_code)
495 return "ldscripts/${EMULATION_NAME}.xse";
497 return "ldscripts/${EMULATION_NAME}.xs";
501 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
503 else if (link_info.combreloc && link_info.relro
504 && (link_info.flags & DF_BIND_NOW))
506 if (link_info.separate_code)
507 return "ldscripts/${EMULATION_NAME}.xwe";
509 return "ldscripts/${EMULATION_NAME}.xw";
512 if test -n "$GENERATE_RELRO_SCRIPT" ; then
514 else if (link_info.combreloc
517 if (link_info.separate_code)
518 return "ldscripts/${EMULATION_NAME}.xceo";
520 return "ldscripts/${EMULATION_NAME}.xco";
525 else if (link_info.combreloc)
527 if (link_info.separate_code)
528 return "ldscripts/${EMULATION_NAME}.xce";
530 return "ldscripts/${EMULATION_NAME}.xc";
534 if test -n "$GENERATE_RELRO_SCRIPT" ; then
536 else if (link_info.relro)
538 if (link_info.separate_code)
539 return "ldscripts/${EMULATION_NAME}.xeo";
541 return "ldscripts/${EMULATION_NAME}.xo";
548 if (link_info.separate_code)
549 return "ldscripts/${EMULATION_NAME}.xe";
551 return "ldscripts/${EMULATION_NAME}.x";
559 if test -n "$PARSE_AND_LIST_PROLOGUE" ; then
561 $PARSE_AND_LIST_PROLOGUE
569 OPTION_DISABLE_NEW_DTAGS = 400,
570 OPTION_ENABLE_NEW_DTAGS,
573 OPTION_NO_EH_FRAME_HDR,
577 OPTION_PACKAGE_METADATA,
579 OPTION_COMPRESS_DEBUG
583 gld${EMULATION_NAME}_add_options
584 (int ns, char **shortopts, int nl, struct option **longopts,
585 int nrl ATTRIBUTE_UNUSED, struct option **really_longopts ATTRIBUTE_UNUSED)
588 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
590 static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:P:";
594 static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:";
598 static const struct option xtra_long[] = {
600 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
602 {"audit", required_argument, NULL, OPTION_AUDIT},
603 {"Bgroup", no_argument, NULL, OPTION_GROUP},
607 {"build-id", optional_argument, NULL, OPTION_BUILD_ID},
608 {"package-metadata", optional_argument, NULL, OPTION_PACKAGE_METADATA},
609 {"compress-debug-sections", required_argument, NULL, OPTION_COMPRESS_DEBUG},
611 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
613 {"depaudit", required_argument, NULL, 'P'},
614 {"disable-new-dtags", no_argument, NULL, OPTION_DISABLE_NEW_DTAGS},
615 {"enable-new-dtags", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS},
616 {"eh-frame-hdr", no_argument, NULL, OPTION_EH_FRAME_HDR},
617 {"no-eh-frame-hdr", no_argument, NULL, OPTION_NO_EH_FRAME_HDR},
618 {"exclude-libs", required_argument, NULL, OPTION_EXCLUDE_LIBS},
619 {"hash-style", required_argument, NULL, OPTION_HASH_STYLE},
622 if test -n "$PARSE_AND_LIST_LONGOPTS" ; then
624 $PARSE_AND_LIST_LONGOPTS
628 {NULL, no_argument, NULL, 0}
631 *shortopts = (char *) xrealloc (*shortopts, ns + sizeof (xtra_short));
632 memcpy (*shortopts + ns, &xtra_short, sizeof (xtra_short));
633 *longopts = (struct option *)
634 xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
635 memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
638 #define DEFAULT_BUILD_ID_STYLE "sha1"
641 gld${EMULATION_NAME}_handle_option (int optc)
648 case OPTION_BUILD_ID:
649 free ((char *) ldelf_emit_note_gnu_build_id);
650 ldelf_emit_note_gnu_build_id = NULL;
652 optarg = DEFAULT_BUILD_ID_STYLE;
653 if (strcmp (optarg, "none"))
654 ldelf_emit_note_gnu_build_id = xstrdup (optarg);
657 case OPTION_PACKAGE_METADATA:
658 free ((char *) ldelf_emit_note_fdo_package_metadata);
659 ldelf_emit_note_fdo_package_metadata = NULL;
660 if (optarg != NULL && strlen(optarg) > 0)
661 ldelf_emit_note_fdo_package_metadata = xstrdup (optarg);
664 case OPTION_COMPRESS_DEBUG:
665 config.compress_debug = bfd_get_compression_algorithm (optarg);
666 if (strcasecmp (optarg, "zstd") == 0)
669 if (config.compress_debug == COMPRESS_DEBUG_ZSTD)
670 einfo (_ ("%F%P: --compress-debug-sections=zstd: ld is not built "
671 "with zstd support\n"));
674 if (config.compress_debug == COMPRESS_UNKNOWN)
675 einfo (_("%F%P: invalid --compress-debug-sections option: \`%s'\n"),
680 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
683 ldelf_append_to_separated_string (&audit, optarg);
687 ldelf_append_to_separated_string (&depaudit, optarg);
690 case OPTION_DISABLE_NEW_DTAGS:
691 link_info.new_dtags = false;
694 case OPTION_ENABLE_NEW_DTAGS:
695 link_info.new_dtags = true;
698 case OPTION_EH_FRAME_HDR:
699 link_info.eh_frame_hdr_type = DWARF2_EH_HDR;
702 case OPTION_NO_EH_FRAME_HDR:
703 link_info.eh_frame_hdr_type = 0;
707 link_info.flags_1 |= (bfd_vma) DF_1_GROUP;
708 /* Groups must be self-contained. */
709 link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
710 link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
713 case OPTION_EXCLUDE_LIBS:
714 add_excluded_libs (optarg);
717 case OPTION_HASH_STYLE:
718 link_info.emit_hash = false;
719 link_info.emit_gnu_hash = false;
720 if (strcmp (optarg, "sysv") == 0)
721 link_info.emit_hash = true;
722 else if (strcmp (optarg, "gnu") == 0)
723 link_info.emit_gnu_hash = true;
724 else if (strcmp (optarg, "both") == 0)
726 link_info.emit_hash = true;
727 link_info.emit_gnu_hash = true;
730 einfo (_("%F%P: invalid hash style \`%s'\n"), optarg);
737 if (strcmp (optarg, "defs") == 0)
738 link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
739 else if (strcmp (optarg, "undefs") == 0)
740 link_info.unresolved_syms_in_objects = RM_IGNORE;
741 else if (strcmp (optarg, "muldefs") == 0)
742 link_info.allow_multiple_definition = true;
743 else if (startswith (optarg, "max-page-size="))
747 link_info.maxpagesize = strtoul (optarg + 14, &end, 0);
749 || (link_info.maxpagesize & (link_info.maxpagesize - 1)) != 0)
750 einfo (_("%F%P: invalid maximum page size \`%s'\n"),
752 link_info.maxpagesize_is_set = true;
754 else if (startswith (optarg, "common-page-size="))
757 link_info.commonpagesize = strtoul (optarg + 17, &end, 0);
759 || (link_info.commonpagesize & (link_info.commonpagesize - 1)) != 0)
760 einfo (_("%F%P: invalid common page size \`%s'\n"),
762 link_info.commonpagesize_is_set = true;
764 else if (startswith (optarg, "stack-size="))
767 link_info.stacksize = strtoul (optarg + 11, &end, 0);
768 if (*end || link_info.stacksize < 0)
769 einfo (_("%F%P: invalid stack size \`%s'\n"), optarg + 11);
770 if (!link_info.stacksize)
771 /* Use -1 for explicit no-stack, because zero means
773 link_info.stacksize = -1;
775 else if (strcmp (optarg, "execstack") == 0)
777 link_info.execstack = true;
778 link_info.noexecstack = false;
780 else if (strcmp (optarg, "noexecstack") == 0)
782 link_info.noexecstack = true;
783 link_info.execstack = false;
785 else if (strcmp (optarg, "unique-symbol") == 0)
786 link_info.unique_symbol = true;
787 else if (strcmp (optarg, "nounique-symbol") == 0)
788 link_info.unique_symbol = false;
789 else if (strcmp (optarg, "globalaudit") == 0)
791 link_info.flags_1 |= DF_1_GLOBAUDIT;
793 else if (startswith (optarg, "start-stop-gc"))
794 link_info.start_stop_gc = true;
795 else if (startswith (optarg, "nostart-stop-gc"))
796 link_info.start_stop_gc = false;
797 else if (startswith (optarg, "start-stop-visibility="))
799 if (strcmp (optarg, "start-stop-visibility=default") == 0)
800 link_info.start_stop_visibility = STV_DEFAULT;
801 else if (strcmp (optarg, "start-stop-visibility=internal") == 0)
802 link_info.start_stop_visibility = STV_INTERNAL;
803 else if (strcmp (optarg, "start-stop-visibility=hidden") == 0)
804 link_info.start_stop_visibility = STV_HIDDEN;
805 else if (strcmp (optarg, "start-stop-visibility=protected") == 0)
806 link_info.start_stop_visibility = STV_PROTECTED;
808 einfo (_("%F%P: invalid visibility in \`-z %s'; "
809 "must be default, internal, hidden, or protected"),
812 else if (strcmp (optarg, "sectionheader") == 0)
813 config.no_section_header = false;
814 else if (strcmp (optarg, "nosectionheader") == 0)
815 config.no_section_header = true;
818 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
820 else if (strcmp (optarg, "global") == 0)
821 link_info.flags_1 |= (bfd_vma) DF_1_GLOBAL;
822 else if (strcmp (optarg, "initfirst") == 0)
823 link_info.flags_1 |= (bfd_vma) DF_1_INITFIRST;
824 else if (strcmp (optarg, "interpose") == 0)
825 link_info.flags_1 |= (bfd_vma) DF_1_INTERPOSE;
826 else if (strcmp (optarg, "loadfltr") == 0)
827 link_info.flags_1 |= (bfd_vma) DF_1_LOADFLTR;
828 else if (strcmp (optarg, "nodefaultlib") == 0)
829 link_info.flags_1 |= (bfd_vma) DF_1_NODEFLIB;
830 else if (strcmp (optarg, "nodelete") == 0)
831 link_info.flags_1 |= (bfd_vma) DF_1_NODELETE;
832 else if (strcmp (optarg, "nodlopen") == 0)
833 link_info.flags_1 |= (bfd_vma) DF_1_NOOPEN;
834 else if (strcmp (optarg, "nodump") == 0)
835 link_info.flags_1 |= (bfd_vma) DF_1_NODUMP;
836 else if (strcmp (optarg, "now") == 0)
838 link_info.flags |= (bfd_vma) DF_BIND_NOW;
839 link_info.flags_1 |= (bfd_vma) DF_1_NOW;
841 else if (strcmp (optarg, "lazy") == 0)
843 link_info.flags &= ~(bfd_vma) DF_BIND_NOW;
844 link_info.flags_1 &= ~(bfd_vma) DF_1_NOW;
846 else if (strcmp (optarg, "origin") == 0)
848 link_info.flags |= (bfd_vma) DF_ORIGIN;
849 link_info.flags_1 |= (bfd_vma) DF_1_ORIGIN;
851 else if (strcmp (optarg, "unique") == 0)
852 link_info.gnu_flags_1 |= (bfd_vma) DF_GNU_1_UNIQUE;
853 else if (strcmp (optarg, "nounique") == 0)
854 link_info.gnu_flags_1 &= ~(bfd_vma) DF_GNU_1_UNIQUE;
855 else if (strcmp (optarg, "combreloc") == 0)
856 link_info.combreloc = true;
857 else if (strcmp (optarg, "nocombreloc") == 0)
858 link_info.combreloc = false;
859 else if (strcmp (optarg, "nocopyreloc") == 0)
860 link_info.nocopyreloc = true;
862 if test -n "$COMMONPAGESIZE"; then
864 else if (strcmp (optarg, "relro") == 0)
865 link_info.relro = true;
866 else if (strcmp (optarg, "norelro") == 0)
867 link_info.relro = false;
871 else if (strcmp (optarg, "separate-code") == 0)
872 link_info.separate_code = true;
873 else if (strcmp (optarg, "noseparate-code") == 0)
874 link_info.separate_code = false;
875 else if (strcmp (optarg, "common") == 0)
876 link_info.elf_stt_common = elf_stt_common;
877 else if (strcmp (optarg, "nocommon") == 0)
878 link_info.elf_stt_common = no_elf_stt_common;
879 else if (strcmp (optarg, "text") == 0)
880 link_info.textrel_check = textrel_check_error;
881 else if (strcmp (optarg, "notext") == 0)
882 link_info.textrel_check = textrel_check_none;
883 else if (strcmp (optarg, "textoff") == 0)
884 link_info.textrel_check = textrel_check_none;
888 if test -n "$PARSE_AND_LIST_ARGS_CASE_Z" ; then
890 $PARSE_AND_LIST_ARGS_CASE_Z
896 einfo (_("%P: warning: -z %s ignored\n"), optarg);
900 if test -n "$PARSE_AND_LIST_ARGS_CASES" ; then
902 $PARSE_AND_LIST_ARGS_CASES
914 if test x"$LDEMUL_LIST_OPTIONS" != xgld"$EMULATION_NAME"_list_options; then
915 gld_list_options="gld${EMULATION_NAME}_list_options"
916 if test -n "$PARSE_AND_LIST_OPTIONS"; then
920 gld${EMULATION_NAME}_list_options (FILE * file)
924 if test -n "$PARSE_AND_LIST_OPTIONS" ; then
926 $PARSE_AND_LIST_OPTIONS
934 gld_list_options="NULL"
937 if test -n "$PARSE_AND_LIST_EPILOGUE" ; then
939 $PARSE_AND_LIST_EPILOGUE
944 LDEMUL_AFTER_PARSE=${LDEMUL_AFTER_PARSE-ldelf_after_parse}
945 LDEMUL_BEFORE_PLUGIN_ALL_SYMBOLS_READ=${LDEMUL_BEFORE_PLUGIN_ALL_SYMBOLS_READ-gld${EMULATION_NAME}_before_plugin_all_symbols_read}
946 LDEMUL_AFTER_OPEN=${LDEMUL_AFTER_OPEN-gld${EMULATION_NAME}_after_open}
947 LDEMUL_BEFORE_PLACE_ORPHANS=${LDEMUL_BEFORE_PLACE_ORPHANS-ldelf_before_place_orphans}
948 LDEMUL_AFTER_ALLOCATION=${LDEMUL_AFTER_ALLOCATION-gld${EMULATION_NAME}_after_allocation}
949 LDEMUL_SET_OUTPUT_ARCH=${LDEMUL_SET_OUTPUT_ARCH-ldelf_set_output_arch}
950 LDEMUL_BEFORE_ALLOCATION=${LDEMUL_BEFORE_ALLOCATION-gld${EMULATION_NAME}_before_allocation}
951 LDEMUL_OPEN_DYNAMIC_ARCHIVE=${LDEMUL_OPEN_DYNAMIC_ARCHIVE-ldelf_open_dynamic_archive}
952 LDEMUL_PLACE_ORPHAN=${LDEMUL_PLACE_ORPHAN-ldelf_place_orphan}
953 LDEMUL_ADD_OPTIONS=gld${EMULATION_NAME}_add_options
954 LDEMUL_HANDLE_OPTION=gld${EMULATION_NAME}_handle_option
955 LDEMUL_LIST_OPTIONS=${LDEMUL_LIST_OPTIONS-${gld_list_options}}
956 LDEMUL_RECOGNIZED_FILE=${LDEMUL_RECOGNIZED_FILE-ldelf_load_symbols}
958 source_em ${srcdir}/emultempl/emulation.em