1 # This shell script emits a C file. -*- C -*-
2 # It does some substitutions.
3 # This file is now misnamed, because it supports both 32 bit and 64 bit
5 test -z "${ELFSIZE}" && ELFSIZE=32
6 if [ -z "$MACHINE" ]; then
9 OUTPUT_ARCH=${ARCH}:${MACHINE}
12 /* This file is is generated by a shell script. DO NOT EDIT! */
14 /* ${ELFSIZE} bit ELF emulation code for ${EMULATION_NAME}
15 Copyright (C) 1991-2015 Free Software Foundation, Inc.
16 Written by Steve Chamberlain <sac@cygnus.com>
17 ELF support by Ian Lance Taylor <ian@cygnus.com>
19 This file is part of the GNU Binutils.
21 This program is free software; you can redistribute it and/or modify
22 it under the terms of the GNU General Public License as published by
23 the Free Software Foundation; either version 3 of the License, or
24 (at your option) any later version.
26 This program is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 GNU General Public License for more details.
31 You should have received a copy of the GNU General Public License
32 along with this program; if not, write to the Free Software
33 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
34 MA 02110-1301, USA. */
36 #define TARGET_IS_${EMULATION_NAME}
40 #include "libiberty.h"
41 #include "safe-ctype.h"
42 #include "filenames.h"
55 #include "ldbuildid.h"
57 #include "elf/common.h"
59 #include "filenames.h"
61 /* Declare functions used by various EXTRA_EM_FILEs. */
62 static void gld${EMULATION_NAME}_before_parse (void);
63 static void gld${EMULATION_NAME}_after_parse (void);
64 static void gld${EMULATION_NAME}_after_open (void);
65 static void gld${EMULATION_NAME}_before_allocation (void);
66 static void gld${EMULATION_NAME}_after_allocation (void);
67 static lang_output_section_statement_type *gld${EMULATION_NAME}_place_orphan
68 (asection *, const char *, int);
71 if [ "x${USE_LIBPATH}" = xyes ] ; then
73 *-*-linux-* | *-*-k*bsd*-* | *-*-gnu*)
83 # Import any needed special functions and/or overrides.
85 source_em ${srcdir}/emultempl/elf-generic.em
86 if test -n "$EXTRA_EM_FILE" ; then
87 source_em ${srcdir}/emultempl/${EXTRA_EM_FILE}.em
90 # Functions in this file can be overridden by setting the LDEMUL_* shell
91 # variables. If the name of the overriding function is the same as is
92 # defined in this file, then don't output this file's version.
93 # If a different overriding name is given then output the standard function
94 # as presumably it is called from the overriding function.
96 if test x"$LDEMUL_BEFORE_PARSE" != xgld"$EMULATION_NAME"_before_parse; then
100 gld${EMULATION_NAME}_before_parse (void)
102 ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
103 input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
104 config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
105 config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
106 `if test -n "$CALL_NOP_BYTE" ; then echo link_info.call_nop_byte = $CALL_NOP_BYTE; fi`;
112 if test x"$LDEMUL_AFTER_PARSE" != xgld"$EMULATION_NAME"_after_parse; then
116 gld${EMULATION_NAME}_after_parse (void)
118 if (bfd_link_pie (&link_info))
119 link_info.flags_1 |= (bfd_vma) DF_1_PIE;
121 after_parse_default ();
127 if test x"$LDEMUL_RECOGNIZED_FILE" != xgld"${EMULATION_NAME}"_load_symbols; then
129 /* Handle the generation of DT_NEEDED tags. */
132 gld${EMULATION_NAME}_load_symbols (lang_input_statement_type *entry)
136 /* Tell the ELF linker that we don't want the output file to have a
137 DT_NEEDED entry for this file, unless it is used to resolve
138 references in a regular object. */
139 if (entry->flags.add_DT_NEEDED_for_regular)
140 link_class = DYN_AS_NEEDED;
142 /* Tell the ELF linker that we don't want the output file to have a
143 DT_NEEDED entry for any dynamic library in DT_NEEDED tags from
145 if (!entry->flags.add_DT_NEEDED_for_dynamic)
146 link_class |= DYN_NO_ADD_NEEDED;
148 if (entry->flags.just_syms
149 && (bfd_get_file_flags (entry->the_bfd) & DYNAMIC) != 0)
150 einfo (_("%P%F: --just-symbols may not be used on DSO: %B\n"),
154 || (bfd_get_file_flags (entry->the_bfd) & DYNAMIC) == 0)
157 bfd_elf_set_dyn_lib_class (entry->the_bfd,
158 (enum dynamic_lib_link_class) link_class);
160 /* Continue on with normal load_symbols processing. */
168 /* These variables are required to pass information back and forth
169 between after_open and check_needed and stat_needed and vercheck. */
171 static struct bfd_link_needed_list *global_needed;
172 static struct stat global_stat;
173 static lang_input_statement_type *global_found;
174 static struct bfd_link_needed_list *global_vercheck_needed;
175 static bfd_boolean global_vercheck_failed;
177 /* These variables are used to implement target options */
179 static char *audit; /* colon (typically) separated list of libs */
180 static char *depaudit; /* colon (typically) separated list of libs */
182 /* Style of .note.gnu.build-id section. */
183 static const char *emit_note_gnu_build_id;
185 /* On Linux, it's possible to have different versions of the same
186 shared library linked against different versions of libc. The
187 dynamic linker somehow tags which libc version to use in
188 /etc/ld.so.cache, and, based on the libc that it sees in the
189 executable, chooses which version of the shared library to use.
191 We try to do a similar check here by checking whether this shared
192 library needs any other shared libraries which may conflict with
193 libraries we have already included in the link. If it does, we
194 skip it, and try to find another shared library farther on down the
197 This is called via lang_for_each_input_file.
198 GLOBAL_VERCHECK_NEEDED is the list of objects needed by the object
199 which we are checking. This sets GLOBAL_VERCHECK_FAILED if we find
200 a conflicting version. */
203 gld${EMULATION_NAME}_vercheck (lang_input_statement_type *s)
206 struct bfd_link_needed_list *l;
208 if (global_vercheck_failed)
210 if (s->the_bfd == NULL
211 || (bfd_get_file_flags (s->the_bfd) & DYNAMIC) == 0)
214 soname = bfd_elf_get_dt_soname (s->the_bfd);
216 soname = lbasename (bfd_get_filename (s->the_bfd));
218 for (l = global_vercheck_needed; l != NULL; l = l->next)
222 if (filename_cmp (soname, l->name) == 0)
224 /* Probably can't happen, but it's an easy check. */
228 if (strchr (l->name, '/') != NULL)
231 suffix = strstr (l->name, ".so.");
235 suffix += sizeof ".so." - 1;
237 if (filename_ncmp (soname, l->name, suffix - l->name) == 0)
239 /* Here we know that S is a dynamic object FOO.SO.VER1, and
240 the object we are considering needs a dynamic object
241 FOO.SO.VER2, and VER1 and VER2 are different. This
242 appears to be a version mismatch, so we tell the caller
243 to try a different version of this library. */
244 global_vercheck_failed = TRUE;
251 /* See if an input file matches a DT_NEEDED entry by running stat on
255 gld${EMULATION_NAME}_stat_needed (lang_input_statement_type *s)
261 if (global_found != NULL)
263 if (s->the_bfd == NULL)
266 /* If this input file was an as-needed entry, and wasn't found to be
267 needed at the stage it was linked, then don't say we have loaded it. */
268 if ((bfd_elf_get_dyn_lib_class (s->the_bfd) & DYN_AS_NEEDED) != 0)
271 if (bfd_stat (s->the_bfd, &st) != 0)
273 einfo ("%P:%B: bfd_stat failed: %E\n", s->the_bfd);
277 /* Some operating systems, e.g. Windows, do not provide a meaningful
278 st_ino; they always set it to zero. (Windows does provide a
279 meaningful st_dev.) Do not indicate a duplicate library in that
280 case. While there is no guarantee that a system that provides
281 meaningful inode numbers will never set st_ino to zero, this is
282 merely an optimization, so we do not need to worry about false
284 if (st.st_dev == global_stat.st_dev
285 && st.st_ino == global_stat.st_ino
292 /* We issue a warning if it looks like we are including two
293 different versions of the same shared library. For example,
294 there may be a problem if -lc picks up libc.so.6 but some other
295 shared library has a DT_NEEDED entry of libc.so.5. This is a
296 heuristic test, and it will only work if the name looks like
297 NAME.so.VERSION. FIXME: Depending on file names is error-prone.
298 If we really want to issue warnings about mixing version numbers
299 of shared libraries, we need to find a better way. */
301 if (strchr (global_needed->name, '/') != NULL)
303 suffix = strstr (global_needed->name, ".so.");
306 suffix += sizeof ".so." - 1;
308 soname = bfd_elf_get_dt_soname (s->the_bfd);
310 soname = lbasename (s->filename);
312 if (filename_ncmp (soname, global_needed->name, suffix - global_needed->name) == 0)
313 einfo ("%P: warning: %s, needed by %B, may conflict with %s\n",
314 global_needed->name, global_needed->by, soname);
323 /* This function is called for each possible name for a dynamic object
324 named by a DT_NEEDED entry. The FORCE parameter indicates whether
325 to skip the check for a conflicting version. */
328 gld${EMULATION_NAME}_try_needed (struct dt_needed *needed,
332 const char *name = needed->name;
336 abfd = bfd_openr (name, bfd_get_target (link_info.output_bfd));
340 /* Linker needs to decompress sections. */
341 abfd->flags |= BFD_DECOMPRESS;
343 if (! bfd_check_format (abfd, bfd_object))
348 if ((bfd_get_file_flags (abfd) & DYNAMIC) == 0)
354 /* For DT_NEEDED, they have to match. */
355 if (abfd->xvec != link_info.output_bfd->xvec)
361 /* Check whether this object would include any conflicting library
362 versions. If FORCE is set, then we skip this check; we use this
363 the second time around, if we couldn't find any compatible
364 instance of the shared library. */
368 struct bfd_link_needed_list *needs;
370 if (! bfd_elf_get_bfd_needed_list (abfd, &needs))
371 einfo ("%F%P:%B: bfd_elf_get_bfd_needed_list failed: %E\n", abfd);
375 global_vercheck_needed = needs;
376 global_vercheck_failed = FALSE;
377 lang_for_each_input_file (gld${EMULATION_NAME}_vercheck);
378 if (global_vercheck_failed)
381 /* Return FALSE to force the caller to move on to try
382 another file on the search path. */
386 /* But wait! It gets much worse. On Linux, if a shared
387 library does not use libc at all, we are supposed to skip
388 it the first time around in case we encounter a shared
389 library later on with the same name which does use the
390 version of libc that we want. This is much too horrible
391 to use on any system other than Linux. */
395 *-*-linux-* | *-*-k*bsd*-* | *-*-gnu*)
398 struct bfd_link_needed_list *l;
400 for (l = needs; l != NULL; l = l->next)
401 if (CONST_STRNEQ (l->name, "libc.so"))
417 /* We've found a dynamic object matching the DT_NEEDED entry. */
419 /* We have already checked that there is no other input file of the
420 same name. We must now check again that we are not including the
421 same file twice. We need to do this because on many systems
422 libc.so is a symlink to, e.g., libc.so.1. The SONAME entry will
423 reference libc.so.1. If we have already included libc.so, we
424 don't want to include libc.so.1 if they are the same file, and we
425 can only check that using stat. */
427 if (bfd_stat (abfd, &global_stat) != 0)
428 einfo ("%F%P:%B: bfd_stat failed: %E\n", abfd);
430 /* First strip off everything before the last '/'. */
431 soname = lbasename (abfd->filename);
434 info_msg (_("found %s at %s\n"), soname, name);
437 lang_for_each_input_file (gld${EMULATION_NAME}_stat_needed);
438 if (global_found != NULL)
440 /* Return TRUE to indicate that we found the file, even though
441 we aren't going to do anything with it. */
445 /* Specify the soname to use. */
446 bfd_elf_set_dt_needed_name (abfd, soname);
448 /* Tell the ELF linker that we don't want the output file to have a
449 DT_NEEDED entry for this file, unless it is used to resolve
450 references in a regular object. */
451 link_class = DYN_DT_NEEDED;
453 /* Tell the ELF linker that we don't want the output file to have a
454 DT_NEEDED entry for this file at all if the entry is from a file
455 with DYN_NO_ADD_NEEDED. */
456 if (needed->by != NULL
457 && (bfd_elf_get_dyn_lib_class (needed->by) & DYN_NO_ADD_NEEDED) != 0)
458 link_class |= DYN_NO_NEEDED | DYN_NO_ADD_NEEDED;
460 bfd_elf_set_dyn_lib_class (abfd, (enum dynamic_lib_link_class) link_class);
462 /* Add this file into the symbol table. */
463 if (! bfd_link_add_symbols (abfd, &link_info))
464 einfo ("%F%B: error adding symbols: %E\n", abfd);
470 /* Search for a needed file in a path. */
473 gld${EMULATION_NAME}_search_needed (const char *path,
474 struct dt_needed *n, int force)
477 const char *name = n->name;
479 struct dt_needed needed;
482 return gld${EMULATION_NAME}_try_needed (n, force);
484 if (path == NULL || *path == '\0')
488 needed.name = n->name;
493 char *filename, *sset;
495 s = strchr (path, config.rpath_separator);
497 s = path + strlen (path);
499 #if HAVE_DOS_BASED_FILE_SYSTEM
500 /* Assume a match on the second char is part of drive specifier. */
501 else if (config.rpath_separator == ':'
505 s = strchr (s + 1, config.rpath_separator);
507 s = path + strlen (path);
510 filename = (char *) xmalloc (s - path + len + 2);
515 memcpy (filename, path, s - path);
516 filename[s - path] = '/';
517 sset = filename + (s - path) + 1;
521 needed.name = filename;
522 if (gld${EMULATION_NAME}_try_needed (&needed, force))
536 if [ "x${USE_LIBPATH}" = xyes ] ; then
539 /* Add the sysroot to every entry in a path separated by
540 config.rpath_separator. */
543 gld${EMULATION_NAME}_add_sysroot (const char *path)
552 if (path[i++] == config.rpath_separator)
558 len = len + (colons + 1) * strlen (ld_sysroot);
559 ret = xmalloc (len + 1);
560 strcpy (ret, ld_sysroot);
561 p = ret + strlen (ret);
564 if (path[i] == config.rpath_separator)
567 strcpy (p, ld_sysroot);
579 *-*-freebsd* | *-*-dragonfly*)
581 /* Read the system search path the FreeBSD way rather than the Linux way. */
582 #ifdef HAVE_ELF_HINTS_H
583 #include <elf-hints.h>
585 #include "elf-hints-local.h"
589 gld${EMULATION_NAME}_check_ld_elf_hints (const struct bfd_link_needed_list *l,
592 static bfd_boolean initialized;
593 static char *ld_elf_hints;
594 struct dt_needed needed;
601 tmppath = concat (ld_sysroot, _PATH_ELF_HINTS, (const char *) NULL);
602 f = fopen (tmppath, FOPEN_RB);
606 struct elfhints_hdr hdr;
608 if (fread (&hdr, 1, sizeof (hdr), f) == sizeof (hdr)
609 && hdr.magic == ELFHINTS_MAGIC
612 if (fseek (f, hdr.strtab + hdr.dirlist, SEEK_SET) != -1)
616 b = xmalloc (hdr.dirlistlen + 1);
617 if (fread (b, 1, hdr.dirlistlen + 1, f) ==
619 ld_elf_hints = gld${EMULATION_NAME}_add_sysroot (b);
630 if (ld_elf_hints == NULL)
634 needed.name = l->name;
635 return gld${EMULATION_NAME}_search_needed (ld_elf_hints, &needed, force);
641 *-*-linux-* | *-*-k*bsd*-* | *-*-gnu*)
643 /* For a native linker, check the file /etc/ld.so.conf for directories
644 in which we may find shared libraries. /etc/ld.so.conf is really
645 only meaningful on Linux. */
647 struct gld${EMULATION_NAME}_ld_so_conf
654 gld${EMULATION_NAME}_parse_ld_so_conf
655 (struct gld${EMULATION_NAME}_ld_so_conf *info, const char *filename);
658 gld${EMULATION_NAME}_parse_ld_so_conf_include
659 (struct gld${EMULATION_NAME}_ld_so_conf *info, const char *filename,
667 if (pattern[0] != '/')
669 char *p = strrchr (filename, '/');
670 size_t patlen = strlen (pattern) + 1;
672 newp = xmalloc (p - filename + 1 + patlen);
673 memcpy (newp, filename, p - filename + 1);
674 memcpy (newp + (p - filename + 1), pattern, patlen);
679 if (glob (pattern, 0, NULL, &gl) == 0)
683 for (i = 0; i < gl.gl_pathc; ++i)
684 gld${EMULATION_NAME}_parse_ld_so_conf (info, gl.gl_pathv[i]);
688 /* If we do not have glob, treat the pattern as a literal filename. */
689 gld${EMULATION_NAME}_parse_ld_so_conf (info, pattern);
697 gld${EMULATION_NAME}_parse_ld_so_conf
698 (struct gld${EMULATION_NAME}_ld_so_conf *info, const char *filename)
700 FILE *f = fopen (filename, FOPEN_RT);
708 line = xmalloc (linelen);
713 /* Normally this would use getline(3), but we need to be portable. */
714 while ((q = fgets (p, linelen - (p - line), f)) != NULL
715 && strlen (q) == linelen - (p - line) - 1
716 && line[linelen - 2] != '\n')
718 line = xrealloc (line, 2 * linelen);
719 p = line + linelen - 1;
723 if (q == NULL && p == line)
726 p = strchr (line, '\n');
730 /* Because the file format does not know any form of quoting we
731 can search forward for the next '#' character and if found
732 make it terminating the line. */
733 p = strchr (line, '#');
737 /* Remove leading whitespace. NUL is no whitespace character. */
739 while (*p == ' ' || *p == '\f' || *p == '\r' || *p == '\t' || *p == '\v')
742 /* If the line is blank it is ignored. */
746 if (CONST_STRNEQ (p, "include") && (p[7] == ' ' || p[7] == '\t'))
752 while (*p == ' ' || *p == '\t')
760 while (*p != ' ' && *p != '\t' && *p)
766 gld${EMULATION_NAME}_parse_ld_so_conf_include (info, filename,
774 while (*p && *p != '=' && *p != ' ' && *p != '\t' && *p != '\f'
775 && *p != '\r' && *p != '\v')
778 while (p != dir && p[-1] == '/')
780 if (info->path == NULL)
782 info->alloc = p - dir + 1 + 256;
783 info->path = xmalloc (info->alloc);
788 if (info->len + 1 + (p - dir) >= info->alloc)
790 info->alloc += p - dir + 256;
791 info->path = xrealloc (info->path, info->alloc);
793 info->path[info->len++] = config.rpath_separator;
795 memcpy (info->path + info->len, dir, p - dir);
796 info->len += p - dir;
797 info->path[info->len] = '\0';
807 gld${EMULATION_NAME}_check_ld_so_conf (const struct bfd_link_needed_list *l,
810 static bfd_boolean initialized;
811 static char *ld_so_conf;
812 struct dt_needed needed;
817 struct gld${EMULATION_NAME}_ld_so_conf info;
820 info.len = info.alloc = 0;
821 tmppath = concat (ld_sysroot, "${prefix}/etc/ld.so.conf",
822 (const char *) NULL);
823 if (!gld${EMULATION_NAME}_parse_ld_so_conf (&info, tmppath))
826 tmppath = concat (ld_sysroot, "/etc/ld.so.conf",
827 (const char *) NULL);
828 gld${EMULATION_NAME}_parse_ld_so_conf (&info, tmppath);
834 char *d = gld${EMULATION_NAME}_add_sysroot (info.path);
841 if (ld_so_conf == NULL)
846 needed.name = l->name;
847 return gld${EMULATION_NAME}_search_needed (ld_so_conf, &needed, force);
857 /* See if an input file matches a DT_NEEDED entry by name. */
860 gld${EMULATION_NAME}_check_needed (lang_input_statement_type *s)
864 /* Stop looking if we've found a loaded lib. */
865 if (global_found != NULL
866 && (bfd_elf_get_dyn_lib_class (global_found->the_bfd)
867 & DYN_AS_NEEDED) == 0)
870 if (s->filename == NULL || s->the_bfd == NULL)
873 /* Don't look for a second non-loaded as-needed lib. */
874 if (global_found != NULL
875 && (bfd_elf_get_dyn_lib_class (s->the_bfd) & DYN_AS_NEEDED) != 0)
878 if (filename_cmp (s->filename, global_needed->name) == 0)
884 if (s->flags.search_dirs)
886 const char *f = strrchr (s->filename, '/');
888 && filename_cmp (f + 1, global_needed->name) == 0)
895 soname = bfd_elf_get_dt_soname (s->the_bfd);
897 && filename_cmp (soname, global_needed->name) == 0)
906 if test x"$LDEMUL_AFTER_OPEN" != xgld"$EMULATION_NAME"_after_open; then
910 id_note_section_size (bfd *abfd ATTRIBUTE_UNUSED)
912 const char *style = emit_note_gnu_build_id;
914 bfd_size_type build_id_size;
916 size = offsetof (Elf_External_Note, name[sizeof "GNU"]);
917 size = (size + 3) & -(bfd_size_type) 4;
919 build_id_size = compute_build_id_size (style);
921 size += build_id_size;
929 write_build_id (bfd *abfd)
931 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
932 struct elf_obj_tdata *t = elf_tdata (abfd);
935 Elf_Internal_Shdr *i_shdr;
936 unsigned char *contents, *id_bits;
939 Elf_External_Note *e_note;
941 style = t->o->build_id.style;
942 asec = t->o->build_id.sec;
943 if (bfd_is_abs_section (asec->output_section))
945 einfo (_("%P: warning: .note.gnu.build-id section discarded,"
946 " --build-id ignored.\n"));
949 i_shdr = &elf_section_data (asec->output_section)->this_hdr;
951 if (i_shdr->contents == NULL)
953 if (asec->contents == NULL)
954 asec->contents = (unsigned char *) xmalloc (asec->size);
955 contents = asec->contents;
958 contents = i_shdr->contents + asec->output_offset;
960 e_note = (Elf_External_Note *) contents;
961 size = offsetof (Elf_External_Note, name[sizeof "GNU"]);
962 size = (size + 3) & -(bfd_size_type) 4;
963 id_bits = contents + size;
964 size = asec->size - size;
966 bfd_h_put_32 (abfd, sizeof "GNU", &e_note->namesz);
967 bfd_h_put_32 (abfd, size, &e_note->descsz);
968 bfd_h_put_32 (abfd, NT_GNU_BUILD_ID, &e_note->type);
969 memcpy (e_note->name, "GNU", sizeof "GNU");
971 generate_build_id (abfd, style, bed->s->checksum_contents, id_bits, size);
973 position = i_shdr->sh_offset + asec->output_offset;
975 return (bfd_seek (abfd, position, SEEK_SET) == 0
976 && bfd_bwrite (contents, size, abfd) == size);
979 /* Make .note.gnu.build-id section, and set up elf_tdata->build_id. */
982 setup_build_id (bfd *ibfd)
988 size = id_note_section_size (ibfd);
991 einfo ("%P: warning: unrecognized --build-id style ignored.\n");
995 flags = (SEC_ALLOC | SEC_LOAD | SEC_IN_MEMORY
996 | SEC_LINKER_CREATED | SEC_READONLY | SEC_DATA);
997 s = bfd_make_section_with_flags (ibfd, ".note.gnu.build-id", flags);
998 if (s != NULL && bfd_set_section_alignment (ibfd, s, 2))
1000 struct elf_obj_tdata *t = elf_tdata (link_info.output_bfd);
1001 t->o->build_id.after_write_object_contents = &write_build_id;
1002 t->o->build_id.style = emit_note_gnu_build_id;
1003 t->o->build_id.sec = s;
1004 elf_section_type (s) = SHT_NOTE;
1009 einfo ("%P: warning: Cannot create .note.gnu.build-id section,"
1010 " --build-id ignored.\n");
1014 /* This is called after all the input files have been opened. */
1017 gld${EMULATION_NAME}_after_open (void)
1019 struct bfd_link_needed_list *needed, *l;
1020 struct elf_link_hash_table *htab;
1022 after_open_default ();
1024 htab = elf_hash_table (&link_info);
1025 if (!is_elf_hash_table (htab))
1028 if (emit_note_gnu_build_id != NULL)
1032 /* Find an ELF input. */
1033 for (abfd = link_info.input_bfds;
1034 abfd != (bfd *) NULL; abfd = abfd->link.next)
1035 if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
1036 && bfd_count_sections (abfd) != 0)
1039 /* PR 10555: If there are no ELF input files do not try to
1040 create a .note.gnu-build-id section. */
1042 || !setup_build_id (abfd))
1044 free ((char *) emit_note_gnu_build_id);
1045 emit_note_gnu_build_id = NULL;
1049 if (bfd_link_relocatable (&link_info))
1051 if (link_info.execstack == ! link_info.noexecstack)
1052 /* PR ld/16744: If "-z [no]execstack" has been specified on the
1053 command line and we are perfoming a relocatable link then no
1054 PT_GNU_STACK segment will be created and so the
1055 linkinfo.[no]execstack values set in _handle_option() will have no
1056 effect. Instead we create a .note.GNU-stack section in much the
1057 same way as the assembler does with its --[no]execstack option. */
1058 (void) bfd_make_section_with_flags (link_info.input_bfds,
1060 SEC_READONLY | (link_info.execstack ? SEC_CODE : 0));
1065 if (!link_info.traditional_format)
1067 bfd *abfd, *elfbfd = NULL;
1068 bfd_boolean warn_eh_frame = FALSE;
1072 for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
1075 for (s = abfd->sections; s && type < COMPACT_EH_HDR; s = s->next)
1077 const char *name = bfd_get_section_name (abfd, s);
1079 if (bfd_is_abs_section (s->output_section))
1081 if (CONST_STRNEQ (name, ".eh_frame_entry"))
1082 type = COMPACT_EH_HDR;
1083 else if (strcmp (name, ".eh_frame") == 0 && s->size > 8)
1084 type = DWARF2_EH_HDR;
1093 else if (seen_type != type)
1095 einfo (_("%P%F: compact frame descriptions incompatible with"
1096 " DWARF2 .eh_frame from %B\n"),
1097 type == DWARF2_EH_HDR ? abfd : elfbfd);
1102 && (type == COMPACT_EH_HDR || link_info.eh_frame_hdr_type != 0))
1104 if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
1107 warn_eh_frame = TRUE;
1111 if (seen_type == COMPACT_EH_HDR)
1112 link_info.eh_frame_hdr_type = COMPACT_EH_HDR;
1114 if (bfd_count_sections (abfd) == 0)
1119 const struct elf_backend_data *bed;
1121 bed = get_elf_backend_data (elfbfd);
1122 s = bfd_make_section_with_flags (elfbfd, ".eh_frame_hdr",
1123 bed->dynamic_sec_flags
1126 && bfd_set_section_alignment (elfbfd, s, 2))
1128 htab->eh_info.hdr_sec = s;
1129 warn_eh_frame = FALSE;
1133 einfo ("%P: warning: Cannot create .eh_frame_hdr section,"
1134 " --eh-frame-hdr ignored.\n");
1137 /* Get the list of files which appear in DT_NEEDED entries in
1138 dynamic objects included in the link (often there will be none).
1139 For each such file, we want to track down the corresponding
1140 library, and include the symbol table in the link. This is what
1141 the runtime dynamic linker will do. Tracking the files down here
1142 permits one dynamic object to include another without requiring
1143 special action by the person doing the link. Note that the
1144 needed list can actually grow while we are stepping through this
1146 needed = bfd_elf_get_needed_list (link_info.output_bfd, &link_info);
1147 for (l = needed; l != NULL; l = l->next)
1149 struct bfd_link_needed_list *ll;
1150 struct dt_needed n, nn;
1153 /* If the lib that needs this one was --as-needed and wasn't
1154 found to be needed, then this lib isn't needed either. */
1156 && (bfd_elf_get_dyn_lib_class (l->by) & DYN_AS_NEEDED) != 0)
1159 /* Skip the lib if --no-copy-dt-needed-entries and
1160 --allow-shlib-undefined is in effect. */
1162 && link_info.unresolved_syms_in_shared_libs == RM_IGNORE
1163 && (bfd_elf_get_dyn_lib_class (l->by) & DYN_NO_ADD_NEEDED) != 0)
1166 /* If we've already seen this file, skip it. */
1167 for (ll = needed; ll != l; ll = ll->next)
1169 || (bfd_elf_get_dyn_lib_class (ll->by) & DYN_AS_NEEDED) == 0)
1170 && strcmp (ll->name, l->name) == 0)
1175 /* See if this file was included in the link explicitly. */
1177 global_found = NULL;
1178 lang_for_each_input_file (gld${EMULATION_NAME}_check_needed);
1179 if (global_found != NULL
1180 && (bfd_elf_get_dyn_lib_class (global_found->the_bfd)
1181 & DYN_AS_NEEDED) == 0)
1188 info_msg (_("%s needed by %B\n"), l->name, l->by);
1190 /* As-needed libs specified on the command line (or linker script)
1191 take priority over libs found in search dirs. */
1192 if (global_found != NULL)
1194 nn.name = global_found->filename;
1195 if (gld${EMULATION_NAME}_try_needed (&nn, TRUE))
1199 /* We need to find this file and include the symbol table. We
1200 want to search for the file in the same way that the dynamic
1201 linker will search. That means that we want to use
1202 rpath_link, rpath, then the environment variable
1203 LD_LIBRARY_PATH (native only), then the DT_RPATH/DT_RUNPATH
1204 entries (native only), then the linker script LIB_SEARCH_DIRS.
1205 We do not search using the -L arguments.
1207 We search twice. The first time, we skip objects which may
1208 introduce version mismatches. The second time, we force
1209 their use. See gld${EMULATION_NAME}_vercheck comment. */
1210 for (force = 0; force < 2; force++)
1213 search_dirs_type *search;
1215 if [ "x${NATIVE}" = xyes ] ; then
1217 const char *lib_path;
1220 if [ "x${USE_LIBPATH}" = xyes ] ; then
1222 struct bfd_link_needed_list *rp;
1228 if (gld${EMULATION_NAME}_search_needed (command_line.rpath_link,
1232 if [ "x${USE_LIBPATH}" = xyes ] ; then
1234 if (gld${EMULATION_NAME}_search_needed (command_line.rpath,
1239 if [ "x${NATIVE}" = xyes ] ; then
1241 if (command_line.rpath_link == NULL
1242 && command_line.rpath == NULL)
1244 lib_path = (const char *) getenv ("LD_RUN_PATH");
1245 if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
1249 lib_path = (const char *) getenv ("LD_LIBRARY_PATH");
1250 if (gld${EMULATION_NAME}_search_needed (lib_path, &n, force))
1254 if [ "x${USE_LIBPATH}" = xyes ] ; then
1257 rp = bfd_elf_get_runpath_list (link_info.output_bfd, &link_info);
1258 for (; !found && rp != NULL; rp = rp->next)
1260 const char *tmpname = rp->name;
1262 if (IS_ABSOLUTE_PATH (tmpname))
1263 tmpname = gld${EMULATION_NAME}_add_sysroot (tmpname);
1264 found = (rp->by == l->by
1265 && gld${EMULATION_NAME}_search_needed (tmpname,
1268 if (tmpname != rp->name)
1269 free ((char *) tmpname);
1276 if [ "x${USE_LIBPATH}" = xyes ] ; then
1278 *-*-freebsd* | *-*-dragonfly*)
1280 if (gld${EMULATION_NAME}_check_ld_elf_hints (l, force))
1286 *-*-linux-* | *-*-k*bsd*-* | *-*-gnu*)
1288 if (gld${EMULATION_NAME}_check_ld_so_conf (l, force))
1297 len = strlen (l->name);
1298 for (search = search_head; search != NULL; search = search->next)
1302 if (search->cmdline)
1304 filename = (char *) xmalloc (strlen (search->name) + len + 2);
1305 sprintf (filename, "%s/%s", search->name, l->name);
1307 if (gld${EMULATION_NAME}_try_needed (&nn, force))
1320 einfo ("%P: warning: %s, needed by %B, not found (try using -rpath or -rpath-link)\n",
1324 if (link_info.eh_frame_hdr_type == COMPACT_EH_HDR)
1325 if (bfd_elf_parse_eh_frame_entries (NULL, &link_info) == FALSE)
1326 einfo (_("%P%F: Failed to parse EH frame entries.\n"));
1334 /* Look through an expression for an assignment statement. */
1337 gld${EMULATION_NAME}_find_exp_assignment (etree_type *exp)
1339 bfd_boolean provide = FALSE;
1341 switch (exp->type.node_class)
1344 case etree_provided:
1348 /* We call record_link_assignment even if the symbol is defined.
1349 This is because if it is defined by a dynamic object, we
1350 actually want to use the value defined by the linker script,
1351 not the value from the dynamic object (because we are setting
1352 symbols like etext). If the symbol is defined by a regular
1353 object, then, as it happens, calling record_link_assignment
1355 if (strcmp (exp->assign.dst, ".") != 0)
1357 if (!bfd_elf_record_link_assignment (link_info.output_bfd,
1359 exp->assign.dst, provide,
1360 exp->assign.hidden))
1361 einfo ("%P%F: failed to record assignment to %s: %E\n",
1364 gld${EMULATION_NAME}_find_exp_assignment (exp->assign.src);
1368 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.lhs);
1369 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.rhs);
1373 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.cond);
1374 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.lhs);
1375 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.rhs);
1379 gld${EMULATION_NAME}_find_exp_assignment (exp->unary.child);
1388 /* This is called by the before_allocation routine via
1389 lang_for_each_statement. It locates any assignment statements, and
1390 tells the ELF backend about them, in case they are assignments to
1391 symbols which are referred to by dynamic objects. */
1394 gld${EMULATION_NAME}_find_statement_assignment (lang_statement_union_type *s)
1396 if (s->header.type == lang_assignment_statement_enum)
1397 gld${EMULATION_NAME}_find_exp_assignment (s->assignment_statement.exp);
1402 if test x"$LDEMUL_BEFORE_ALLOCATION" != xgld"$EMULATION_NAME"_before_allocation; then
1403 if test x"${ELF_INTERPRETER_NAME+set}" = xset; then
1404 ELF_INTERPRETER_SET_DEFAULT="
1405 if (sinterp != NULL)
1407 sinterp->contents = (unsigned char *) ${ELF_INTERPRETER_NAME};
1408 sinterp->size = strlen ((char *) sinterp->contents) + 1;
1413 ELF_INTERPRETER_SET_DEFAULT=
1417 /* used by before_allocation and handle_option. */
1419 gld${EMULATION_NAME}_append_to_separated_string (char **to, char *op_arg)
1422 *to = xstrdup (op_arg);
1425 size_t to_len = strlen (*to);
1426 size_t op_arg_len = strlen (op_arg);
1430 /* First see whether OPTARG is already in the path. */
1433 if (strncmp (op_arg, cp, op_arg_len) == 0
1434 && (cp[op_arg_len] == 0
1435 || cp[op_arg_len] == config.rpath_separator))
1439 /* Not yet found. */
1440 cp = strchr (cp, config.rpath_separator);
1448 buf = xmalloc (to_len + op_arg_len + 2);
1449 sprintf (buf, "%s%c%s", *to,
1450 config.rpath_separator, op_arg);
1457 #if defined(__GNUC__) && GCC_VERSION < 4006
1458 /* Work around a GCC uninitialized warning bug fixed in GCC 4.6. */
1459 static struct bfd_link_hash_entry ehdr_start_empty;
1462 /* This is called after the sections have been attached to output
1463 sections, but before any sizes or addresses have been set. */
1466 gld${EMULATION_NAME}_before_allocation (void)
1471 struct elf_link_hash_entry *ehdr_start = NULL;
1472 #if defined(__GNUC__) && GCC_VERSION < 4006
1473 /* Work around a GCC uninitialized warning bug fixed in GCC 4.6. */
1474 struct bfd_link_hash_entry ehdr_start_save = ehdr_start_empty;
1476 struct bfd_link_hash_entry ehdr_start_save;
1479 if (is_elf_hash_table (link_info.hash))
1481 _bfd_elf_tls_setup (link_info.output_bfd, &link_info);
1483 /* Make __ehdr_start hidden if it has been referenced, to
1484 prevent the symbol from being dynamic. */
1485 if (!bfd_link_relocatable (&link_info))
1487 struct elf_link_hash_entry *h
1488 = elf_link_hash_lookup (elf_hash_table (&link_info), "__ehdr_start",
1489 FALSE, FALSE, TRUE);
1491 /* Only adjust the export class if the symbol was referenced
1492 and not defined, otherwise leave it alone. */
1494 && (h->root.type == bfd_link_hash_new
1495 || h->root.type == bfd_link_hash_undefined
1496 || h->root.type == bfd_link_hash_undefweak
1497 || h->root.type == bfd_link_hash_common))
1499 _bfd_elf_link_hash_hide_symbol (&link_info, h, TRUE);
1500 if (ELF_ST_VISIBILITY (h->other) != STV_INTERNAL)
1501 h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN;
1502 /* Don't leave the symbol undefined. Undefined hidden
1503 symbols typically won't have dynamic relocations, but
1504 we most likely will need dynamic relocations for
1505 __ehdr_start if we are building a PIE or shared
1508 ehdr_start_save = h->root;
1509 h->root.type = bfd_link_hash_defined;
1510 h->root.u.def.section = bfd_abs_section_ptr;
1511 h->root.u.def.value = 0;
1515 /* If we are going to make any variable assignments, we need to
1516 let the ELF backend know about them in case the variables are
1517 referred to by dynamic objects. */
1518 lang_for_each_statement (gld${EMULATION_NAME}_find_statement_assignment);
1521 /* Let the ELF backend work out the sizes of any sections required
1522 by dynamic linking. */
1523 rpath = command_line.rpath;
1525 rpath = (const char *) getenv ("LD_RUN_PATH");
1527 for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
1528 if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
1530 const char *audit_libs = elf_dt_audit (abfd);
1532 /* If the input bfd contains an audit entry, we need to add it as
1533 a dep audit entry. */
1534 if (audit_libs && *audit_libs != '\0')
1536 char *cp = xstrdup (audit_libs);
1540 char *cp2 = strchr (cp, config.rpath_separator);
1548 if (cp != NULL && *cp != '\0')
1549 gld${EMULATION_NAME}_append_to_separated_string (&depaudit, cp);
1551 cp = more ? ++cp2 : NULL;
1557 if (! (bfd_elf_size_dynamic_sections
1558 (link_info.output_bfd, command_line.soname, rpath,
1559 command_line.filter_shlib, audit, depaudit,
1560 (const char * const *) command_line.auxiliary_filters,
1561 &link_info, &sinterp)))
1562 einfo ("%P%F: failed to set dynamic section sizes: %E\n");
1564 ${ELF_INTERPRETER_SET_DEFAULT}
1565 /* Let the user override the dynamic linker we are using. */
1566 if (command_line.interpreter != NULL
1569 sinterp->contents = (bfd_byte *) command_line.interpreter;
1570 sinterp->size = strlen (command_line.interpreter) + 1;
1573 /* Look for any sections named .gnu.warning. As a GNU extensions,
1574 we treat such sections as containing warning messages. We print
1575 out the warning message, and then zero out the section size so
1576 that it does not get copied into the output file. */
1579 LANG_FOR_EACH_INPUT_STATEMENT (is)
1586 if (is->flags.just_syms)
1589 s = bfd_get_section_by_name (is->the_bfd, ".gnu.warning");
1594 msg = (char *) xmalloc ((size_t) (sz + 1));
1595 if (! bfd_get_section_contents (is->the_bfd, s, msg,
1597 einfo ("%F%B: Can't read contents of section .gnu.warning: %E\n",
1600 ret = link_info.callbacks->warning (&link_info, msg,
1601 (const char *) NULL,
1602 is->the_bfd, (asection *) NULL,
1607 /* Clobber the section size, so that we don't waste space
1608 copying the warning into the output file. If we've already
1609 sized the output section, adjust its size. The adjustment
1610 is on rawsize because targets that size sections early will
1611 have called lang_reset_memory_regions after sizing. */
1612 if (s->output_section != NULL
1613 && s->output_section->rawsize >= s->size)
1614 s->output_section->rawsize -= s->size;
1618 /* Also set SEC_EXCLUDE, so that local symbols defined in the
1619 warning section don't get copied to the output. */
1620 s->flags |= SEC_EXCLUDE | SEC_KEEP;
1624 before_allocation_default ();
1626 if (!bfd_elf_size_dynsym_hash_dynstr (link_info.output_bfd, &link_info))
1627 einfo ("%P%F: failed to set dynamic section sizes: %E\n");
1629 if (ehdr_start != NULL)
1631 /* If we twiddled __ehdr_start to defined earlier, put it back
1633 ehdr_start->root.type = ehdr_start_save.type;
1634 ehdr_start->root.u = ehdr_start_save.u;
1641 if test x"$LDEMUL_OPEN_DYNAMIC_ARCHIVE" != xgld"$EMULATION_NAME"_open_dynamic_archive; then
1644 /* Try to open a dynamic archive. This is where we know that ELF
1645 dynamic libraries have an extension of .so (or .sl on oddball systems
1649 gld${EMULATION_NAME}_open_dynamic_archive
1650 (const char *arch, search_dirs_type *search, lang_input_statement_type *entry)
1652 const char *filename;
1655 bfd_boolean opened = FALSE;
1657 if (! entry->flags.maybe_archive)
1660 filename = entry->filename;
1661 len = strlen (search->name) + strlen (filename);
1662 if (entry->flags.full_name_provided)
1665 string = (char *) xmalloc (len);
1666 sprintf (string, "%s/%s", search->name, filename);
1672 len += strlen (arch) + sizeof "/lib.so";
1673 #ifdef EXTRA_SHLIB_EXTENSION
1674 xlen = (strlen (EXTRA_SHLIB_EXTENSION) > 3
1675 ? strlen (EXTRA_SHLIB_EXTENSION) - 3
1678 string = (char *) xmalloc (len + xlen);
1679 sprintf (string, "%s/lib%s%s.so", search->name, filename, arch);
1680 #ifdef EXTRA_SHLIB_EXTENSION
1681 /* Try the .so extension first. If that fails build a new filename
1682 using EXTRA_SHLIB_EXTENSION. */
1683 opened = ldfile_try_open_bfd (string, entry);
1685 strcpy (string + len - 4, EXTRA_SHLIB_EXTENSION);
1689 if (!opened && !ldfile_try_open_bfd (string, entry))
1695 entry->filename = string;
1697 /* We have found a dynamic object to include in the link. The ELF
1698 backend linker will create a DT_NEEDED entry in the .dynamic
1699 section naming this file. If this file includes a DT_SONAME
1700 entry, it will be used. Otherwise, the ELF linker will just use
1701 the name of the file. For an archive found by searching, like
1702 this one, the DT_NEEDED entry should consist of just the name of
1703 the file, without the path information used to find it. Note
1704 that we only need to do this if we have a dynamic object; an
1705 archive will never be referenced by a DT_NEEDED entry.
1707 FIXME: This approach--using bfd_elf_set_dt_needed_name--is not
1708 very pretty. I haven't been able to think of anything that is
1710 if (bfd_check_format (entry->the_bfd, bfd_object)
1711 && (entry->the_bfd->flags & DYNAMIC) != 0)
1713 ASSERT (entry->flags.maybe_archive && entry->flags.search_dirs);
1715 /* Rather than duplicating the logic above. Just use the
1716 filename we recorded earlier. */
1718 if (!entry->flags.full_name_provided)
1719 filename = lbasename (entry->filename);
1720 bfd_elf_set_dt_needed_name (entry->the_bfd, filename);
1729 if test x"$LDEMUL_PLACE_ORPHAN" != xgld"$EMULATION_NAME"_place_orphan; then
1732 /* A variant of lang_output_section_find used by place_orphan. */
1734 static lang_output_section_statement_type *
1735 output_rel_find (asection *sec, int isdyn)
1737 lang_output_section_statement_type *lookup;
1738 lang_output_section_statement_type *last = NULL;
1739 lang_output_section_statement_type *last_alloc = NULL;
1740 lang_output_section_statement_type *last_ro_alloc = NULL;
1741 lang_output_section_statement_type *last_rel = NULL;
1742 lang_output_section_statement_type *last_rel_alloc = NULL;
1743 int rela = sec->name[4] == 'a';
1745 for (lookup = &lang_output_section_statement.head->output_section_statement;
1747 lookup = lookup->next)
1749 if (lookup->constraint >= 0
1750 && CONST_STRNEQ (lookup->name, ".rel"))
1752 int lookrela = lookup->name[4] == 'a';
1754 /* .rel.dyn must come before all other reloc sections, to suit
1759 /* Don't place after .rel.plt as doing so results in wrong
1761 if (strcmp (".plt", lookup->name + 4 + lookrela) == 0)
1764 if (rela == lookrela || last_rel == NULL)
1766 if ((rela == lookrela || last_rel_alloc == NULL)
1767 && lookup->bfd_section != NULL
1768 && (lookup->bfd_section->flags & SEC_ALLOC) != 0)
1769 last_rel_alloc = lookup;
1773 if (lookup->bfd_section != NULL
1774 && (lookup->bfd_section->flags & SEC_ALLOC) != 0)
1776 last_alloc = lookup;
1777 if ((lookup->bfd_section->flags & SEC_READONLY) != 0)
1778 last_ro_alloc = lookup;
1783 return last_rel_alloc;
1789 return last_ro_alloc;
1797 /* Place an orphan section. We use this to put random SHF_ALLOC
1798 sections in the right segment. */
1800 static lang_output_section_statement_type *
1801 gld${EMULATION_NAME}_place_orphan (asection *s,
1802 const char *secname,
1805 static struct orphan_save hold[] =
1808 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE,
1811 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA,
1814 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_THREAD_LOCAL,
1817 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_DATA,
1823 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA,
1826 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA,
1829 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_SMALL_DATA,
1835 enum orphan_save_index
1847 static int orphan_init_done = 0;
1848 struct orphan_save *place;
1849 lang_output_section_statement_type *after;
1850 lang_output_section_statement_type *os;
1851 lang_output_section_statement_type *match_by_name = NULL;
1853 int iself = s->owner->xvec->flavour == bfd_target_elf_flavour;
1854 unsigned int sh_type = iself ? elf_section_type (s) : SHT_NULL;
1858 if (!bfd_link_relocatable (&link_info)
1859 && link_info.combreloc
1860 && (s->flags & SEC_ALLOC))
1866 secname = ".rela.dyn";
1870 secname = ".rel.dyn";
1876 else if (CONST_STRNEQ (secname, ".rel"))
1878 secname = secname[4] == 'a' ? ".rela.dyn" : ".rel.dyn";
1883 /* Look through the script to see where to place this section. */
1884 if (constraint == 0)
1885 for (os = lang_output_section_find (secname);
1887 os = next_matching_output_section_statement (os, 0))
1889 /* If we don't match an existing output section, tell
1890 lang_insert_orphan to create a new output section. */
1891 constraint = SPECIAL;
1893 if (os->bfd_section != NULL
1894 && (os->bfd_section->flags == 0
1895 || (((s->flags ^ os->bfd_section->flags)
1896 & (SEC_LOAD | SEC_ALLOC)) == 0
1897 && _bfd_elf_match_sections_by_type (link_info.output_bfd,
1901 /* We already have an output section statement with this
1902 name, and its bfd section has compatible flags.
1903 If the section already exists but does not have any flags
1904 set, then it has been created by the linker, probably as a
1905 result of a --section-start command line switch. */
1906 lang_add_section (&os->children, s, NULL, os);
1910 /* Save unused output sections in case we can match them
1911 against orphans later. */
1912 if (os->bfd_section == NULL)
1916 /* If we didn't match an active output section, see if we matched an
1917 unused one and use that. */
1920 lang_add_section (&match_by_name->children, s, NULL, match_by_name);
1921 return match_by_name;
1924 if (!orphan_init_done)
1926 struct orphan_save *ho;
1928 for (ho = hold; ho < hold + sizeof (hold) / sizeof (hold[0]); ++ho)
1929 if (ho->name != NULL)
1931 ho->os = lang_output_section_find (ho->name);
1932 if (ho->os != NULL && ho->os->flags == 0)
1933 ho->os->flags = ho->flags;
1935 orphan_init_done = 1;
1938 /* If this is a final link, then always put .gnu.warning.SYMBOL
1939 sections into the .text section to get them out of the way. */
1940 if (bfd_link_executable (&link_info)
1941 && CONST_STRNEQ (s->name, ".gnu.warning.")
1942 && hold[orphan_text].os != NULL)
1944 os = hold[orphan_text].os;
1945 lang_add_section (&os->children, s, NULL, os);
1949 /* Decide which segment the section should go in based on the
1950 section name and section flags. We put loadable .note sections
1951 right after the .interp section, so that the PT_NOTE segment is
1952 stored right after the program headers where the OS can read it
1953 in the first page. */
1957 while ((nexts = bfd_get_next_section_by_name (nexts->owner, nexts)) != NULL)
1958 if (nexts->output_section == NULL
1959 && (nexts->flags & SEC_EXCLUDE) == 0
1960 && ((nexts->flags ^ flags) & (SEC_LOAD | SEC_ALLOC)) == 0
1961 && (nexts->owner->flags & DYNAMIC) == 0
1962 && nexts->owner->usrdata != NULL
1963 && !(((lang_input_statement_type *) nexts->owner->usrdata)
1965 && _bfd_elf_match_sections_by_type (nexts->owner, nexts, s->owner, s))
1966 flags = (((flags ^ SEC_READONLY) | (nexts->flags ^ SEC_READONLY))
1969 if ((flags & (SEC_ALLOC | SEC_DEBUGGING)) == 0)
1970 place = &hold[orphan_nonalloc];
1971 else if ((flags & SEC_ALLOC) == 0)
1973 else if ((flags & SEC_LOAD) != 0
1974 && ((iself && sh_type == SHT_NOTE)
1975 || (!iself && CONST_STRNEQ (secname, ".note"))))
1976 place = &hold[orphan_interp];
1977 else if ((flags & (SEC_LOAD | SEC_HAS_CONTENTS | SEC_THREAD_LOCAL)) == 0)
1978 place = &hold[orphan_bss];
1979 else if ((flags & SEC_SMALL_DATA) != 0)
1980 place = &hold[orphan_sdata];
1981 else if ((flags & SEC_THREAD_LOCAL) != 0)
1982 place = &hold[orphan_tdata];
1983 else if ((flags & SEC_READONLY) == 0)
1984 place = &hold[orphan_data];
1985 else if (((iself && (sh_type == SHT_RELA || sh_type == SHT_REL))
1986 || (!iself && CONST_STRNEQ (secname, ".rel")))
1987 && (flags & SEC_LOAD) != 0)
1988 place = &hold[orphan_rel];
1989 else if ((flags & SEC_CODE) == 0)
1990 place = &hold[orphan_rodata];
1992 place = &hold[orphan_text];
1997 if (place->os == NULL)
1999 if (place->name != NULL)
2000 place->os = lang_output_section_find (place->name);
2002 place->os = output_rel_find (s, isdyn);
2006 after = lang_output_section_find_by_flags
2007 (s, &place->os, _bfd_elf_match_sections_by_type);
2009 /* *ABS* is always the first output section statement. */
2010 after = &lang_output_section_statement.head->output_section_statement;
2013 return lang_insert_orphan (s, secname, constraint, after, place, NULL, NULL);
2018 if test x"$LDEMUL_AFTER_ALLOCATION" != xgld"$EMULATION_NAME"_after_allocation; then
2022 gld${EMULATION_NAME}_after_allocation (void)
2024 int need_layout = bfd_elf_discard_info (link_info.output_bfd, &link_info);
2026 if (need_layout < 0)
2027 einfo ("%X%P: .eh_frame/.stab edit: %E\n");
2029 gld${EMULATION_NAME}_map_segments (need_layout);
2034 if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then
2038 gld${EMULATION_NAME}_get_script (int *isfile)
2041 if test x"$COMPILE_IN" = xyes
2043 # Scripts compiled in.
2045 # sed commands to quote an ld script as a C string.
2046 sc="-f stringify.sed"
2052 if (bfd_link_relocatable (&link_info) && config.build_constructors)
2055 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
2056 echo ' ; else if (bfd_link_relocatable (&link_info)) return' >> e${EMULATION_NAME}.c
2057 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
2058 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
2059 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
2060 if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then : ; else
2061 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
2062 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
2064 if test -n "$GENERATE_PIE_SCRIPT" ; then
2065 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
2066 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
2067 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
2068 echo ' && link_info.relro' >> e${EMULATION_NAME}.c
2069 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
2070 sed $sc ldscripts/${EMULATION_NAME}.xdw >> e${EMULATION_NAME}.c
2071 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
2072 echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c
2073 sed $sc ldscripts/${EMULATION_NAME}.xdc >> e${EMULATION_NAME}.c
2075 echo ' ; else if (bfd_link_pie (&link_info)) return' >> e${EMULATION_NAME}.c
2076 sed $sc ldscripts/${EMULATION_NAME}.xd >> e${EMULATION_NAME}.c
2078 if test -n "$GENERATE_SHLIB_SCRIPT" ; then
2079 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
2080 echo ' ; else if (bfd_link_dll (&link_info) && link_info.combreloc' >> e${EMULATION_NAME}.c
2081 echo ' && link_info.relro' >> e${EMULATION_NAME}.c
2082 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
2083 sed $sc ldscripts/${EMULATION_NAME}.xsw >> e${EMULATION_NAME}.c
2084 echo ' ; else if (bfd_link_dll (&link_info) && link_info.combreloc) return' >> e${EMULATION_NAME}.c
2085 sed $sc ldscripts/${EMULATION_NAME}.xsc >> e${EMULATION_NAME}.c
2087 echo ' ; else if (bfd_link_dll (&link_info)) return' >> e${EMULATION_NAME}.c
2088 sed $sc ldscripts/${EMULATION_NAME}.xs >> e${EMULATION_NAME}.c
2090 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
2091 echo ' ; else if (link_info.combreloc && link_info.relro' >> e${EMULATION_NAME}.c
2092 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
2093 sed $sc ldscripts/${EMULATION_NAME}.xw >> e${EMULATION_NAME}.c
2094 echo ' ; else if (link_info.combreloc) return' >> e${EMULATION_NAME}.c
2095 sed $sc ldscripts/${EMULATION_NAME}.xc >> e${EMULATION_NAME}.c
2097 echo ' ; else return' >> e${EMULATION_NAME}.c
2098 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
2099 echo '; }' >> e${EMULATION_NAME}.c
2102 # Scripts read from the filesystem.
2108 if (bfd_link_relocatable (&link_info) && config.build_constructors)
2109 return "ldscripts/${EMULATION_NAME}.xu";
2110 else if (bfd_link_relocatable (&link_info))
2111 return "ldscripts/${EMULATION_NAME}.xr";
2112 else if (!config.text_read_only)
2113 return "ldscripts/${EMULATION_NAME}.xbn";
2115 if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then :
2118 else if (!config.magic_demand_paged)
2119 return "ldscripts/${EMULATION_NAME}.xn";
2122 if test -n "$GENERATE_PIE_SCRIPT" ; then
2123 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
2125 else if (bfd_link_pie (&link_info)
2126 && link_info.combreloc
2128 && (link_info.flags & DF_BIND_NOW))
2129 return "ldscripts/${EMULATION_NAME}.xdw";
2130 else if (bfd_link_pie (&link_info)
2131 && link_info.combreloc)
2132 return "ldscripts/${EMULATION_NAME}.xdc";
2136 else if (bfd_link_pie (&link_info))
2137 return "ldscripts/${EMULATION_NAME}.xd";
2140 if test -n "$GENERATE_SHLIB_SCRIPT" ; then
2141 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
2143 else if (bfd_link_dll (&link_info) && link_info.combreloc
2144 && link_info.relro && (link_info.flags & DF_BIND_NOW))
2145 return "ldscripts/${EMULATION_NAME}.xsw";
2146 else if (bfd_link_dll (&link_info) && link_info.combreloc)
2147 return "ldscripts/${EMULATION_NAME}.xsc";
2151 else if (bfd_link_dll (&link_info))
2152 return "ldscripts/${EMULATION_NAME}.xs";
2155 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
2157 else if (link_info.combreloc && link_info.relro
2158 && (link_info.flags & DF_BIND_NOW))
2159 return "ldscripts/${EMULATION_NAME}.xw";
2160 else if (link_info.combreloc)
2161 return "ldscripts/${EMULATION_NAME}.xc";
2166 return "ldscripts/${EMULATION_NAME}.x";
2173 if test -n "$PARSE_AND_LIST_PROLOGUE" ; then
2175 $PARSE_AND_LIST_PROLOGUE
2181 #define OPTION_DISABLE_NEW_DTAGS (400)
2182 #define OPTION_ENABLE_NEW_DTAGS (OPTION_DISABLE_NEW_DTAGS + 1)
2183 #define OPTION_GROUP (OPTION_ENABLE_NEW_DTAGS + 1)
2184 #define OPTION_EH_FRAME_HDR (OPTION_GROUP + 1)
2185 #define OPTION_EXCLUDE_LIBS (OPTION_EH_FRAME_HDR + 1)
2186 #define OPTION_HASH_STYLE (OPTION_EXCLUDE_LIBS + 1)
2187 #define OPTION_BUILD_ID (OPTION_HASH_STYLE + 1)
2188 #define OPTION_AUDIT (OPTION_BUILD_ID + 1)
2189 #define OPTION_COMPRESS_DEBUG (OPTION_AUDIT + 1)
2192 gld${EMULATION_NAME}_add_options
2193 (int ns, char **shortopts, int nl, struct option **longopts,
2194 int nrl ATTRIBUTE_UNUSED, struct option **really_longopts ATTRIBUTE_UNUSED)
2197 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
2199 static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:P:";
2203 static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:";
2207 static const struct option xtra_long[] = {
2209 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
2211 {"audit", required_argument, NULL, OPTION_AUDIT},
2212 {"Bgroup", no_argument, NULL, OPTION_GROUP},
2216 {"build-id", optional_argument, NULL, OPTION_BUILD_ID},
2217 {"compress-debug-sections", required_argument, NULL, OPTION_COMPRESS_DEBUG},
2219 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
2221 {"depaudit", required_argument, NULL, 'P'},
2222 {"disable-new-dtags", no_argument, NULL, OPTION_DISABLE_NEW_DTAGS},
2223 {"enable-new-dtags", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS},
2224 {"eh-frame-hdr", no_argument, NULL, OPTION_EH_FRAME_HDR},
2225 {"exclude-libs", required_argument, NULL, OPTION_EXCLUDE_LIBS},
2226 {"hash-style", required_argument, NULL, OPTION_HASH_STYLE},
2229 if test -n "$PARSE_AND_LIST_LONGOPTS" ; then
2231 $PARSE_AND_LIST_LONGOPTS
2235 {NULL, no_argument, NULL, 0}
2238 *shortopts = (char *) xrealloc (*shortopts, ns + sizeof (xtra_short));
2239 memcpy (*shortopts + ns, &xtra_short, sizeof (xtra_short));
2240 *longopts = (struct option *)
2241 xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
2242 memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
2245 #define DEFAULT_BUILD_ID_STYLE "sha1"
2248 gld${EMULATION_NAME}_handle_option (int optc)
2255 case OPTION_BUILD_ID:
2256 if (emit_note_gnu_build_id != NULL)
2258 free ((char *) emit_note_gnu_build_id);
2259 emit_note_gnu_build_id = NULL;
2262 optarg = DEFAULT_BUILD_ID_STYLE;
2263 if (strcmp (optarg, "none"))
2264 emit_note_gnu_build_id = xstrdup (optarg);
2267 case OPTION_COMPRESS_DEBUG:
2268 if (strcasecmp (optarg, "none") == 0)
2269 link_info.compress_debug = COMPRESS_DEBUG_NONE;
2270 else if (strcasecmp (optarg, "zlib") == 0)
2271 link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB;
2272 else if (strcasecmp (optarg, "zlib-gnu") == 0)
2273 link_info.compress_debug = COMPRESS_DEBUG_GNU_ZLIB;
2274 else if (strcasecmp (optarg, "zlib-gabi") == 0)
2275 link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB;
2277 einfo (_("%P%F: invalid --compress-debug-sections option: \`%s'\n"),
2282 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
2285 gld${EMULATION_NAME}_append_to_separated_string (&audit, optarg);
2289 gld${EMULATION_NAME}_append_to_separated_string (&depaudit, optarg);
2292 case OPTION_DISABLE_NEW_DTAGS:
2293 link_info.new_dtags = FALSE;
2296 case OPTION_ENABLE_NEW_DTAGS:
2297 link_info.new_dtags = TRUE;
2300 case OPTION_EH_FRAME_HDR:
2301 link_info.eh_frame_hdr_type = DWARF2_EH_HDR;
2305 link_info.flags_1 |= (bfd_vma) DF_1_GROUP;
2306 /* Groups must be self-contained. */
2307 link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
2308 link_info.unresolved_syms_in_shared_libs = RM_GENERATE_ERROR;
2311 case OPTION_EXCLUDE_LIBS:
2312 add_excluded_libs (optarg);
2315 case OPTION_HASH_STYLE:
2316 link_info.emit_hash = FALSE;
2317 link_info.emit_gnu_hash = FALSE;
2318 if (strcmp (optarg, "sysv") == 0)
2319 link_info.emit_hash = TRUE;
2320 else if (strcmp (optarg, "gnu") == 0)
2321 link_info.emit_gnu_hash = TRUE;
2322 else if (strcmp (optarg, "both") == 0)
2324 link_info.emit_hash = TRUE;
2325 link_info.emit_gnu_hash = TRUE;
2328 einfo (_("%P%F: invalid hash style \`%s'\n"), optarg);
2335 if (strcmp (optarg, "defs") == 0)
2336 link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
2337 else if (strcmp (optarg, "muldefs") == 0)
2338 link_info.allow_multiple_definition = TRUE;
2339 else if (CONST_STRNEQ (optarg, "max-page-size="))
2343 config.maxpagesize = strtoul (optarg + 14, &end, 0);
2344 if (*end || (config.maxpagesize & (config.maxpagesize - 1)) != 0)
2345 einfo (_("%P%F: invalid maxium page size \`%s'\n"),
2348 else if (CONST_STRNEQ (optarg, "common-page-size="))
2351 config.commonpagesize = strtoul (optarg + 17, &end, 0);
2353 || (config.commonpagesize & (config.commonpagesize - 1)) != 0)
2354 einfo (_("%P%F: invalid common page size \`%s'\n"),
2357 else if (CONST_STRNEQ (optarg, "stack-size="))
2360 link_info.stacksize = strtoul (optarg + 11, &end, 0);
2361 if (*end || link_info.stacksize < 0)
2362 einfo (_("%P%F: invalid stack size \`%s'\n"), optarg + 11);
2363 if (!link_info.stacksize)
2364 /* Use -1 for explicit no-stack, because zero means
2366 link_info.stacksize = -1;
2368 else if (strcmp (optarg, "execstack") == 0)
2370 link_info.execstack = TRUE;
2371 link_info.noexecstack = FALSE;
2373 else if (strcmp (optarg, "noexecstack") == 0)
2375 link_info.noexecstack = TRUE;
2376 link_info.execstack = FALSE;
2380 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
2382 else if (strcmp (optarg, "global") == 0)
2383 link_info.flags_1 |= (bfd_vma) DF_1_GLOBAL;
2384 else if (strcmp (optarg, "initfirst") == 0)
2385 link_info.flags_1 |= (bfd_vma) DF_1_INITFIRST;
2386 else if (strcmp (optarg, "interpose") == 0)
2387 link_info.flags_1 |= (bfd_vma) DF_1_INTERPOSE;
2388 else if (strcmp (optarg, "loadfltr") == 0)
2389 link_info.flags_1 |= (bfd_vma) DF_1_LOADFLTR;
2390 else if (strcmp (optarg, "nodefaultlib") == 0)
2391 link_info.flags_1 |= (bfd_vma) DF_1_NODEFLIB;
2392 else if (strcmp (optarg, "nodelete") == 0)
2393 link_info.flags_1 |= (bfd_vma) DF_1_NODELETE;
2394 else if (strcmp (optarg, "nodlopen") == 0)
2395 link_info.flags_1 |= (bfd_vma) DF_1_NOOPEN;
2396 else if (strcmp (optarg, "nodump") == 0)
2397 link_info.flags_1 |= (bfd_vma) DF_1_NODUMP;
2398 else if (strcmp (optarg, "now") == 0)
2400 link_info.flags |= (bfd_vma) DF_BIND_NOW;
2401 link_info.flags_1 |= (bfd_vma) DF_1_NOW;
2403 else if (strcmp (optarg, "lazy") == 0)
2405 link_info.flags &= ~(bfd_vma) DF_BIND_NOW;
2406 link_info.flags_1 &= ~(bfd_vma) DF_1_NOW;
2408 else if (strcmp (optarg, "origin") == 0)
2410 link_info.flags |= (bfd_vma) DF_ORIGIN;
2411 link_info.flags_1 |= (bfd_vma) DF_1_ORIGIN;
2413 else if (strcmp (optarg, "combreloc") == 0)
2414 link_info.combreloc = TRUE;
2415 else if (strcmp (optarg, "nocombreloc") == 0)
2416 link_info.combreloc = FALSE;
2417 else if (strcmp (optarg, "nocopyreloc") == 0)
2418 link_info.nocopyreloc = TRUE;
2419 else if (strcmp (optarg, "relro") == 0)
2420 link_info.relro = TRUE;
2421 else if (strcmp (optarg, "norelro") == 0)
2422 link_info.relro = FALSE;
2423 else if (strcmp (optarg, "text") == 0)
2424 link_info.error_textrel = TRUE;
2425 else if (strcmp (optarg, "notext") == 0)
2426 link_info.error_textrel = FALSE;
2427 else if (strcmp (optarg, "textoff") == 0)
2428 link_info.error_textrel = FALSE;
2432 if test -n "$PARSE_AND_LIST_ARGS_CASE_Z" ; then
2434 $PARSE_AND_LIST_ARGS_CASE_Z
2440 einfo (_("%P: warning: -z %s ignored.\n"), optarg);
2444 if test -n "$PARSE_AND_LIST_ARGS_CASES" ; then
2446 $PARSE_AND_LIST_ARGS_CASES
2458 if test x"$LDEMUL_LIST_OPTIONS" != xgld"$EMULATION_NAME"_list_options; then
2459 gld_list_options="gld${EMULATION_NAME}_list_options"
2460 if test -n "$PARSE_AND_LIST_OPTIONS"; then
2464 gld${EMULATION_NAME}_list_options (FILE * file)
2468 if test -n "$PARSE_AND_LIST_OPTIONS" ; then
2470 $PARSE_AND_LIST_OPTIONS
2478 gld_list_options="NULL"
2481 if test -n "$PARSE_AND_LIST_EPILOGUE" ; then
2483 $PARSE_AND_LIST_EPILOGUE
2490 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
2492 ${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse},
2493 ${LDEMUL_SYSLIB-syslib_default},
2494 ${LDEMUL_HLL-hll_default},
2495 ${LDEMUL_AFTER_PARSE-gld${EMULATION_NAME}_after_parse},
2496 ${LDEMUL_AFTER_OPEN-gld${EMULATION_NAME}_after_open},
2497 ${LDEMUL_AFTER_ALLOCATION-gld${EMULATION_NAME}_after_allocation},
2498 ${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
2499 ${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
2500 ${LDEMUL_BEFORE_ALLOCATION-gld${EMULATION_NAME}_before_allocation},
2501 ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
2502 "${EMULATION_NAME}",
2504 ${LDEMUL_FINISH-finish_default},
2505 ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL},
2506 ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-gld${EMULATION_NAME}_open_dynamic_archive},
2507 ${LDEMUL_PLACE_ORPHAN-gld${EMULATION_NAME}_place_orphan},
2508 ${LDEMUL_SET_SYMBOLS-NULL},
2509 ${LDEMUL_PARSE_ARGS-NULL},
2510 gld${EMULATION_NAME}_add_options,
2511 gld${EMULATION_NAME}_handle_option,
2512 ${LDEMUL_UNRECOGNIZED_FILE-NULL},
2513 ${LDEMUL_LIST_OPTIONS-${gld_list_options}},
2514 ${LDEMUL_RECOGNIZED_FILE-gld${EMULATION_NAME}_load_symbols},
2515 ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL},
2516 ${LDEMUL_NEW_VERS_PATTERN-NULL},
2517 ${LDEMUL_EXTRA_MAP_FILE_TEXT-NULL}