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-2016 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`;
107 link_info.check_relocs_after_open_input = `if test "x${CHECK_RELOCS_AFTER_OPEN_INPUT}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
113 if test x"$LDEMUL_AFTER_PARSE" != xgld"$EMULATION_NAME"_after_parse; then
117 gld${EMULATION_NAME}_after_parse (void)
119 if (bfd_link_pie (&link_info))
120 link_info.flags_1 |= (bfd_vma) DF_1_PIE;
122 after_parse_default ();
128 if test x"$LDEMUL_RECOGNIZED_FILE" != xgld"${EMULATION_NAME}"_load_symbols; then
130 /* Handle the generation of DT_NEEDED tags. */
133 gld${EMULATION_NAME}_load_symbols (lang_input_statement_type *entry)
137 /* Tell the ELF linker that we don't want the output file to have a
138 DT_NEEDED entry for this file, unless it is used to resolve
139 references in a regular object. */
140 if (entry->flags.add_DT_NEEDED_for_regular)
141 link_class = DYN_AS_NEEDED;
143 /* Tell the ELF linker that we don't want the output file to have a
144 DT_NEEDED entry for any dynamic library in DT_NEEDED tags from
146 if (!entry->flags.add_DT_NEEDED_for_dynamic)
147 link_class |= DYN_NO_ADD_NEEDED;
149 if (entry->flags.just_syms
150 && (bfd_get_file_flags (entry->the_bfd) & DYNAMIC) != 0)
151 einfo (_("%P%F: --just-symbols may not be used on DSO: %B\n"),
155 || (bfd_get_file_flags (entry->the_bfd) & DYNAMIC) == 0)
158 bfd_elf_set_dyn_lib_class (entry->the_bfd,
159 (enum dynamic_lib_link_class) link_class);
161 /* Continue on with normal load_symbols processing. */
169 /* These variables are required to pass information back and forth
170 between after_open and check_needed and stat_needed and vercheck. */
172 static struct bfd_link_needed_list *global_needed;
173 static struct stat global_stat;
174 static lang_input_statement_type *global_found;
175 static struct bfd_link_needed_list *global_vercheck_needed;
176 static bfd_boolean global_vercheck_failed;
178 /* These variables are used to implement target options */
180 static char *audit; /* colon (typically) separated list of libs */
181 static char *depaudit; /* colon (typically) separated list of libs */
183 /* Style of .note.gnu.build-id section. */
184 static const char *emit_note_gnu_build_id;
186 /* On Linux, it's possible to have different versions of the same
187 shared library linked against different versions of libc. The
188 dynamic linker somehow tags which libc version to use in
189 /etc/ld.so.cache, and, based on the libc that it sees in the
190 executable, chooses which version of the shared library to use.
192 We try to do a similar check here by checking whether this shared
193 library needs any other shared libraries which may conflict with
194 libraries we have already included in the link. If it does, we
195 skip it, and try to find another shared library farther on down the
198 This is called via lang_for_each_input_file.
199 GLOBAL_VERCHECK_NEEDED is the list of objects needed by the object
200 which we are checking. This sets GLOBAL_VERCHECK_FAILED if we find
201 a conflicting version. */
204 gld${EMULATION_NAME}_vercheck (lang_input_statement_type *s)
207 struct bfd_link_needed_list *l;
209 if (global_vercheck_failed)
211 if (s->the_bfd == NULL
212 || (bfd_get_file_flags (s->the_bfd) & DYNAMIC) == 0)
215 soname = bfd_elf_get_dt_soname (s->the_bfd);
217 soname = lbasename (bfd_get_filename (s->the_bfd));
219 for (l = global_vercheck_needed; l != NULL; l = l->next)
223 if (filename_cmp (soname, l->name) == 0)
225 /* Probably can't happen, but it's an easy check. */
229 if (strchr (l->name, '/') != NULL)
232 suffix = strstr (l->name, ".so.");
236 suffix += sizeof ".so." - 1;
238 if (filename_ncmp (soname, l->name, suffix - l->name) == 0)
240 /* Here we know that S is a dynamic object FOO.SO.VER1, and
241 the object we are considering needs a dynamic object
242 FOO.SO.VER2, and VER1 and VER2 are different. This
243 appears to be a version mismatch, so we tell the caller
244 to try a different version of this library. */
245 global_vercheck_failed = TRUE;
252 /* See if an input file matches a DT_NEEDED entry by running stat on
256 gld${EMULATION_NAME}_stat_needed (lang_input_statement_type *s)
262 if (global_found != NULL)
264 if (s->the_bfd == NULL)
267 /* If this input file was an as-needed entry, and wasn't found to be
268 needed at the stage it was linked, then don't say we have loaded it. */
269 if ((bfd_elf_get_dyn_lib_class (s->the_bfd) & DYN_AS_NEEDED) != 0)
272 if (bfd_stat (s->the_bfd, &st) != 0)
274 einfo ("%P:%B: bfd_stat failed: %E\n", s->the_bfd);
278 /* Some operating systems, e.g. Windows, do not provide a meaningful
279 st_ino; they always set it to zero. (Windows does provide a
280 meaningful st_dev.) Do not indicate a duplicate library in that
281 case. While there is no guarantee that a system that provides
282 meaningful inode numbers will never set st_ino to zero, this is
283 merely an optimization, so we do not need to worry about false
285 if (st.st_dev == global_stat.st_dev
286 && st.st_ino == global_stat.st_ino
293 /* We issue a warning if it looks like we are including two
294 different versions of the same shared library. For example,
295 there may be a problem if -lc picks up libc.so.6 but some other
296 shared library has a DT_NEEDED entry of libc.so.5. This is a
297 heuristic test, and it will only work if the name looks like
298 NAME.so.VERSION. FIXME: Depending on file names is error-prone.
299 If we really want to issue warnings about mixing version numbers
300 of shared libraries, we need to find a better way. */
302 if (strchr (global_needed->name, '/') != NULL)
304 suffix = strstr (global_needed->name, ".so.");
307 suffix += sizeof ".so." - 1;
309 soname = bfd_elf_get_dt_soname (s->the_bfd);
311 soname = lbasename (s->filename);
313 if (filename_ncmp (soname, global_needed->name, suffix - global_needed->name) == 0)
314 einfo ("%P: warning: %s, needed by %B, may conflict with %s\n",
315 global_needed->name, global_needed->by, soname);
324 /* This function is called for each possible name for a dynamic object
325 named by a DT_NEEDED entry. The FORCE parameter indicates whether
326 to skip the check for a conflicting version. */
329 gld${EMULATION_NAME}_try_needed (struct dt_needed *needed,
333 const char *name = needed->name;
337 abfd = bfd_openr (name, bfd_get_target (link_info.output_bfd));
341 /* Linker needs to decompress sections. */
342 abfd->flags |= BFD_DECOMPRESS;
344 if (! bfd_check_format (abfd, bfd_object))
349 if ((bfd_get_file_flags (abfd) & DYNAMIC) == 0)
355 /* For DT_NEEDED, they have to match. */
356 if (abfd->xvec != link_info.output_bfd->xvec)
362 /* Check whether this object would include any conflicting library
363 versions. If FORCE is set, then we skip this check; we use this
364 the second time around, if we couldn't find any compatible
365 instance of the shared library. */
369 struct bfd_link_needed_list *needs;
371 if (! bfd_elf_get_bfd_needed_list (abfd, &needs))
372 einfo ("%F%P:%B: bfd_elf_get_bfd_needed_list failed: %E\n", abfd);
376 global_vercheck_needed = needs;
377 global_vercheck_failed = FALSE;
378 lang_for_each_input_file (gld${EMULATION_NAME}_vercheck);
379 if (global_vercheck_failed)
382 /* Return FALSE to force the caller to move on to try
383 another file on the search path. */
387 /* But wait! It gets much worse. On Linux, if a shared
388 library does not use libc at all, we are supposed to skip
389 it the first time around in case we encounter a shared
390 library later on with the same name which does use the
391 version of libc that we want. This is much too horrible
392 to use on any system other than Linux. */
396 *-*-linux-* | *-*-k*bsd*-* | *-*-gnu*)
399 struct bfd_link_needed_list *l;
401 for (l = needs; l != NULL; l = l->next)
402 if (CONST_STRNEQ (l->name, "libc.so"))
418 /* We've found a dynamic object matching the DT_NEEDED entry. */
420 /* We have already checked that there is no other input file of the
421 same name. We must now check again that we are not including the
422 same file twice. We need to do this because on many systems
423 libc.so is a symlink to, e.g., libc.so.1. The SONAME entry will
424 reference libc.so.1. If we have already included libc.so, we
425 don't want to include libc.so.1 if they are the same file, and we
426 can only check that using stat. */
428 if (bfd_stat (abfd, &global_stat) != 0)
429 einfo ("%F%P:%B: bfd_stat failed: %E\n", abfd);
431 /* First strip off everything before the last '/'. */
432 soname = lbasename (abfd->filename);
435 info_msg (_("found %s at %s\n"), soname, name);
438 lang_for_each_input_file (gld${EMULATION_NAME}_stat_needed);
439 if (global_found != NULL)
441 /* Return TRUE to indicate that we found the file, even though
442 we aren't going to do anything with it. */
446 /* Specify the soname to use. */
447 bfd_elf_set_dt_needed_name (abfd, soname);
449 /* Tell the ELF linker that we don't want the output file to have a
450 DT_NEEDED entry for this file, unless it is used to resolve
451 references in a regular object. */
452 link_class = DYN_DT_NEEDED;
454 /* Tell the ELF linker that we don't want the output file to have a
455 DT_NEEDED entry for this file at all if the entry is from a file
456 with DYN_NO_ADD_NEEDED. */
457 if (needed->by != NULL
458 && (bfd_elf_get_dyn_lib_class (needed->by) & DYN_NO_ADD_NEEDED) != 0)
459 link_class |= DYN_NO_NEEDED | DYN_NO_ADD_NEEDED;
461 bfd_elf_set_dyn_lib_class (abfd, (enum dynamic_lib_link_class) link_class);
463 /* Add this file into the symbol table. */
464 if (! bfd_link_add_symbols (abfd, &link_info))
465 einfo ("%F%B: error adding symbols: %E\n", abfd);
471 /* Search for a needed file in a path. */
474 gld${EMULATION_NAME}_search_needed (const char *path,
475 struct dt_needed *n, int force)
478 const char *name = n->name;
480 struct dt_needed needed;
483 return gld${EMULATION_NAME}_try_needed (n, force);
485 if (path == NULL || *path == '\0')
489 needed.name = n->name;
494 char *filename, *sset;
496 s = strchr (path, config.rpath_separator);
498 s = path + strlen (path);
500 #if HAVE_DOS_BASED_FILE_SYSTEM
501 /* Assume a match on the second char is part of drive specifier. */
502 else if (config.rpath_separator == ':'
506 s = strchr (s + 1, config.rpath_separator);
508 s = path + strlen (path);
511 filename = (char *) xmalloc (s - path + len + 2);
516 memcpy (filename, path, s - path);
517 filename[s - path] = '/';
518 sset = filename + (s - path) + 1;
522 needed.name = filename;
523 if (gld${EMULATION_NAME}_try_needed (&needed, force))
537 if [ "x${USE_LIBPATH}" = xyes ] ; then
540 /* Add the sysroot to every entry in a path separated by
541 config.rpath_separator. */
544 gld${EMULATION_NAME}_add_sysroot (const char *path)
553 if (path[i++] == config.rpath_separator)
559 len = len + (colons + 1) * strlen (ld_sysroot);
560 ret = xmalloc (len + 1);
561 strcpy (ret, ld_sysroot);
562 p = ret + strlen (ret);
565 if (path[i] == config.rpath_separator)
568 strcpy (p, ld_sysroot);
580 *-*-freebsd* | *-*-dragonfly*)
582 /* Read the system search path the FreeBSD way rather than the Linux way. */
583 #ifdef HAVE_ELF_HINTS_H
584 #include <elf-hints.h>
586 #include "elf-hints-local.h"
590 gld${EMULATION_NAME}_check_ld_elf_hints (const struct bfd_link_needed_list *l,
593 static bfd_boolean initialized;
594 static char *ld_elf_hints;
595 struct dt_needed needed;
602 tmppath = concat (ld_sysroot, _PATH_ELF_HINTS, (const char *) NULL);
603 f = fopen (tmppath, FOPEN_RB);
607 struct elfhints_hdr hdr;
609 if (fread (&hdr, 1, sizeof (hdr), f) == sizeof (hdr)
610 && hdr.magic == ELFHINTS_MAGIC
613 if (fseek (f, hdr.strtab + hdr.dirlist, SEEK_SET) != -1)
617 b = xmalloc (hdr.dirlistlen + 1);
618 if (fread (b, 1, hdr.dirlistlen + 1, f) ==
620 ld_elf_hints = gld${EMULATION_NAME}_add_sysroot (b);
631 if (ld_elf_hints == NULL)
635 needed.name = l->name;
636 return gld${EMULATION_NAME}_search_needed (ld_elf_hints, &needed, force);
642 *-*-linux-* | *-*-k*bsd*-* | *-*-gnu*)
644 /* For a native linker, check the file /etc/ld.so.conf for directories
645 in which we may find shared libraries. /etc/ld.so.conf is really
646 only meaningful on Linux. */
648 struct gld${EMULATION_NAME}_ld_so_conf
655 gld${EMULATION_NAME}_parse_ld_so_conf
656 (struct gld${EMULATION_NAME}_ld_so_conf *info, const char *filename);
659 gld${EMULATION_NAME}_parse_ld_so_conf_include
660 (struct gld${EMULATION_NAME}_ld_so_conf *info, const char *filename,
668 if (pattern[0] != '/')
670 char *p = strrchr (filename, '/');
671 size_t patlen = strlen (pattern) + 1;
673 newp = xmalloc (p - filename + 1 + patlen);
674 memcpy (newp, filename, p - filename + 1);
675 memcpy (newp + (p - filename + 1), pattern, patlen);
680 if (glob (pattern, 0, NULL, &gl) == 0)
684 for (i = 0; i < gl.gl_pathc; ++i)
685 gld${EMULATION_NAME}_parse_ld_so_conf (info, gl.gl_pathv[i]);
689 /* If we do not have glob, treat the pattern as a literal filename. */
690 gld${EMULATION_NAME}_parse_ld_so_conf (info, pattern);
698 gld${EMULATION_NAME}_parse_ld_so_conf
699 (struct gld${EMULATION_NAME}_ld_so_conf *info, const char *filename)
701 FILE *f = fopen (filename, FOPEN_RT);
709 line = xmalloc (linelen);
714 /* Normally this would use getline(3), but we need to be portable. */
715 while ((q = fgets (p, linelen - (p - line), f)) != NULL
716 && strlen (q) == linelen - (p - line) - 1
717 && line[linelen - 2] != '\n')
719 line = xrealloc (line, 2 * linelen);
720 p = line + linelen - 1;
724 if (q == NULL && p == line)
727 p = strchr (line, '\n');
731 /* Because the file format does not know any form of quoting we
732 can search forward for the next '#' character and if found
733 make it terminating the line. */
734 p = strchr (line, '#');
738 /* Remove leading whitespace. NUL is no whitespace character. */
740 while (*p == ' ' || *p == '\f' || *p == '\r' || *p == '\t' || *p == '\v')
743 /* If the line is blank it is ignored. */
747 if (CONST_STRNEQ (p, "include") && (p[7] == ' ' || p[7] == '\t'))
753 while (*p == ' ' || *p == '\t')
761 while (*p != ' ' && *p != '\t' && *p)
767 gld${EMULATION_NAME}_parse_ld_so_conf_include (info, filename,
775 while (*p && *p != '=' && *p != ' ' && *p != '\t' && *p != '\f'
776 && *p != '\r' && *p != '\v')
779 while (p != dir && p[-1] == '/')
781 if (info->path == NULL)
783 info->alloc = p - dir + 1 + 256;
784 info->path = xmalloc (info->alloc);
789 if (info->len + 1 + (p - dir) >= info->alloc)
791 info->alloc += p - dir + 256;
792 info->path = xrealloc (info->path, info->alloc);
794 info->path[info->len++] = config.rpath_separator;
796 memcpy (info->path + info->len, dir, p - dir);
797 info->len += p - dir;
798 info->path[info->len] = '\0';
808 gld${EMULATION_NAME}_check_ld_so_conf (const struct bfd_link_needed_list *l,
811 static bfd_boolean initialized;
812 static char *ld_so_conf;
813 struct dt_needed needed;
818 struct gld${EMULATION_NAME}_ld_so_conf info;
821 info.len = info.alloc = 0;
822 tmppath = concat (ld_sysroot, "${prefix}/etc/ld.so.conf",
823 (const char *) NULL);
824 if (!gld${EMULATION_NAME}_parse_ld_so_conf (&info, tmppath))
827 tmppath = concat (ld_sysroot, "/etc/ld.so.conf",
828 (const char *) NULL);
829 gld${EMULATION_NAME}_parse_ld_so_conf (&info, tmppath);
835 char *d = gld${EMULATION_NAME}_add_sysroot (info.path);
842 if (ld_so_conf == NULL)
847 needed.name = l->name;
848 return gld${EMULATION_NAME}_search_needed (ld_so_conf, &needed, force);
858 /* See if an input file matches a DT_NEEDED entry by name. */
861 gld${EMULATION_NAME}_check_needed (lang_input_statement_type *s)
865 /* Stop looking if we've found a loaded lib. */
866 if (global_found != NULL
867 && (bfd_elf_get_dyn_lib_class (global_found->the_bfd)
868 & DYN_AS_NEEDED) == 0)
871 if (s->filename == NULL || s->the_bfd == NULL)
874 /* Don't look for a second non-loaded as-needed lib. */
875 if (global_found != NULL
876 && (bfd_elf_get_dyn_lib_class (s->the_bfd) & DYN_AS_NEEDED) != 0)
879 if (filename_cmp (s->filename, global_needed->name) == 0)
885 if (s->flags.search_dirs)
887 const char *f = strrchr (s->filename, '/');
889 && filename_cmp (f + 1, global_needed->name) == 0)
896 soname = bfd_elf_get_dt_soname (s->the_bfd);
898 && filename_cmp (soname, global_needed->name) == 0)
907 if test x"$LDEMUL_AFTER_OPEN" != xgld"$EMULATION_NAME"_after_open; then
911 id_note_section_size (bfd *abfd ATTRIBUTE_UNUSED)
913 const char *style = emit_note_gnu_build_id;
915 bfd_size_type build_id_size;
917 size = offsetof (Elf_External_Note, name[sizeof "GNU"]);
918 size = (size + 3) & -(bfd_size_type) 4;
920 build_id_size = compute_build_id_size (style);
922 size += build_id_size;
930 write_build_id (bfd *abfd)
932 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
933 struct elf_obj_tdata *t = elf_tdata (abfd);
936 Elf_Internal_Shdr *i_shdr;
937 unsigned char *contents, *id_bits;
940 Elf_External_Note *e_note;
942 style = t->o->build_id.style;
943 asec = t->o->build_id.sec;
944 if (bfd_is_abs_section (asec->output_section))
946 einfo (_("%P: warning: .note.gnu.build-id section discarded,"
947 " --build-id ignored.\n"));
950 i_shdr = &elf_section_data (asec->output_section)->this_hdr;
952 if (i_shdr->contents == NULL)
954 if (asec->contents == NULL)
955 asec->contents = (unsigned char *) xmalloc (asec->size);
956 contents = asec->contents;
959 contents = i_shdr->contents + asec->output_offset;
961 e_note = (Elf_External_Note *) contents;
962 size = offsetof (Elf_External_Note, name[sizeof "GNU"]);
963 size = (size + 3) & -(bfd_size_type) 4;
964 id_bits = contents + size;
965 size = asec->size - size;
967 bfd_h_put_32 (abfd, sizeof "GNU", &e_note->namesz);
968 bfd_h_put_32 (abfd, size, &e_note->descsz);
969 bfd_h_put_32 (abfd, NT_GNU_BUILD_ID, &e_note->type);
970 memcpy (e_note->name, "GNU", sizeof "GNU");
972 generate_build_id (abfd, style, bed->s->checksum_contents, id_bits, size);
974 position = i_shdr->sh_offset + asec->output_offset;
976 return (bfd_seek (abfd, position, SEEK_SET) == 0
977 && bfd_bwrite (contents, size, abfd) == size);
980 /* Make .note.gnu.build-id section, and set up elf_tdata->build_id. */
983 setup_build_id (bfd *ibfd)
989 size = id_note_section_size (ibfd);
992 einfo ("%P: warning: unrecognized --build-id style ignored.\n");
996 flags = (SEC_ALLOC | SEC_LOAD | SEC_IN_MEMORY
997 | SEC_LINKER_CREATED | SEC_READONLY | SEC_DATA);
998 s = bfd_make_section_with_flags (ibfd, ".note.gnu.build-id", flags);
999 if (s != NULL && bfd_set_section_alignment (ibfd, s, 2))
1001 struct elf_obj_tdata *t = elf_tdata (link_info.output_bfd);
1002 t->o->build_id.after_write_object_contents = &write_build_id;
1003 t->o->build_id.style = emit_note_gnu_build_id;
1004 t->o->build_id.sec = s;
1005 elf_section_type (s) = SHT_NOTE;
1010 einfo ("%P: warning: Cannot create .note.gnu.build-id section,"
1011 " --build-id ignored.\n");
1015 /* This is called after all the input files have been opened. */
1018 gld${EMULATION_NAME}_after_open (void)
1020 struct bfd_link_needed_list *needed, *l;
1021 struct elf_link_hash_table *htab;
1023 after_open_default ();
1025 htab = elf_hash_table (&link_info);
1026 if (!is_elf_hash_table (htab))
1029 if (link_info.check_relocs_after_open_input)
1033 for (abfd = link_info.input_bfds;
1034 abfd != (bfd *) NULL; abfd = abfd->link.next)
1035 if (!_bfd_elf_link_check_relocs (abfd, &link_info))
1037 /* no object output, fail return */
1038 config.make_executable = FALSE;
1043 if (emit_note_gnu_build_id != NULL)
1047 /* Find an ELF input. */
1048 for (abfd = link_info.input_bfds;
1049 abfd != (bfd *) NULL; abfd = abfd->link.next)
1050 if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
1051 && bfd_count_sections (abfd) != 0)
1054 /* PR 10555: If there are no ELF input files do not try to
1055 create a .note.gnu-build-id section. */
1057 || !setup_build_id (abfd))
1059 free ((char *) emit_note_gnu_build_id);
1060 emit_note_gnu_build_id = NULL;
1064 if (bfd_link_relocatable (&link_info))
1066 if (link_info.execstack == ! link_info.noexecstack)
1067 /* PR ld/16744: If "-z [no]execstack" has been specified on the
1068 command line and we are perfoming a relocatable link then no
1069 PT_GNU_STACK segment will be created and so the
1070 linkinfo.[no]execstack values set in _handle_option() will have no
1071 effect. Instead we create a .note.GNU-stack section in much the
1072 same way as the assembler does with its --[no]execstack option. */
1073 (void) bfd_make_section_with_flags (link_info.input_bfds,
1075 SEC_READONLY | (link_info.execstack ? SEC_CODE : 0));
1080 if (!link_info.traditional_format)
1082 bfd *abfd, *elfbfd = NULL;
1083 bfd_boolean warn_eh_frame = FALSE;
1087 for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
1090 for (s = abfd->sections; s && type < COMPACT_EH_HDR; s = s->next)
1092 const char *name = bfd_get_section_name (abfd, s);
1094 if (bfd_is_abs_section (s->output_section))
1096 if (CONST_STRNEQ (name, ".eh_frame_entry"))
1097 type = COMPACT_EH_HDR;
1098 else if (strcmp (name, ".eh_frame") == 0 && s->size > 8)
1099 type = DWARF2_EH_HDR;
1108 else if (seen_type != type)
1110 einfo (_("%P%F: compact frame descriptions incompatible with"
1111 " DWARF2 .eh_frame from %B\n"),
1112 type == DWARF2_EH_HDR ? abfd : elfbfd);
1117 && (type == COMPACT_EH_HDR || link_info.eh_frame_hdr_type != 0))
1119 if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
1122 warn_eh_frame = TRUE;
1126 if (seen_type == COMPACT_EH_HDR)
1127 link_info.eh_frame_hdr_type = COMPACT_EH_HDR;
1129 if (bfd_count_sections (abfd) == 0)
1134 const struct elf_backend_data *bed;
1136 bed = get_elf_backend_data (elfbfd);
1137 s = bfd_make_section_with_flags (elfbfd, ".eh_frame_hdr",
1138 bed->dynamic_sec_flags
1141 && bfd_set_section_alignment (elfbfd, s, 2))
1143 htab->eh_info.hdr_sec = s;
1144 warn_eh_frame = FALSE;
1148 einfo ("%P: warning: Cannot create .eh_frame_hdr section,"
1149 " --eh-frame-hdr ignored.\n");
1152 /* Get the list of files which appear in DT_NEEDED entries in
1153 dynamic objects included in the link (often there will be none).
1154 For each such file, we want to track down the corresponding
1155 library, and include the symbol table in the link. This is what
1156 the runtime dynamic linker will do. Tracking the files down here
1157 permits one dynamic object to include another without requiring
1158 special action by the person doing the link. Note that the
1159 needed list can actually grow while we are stepping through this
1161 needed = bfd_elf_get_needed_list (link_info.output_bfd, &link_info);
1162 for (l = needed; l != NULL; l = l->next)
1164 struct bfd_link_needed_list *ll;
1165 struct dt_needed n, nn;
1168 /* If the lib that needs this one was --as-needed and wasn't
1169 found to be needed, then this lib isn't needed either. */
1171 && (bfd_elf_get_dyn_lib_class (l->by) & DYN_AS_NEEDED) != 0)
1174 /* Skip the lib if --no-copy-dt-needed-entries and
1175 --allow-shlib-undefined is in effect. */
1177 && link_info.unresolved_syms_in_shared_libs == RM_IGNORE
1178 && (bfd_elf_get_dyn_lib_class (l->by) & DYN_NO_ADD_NEEDED) != 0)
1181 /* If we've already seen this file, skip it. */
1182 for (ll = needed; ll != l; ll = ll->next)
1184 || (bfd_elf_get_dyn_lib_class (ll->by) & DYN_AS_NEEDED) == 0)
1185 && strcmp (ll->name, l->name) == 0)
1190 /* See if this file was included in the link explicitly. */
1192 global_found = NULL;
1193 lang_for_each_input_file (gld${EMULATION_NAME}_check_needed);
1194 if (global_found != NULL
1195 && (bfd_elf_get_dyn_lib_class (global_found->the_bfd)
1196 & DYN_AS_NEEDED) == 0)
1203 info_msg (_("%s needed by %B\n"), l->name, l->by);
1205 /* As-needed libs specified on the command line (or linker script)
1206 take priority over libs found in search dirs. */
1207 if (global_found != NULL)
1209 nn.name = global_found->filename;
1210 if (gld${EMULATION_NAME}_try_needed (&nn, TRUE))
1214 /* We need to find this file and include the symbol table. We
1215 want to search for the file in the same way that the dynamic
1216 linker will search. That means that we want to use
1217 rpath_link, rpath, then the environment variable
1218 LD_LIBRARY_PATH (native only), then the DT_RPATH/DT_RUNPATH
1219 entries (native only), then the linker script LIB_SEARCH_DIRS.
1220 We do not search using the -L arguments.
1222 We search twice. The first time, we skip objects which may
1223 introduce version mismatches. The second time, we force
1224 their use. See gld${EMULATION_NAME}_vercheck comment. */
1225 for (force = 0; force < 2; force++)
1228 search_dirs_type *search;
1230 if [ "x${NATIVE}" = xyes ] ; then
1232 const char *lib_path;
1235 if [ "x${USE_LIBPATH}" = xyes ] ; then
1237 struct bfd_link_needed_list *rp;
1243 if (gld${EMULATION_NAME}_search_needed (command_line.rpath_link,
1247 if [ "x${USE_LIBPATH}" = xyes ] ; then
1249 if (gld${EMULATION_NAME}_search_needed (command_line.rpath,
1254 if [ "x${NATIVE}" = xyes ] ; then
1256 if (command_line.rpath_link == NULL
1257 && command_line.rpath == NULL)
1259 lib_path = (const char *) getenv ("LD_RUN_PATH");
1260 if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
1264 lib_path = (const char *) getenv ("LD_LIBRARY_PATH");
1265 if (gld${EMULATION_NAME}_search_needed (lib_path, &n, force))
1269 if [ "x${USE_LIBPATH}" = xyes ] ; then
1272 rp = bfd_elf_get_runpath_list (link_info.output_bfd, &link_info);
1273 for (; !found && rp != NULL; rp = rp->next)
1275 const char *tmpname = rp->name;
1277 if (IS_ABSOLUTE_PATH (tmpname))
1278 tmpname = gld${EMULATION_NAME}_add_sysroot (tmpname);
1279 found = (rp->by == l->by
1280 && gld${EMULATION_NAME}_search_needed (tmpname,
1283 if (tmpname != rp->name)
1284 free ((char *) tmpname);
1291 if [ "x${USE_LIBPATH}" = xyes ] ; then
1293 *-*-freebsd* | *-*-dragonfly*)
1295 if (gld${EMULATION_NAME}_check_ld_elf_hints (l, force))
1301 *-*-linux-* | *-*-k*bsd*-* | *-*-gnu*)
1303 if (gld${EMULATION_NAME}_check_ld_so_conf (l, force))
1312 len = strlen (l->name);
1313 for (search = search_head; search != NULL; search = search->next)
1317 if (search->cmdline)
1319 filename = (char *) xmalloc (strlen (search->name) + len + 2);
1320 sprintf (filename, "%s/%s", search->name, l->name);
1322 if (gld${EMULATION_NAME}_try_needed (&nn, force))
1335 einfo ("%P: warning: %s, needed by %B, not found (try using -rpath or -rpath-link)\n",
1339 if (link_info.eh_frame_hdr_type == COMPACT_EH_HDR)
1340 if (bfd_elf_parse_eh_frame_entries (NULL, &link_info) == FALSE)
1341 einfo (_("%P%F: Failed to parse EH frame entries.\n"));
1349 /* Look through an expression for an assignment statement. */
1352 gld${EMULATION_NAME}_find_exp_assignment (etree_type *exp)
1354 bfd_boolean provide = FALSE;
1356 switch (exp->type.node_class)
1359 case etree_provided:
1363 /* We call record_link_assignment even if the symbol is defined.
1364 This is because if it is defined by a dynamic object, we
1365 actually want to use the value defined by the linker script,
1366 not the value from the dynamic object (because we are setting
1367 symbols like etext). If the symbol is defined by a regular
1368 object, then, as it happens, calling record_link_assignment
1370 if (strcmp (exp->assign.dst, ".") != 0)
1372 if (!bfd_elf_record_link_assignment (link_info.output_bfd,
1374 exp->assign.dst, provide,
1375 exp->assign.hidden))
1376 einfo ("%P%F: failed to record assignment to %s: %E\n",
1379 gld${EMULATION_NAME}_find_exp_assignment (exp->assign.src);
1383 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.lhs);
1384 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.rhs);
1388 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.cond);
1389 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.lhs);
1390 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.rhs);
1394 gld${EMULATION_NAME}_find_exp_assignment (exp->unary.child);
1403 /* This is called by the before_allocation routine via
1404 lang_for_each_statement. It locates any assignment statements, and
1405 tells the ELF backend about them, in case they are assignments to
1406 symbols which are referred to by dynamic objects. */
1409 gld${EMULATION_NAME}_find_statement_assignment (lang_statement_union_type *s)
1411 if (s->header.type == lang_assignment_statement_enum)
1412 gld${EMULATION_NAME}_find_exp_assignment (s->assignment_statement.exp);
1417 if test x"$LDEMUL_BEFORE_ALLOCATION" != xgld"$EMULATION_NAME"_before_allocation; then
1418 if test x"${ELF_INTERPRETER_NAME+set}" = xset; then
1419 ELF_INTERPRETER_SET_DEFAULT="
1420 if (sinterp != NULL)
1422 sinterp->contents = (unsigned char *) ${ELF_INTERPRETER_NAME};
1423 sinterp->size = strlen ((char *) sinterp->contents) + 1;
1428 ELF_INTERPRETER_SET_DEFAULT=
1432 /* used by before_allocation and handle_option. */
1434 gld${EMULATION_NAME}_append_to_separated_string (char **to, char *op_arg)
1437 *to = xstrdup (op_arg);
1440 size_t to_len = strlen (*to);
1441 size_t op_arg_len = strlen (op_arg);
1445 /* First see whether OPTARG is already in the path. */
1448 if (strncmp (op_arg, cp, op_arg_len) == 0
1449 && (cp[op_arg_len] == 0
1450 || cp[op_arg_len] == config.rpath_separator))
1454 /* Not yet found. */
1455 cp = strchr (cp, config.rpath_separator);
1463 buf = xmalloc (to_len + op_arg_len + 2);
1464 sprintf (buf, "%s%c%s", *to,
1465 config.rpath_separator, op_arg);
1472 #if defined(__GNUC__) && GCC_VERSION < 4006
1473 /* Work around a GCC uninitialized warning bug fixed in GCC 4.6. */
1474 static struct bfd_link_hash_entry ehdr_start_empty;
1477 /* This is called after the sections have been attached to output
1478 sections, but before any sizes or addresses have been set. */
1481 gld${EMULATION_NAME}_before_allocation (void)
1486 struct elf_link_hash_entry *ehdr_start = NULL;
1487 #if defined(__GNUC__) && GCC_VERSION < 4006
1488 /* Work around a GCC uninitialized warning bug fixed in GCC 4.6. */
1489 struct bfd_link_hash_entry ehdr_start_save = ehdr_start_empty;
1491 struct bfd_link_hash_entry ehdr_start_save;
1494 if (is_elf_hash_table (link_info.hash))
1496 _bfd_elf_tls_setup (link_info.output_bfd, &link_info);
1498 /* Make __ehdr_start hidden if it has been referenced, to
1499 prevent the symbol from being dynamic. */
1500 if (!bfd_link_relocatable (&link_info))
1502 struct elf_link_hash_entry *h
1503 = elf_link_hash_lookup (elf_hash_table (&link_info), "__ehdr_start",
1504 FALSE, FALSE, TRUE);
1506 /* Only adjust the export class if the symbol was referenced
1507 and not defined, otherwise leave it alone. */
1509 && (h->root.type == bfd_link_hash_new
1510 || h->root.type == bfd_link_hash_undefined
1511 || h->root.type == bfd_link_hash_undefweak
1512 || h->root.type == bfd_link_hash_common))
1514 _bfd_elf_link_hash_hide_symbol (&link_info, h, TRUE);
1515 if (ELF_ST_VISIBILITY (h->other) != STV_INTERNAL)
1516 h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN;
1517 /* Don't leave the symbol undefined. Undefined hidden
1518 symbols typically won't have dynamic relocations, but
1519 we most likely will need dynamic relocations for
1520 __ehdr_start if we are building a PIE or shared
1523 ehdr_start_save = h->root;
1524 h->root.type = bfd_link_hash_defined;
1525 h->root.u.def.section = bfd_abs_section_ptr;
1526 h->root.u.def.value = 0;
1530 /* If we are going to make any variable assignments, we need to
1531 let the ELF backend know about them in case the variables are
1532 referred to by dynamic objects. */
1533 lang_for_each_statement (gld${EMULATION_NAME}_find_statement_assignment);
1536 /* Let the ELF backend work out the sizes of any sections required
1537 by dynamic linking. */
1538 rpath = command_line.rpath;
1540 rpath = (const char *) getenv ("LD_RUN_PATH");
1542 for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
1543 if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
1545 const char *audit_libs = elf_dt_audit (abfd);
1547 /* If the input bfd contains an audit entry, we need to add it as
1548 a dep audit entry. */
1549 if (audit_libs && *audit_libs != '\0')
1551 char *cp = xstrdup (audit_libs);
1555 char *cp2 = strchr (cp, config.rpath_separator);
1563 if (cp != NULL && *cp != '\0')
1564 gld${EMULATION_NAME}_append_to_separated_string (&depaudit, cp);
1566 cp = more ? ++cp2 : NULL;
1572 if (! (bfd_elf_size_dynamic_sections
1573 (link_info.output_bfd, command_line.soname, rpath,
1574 command_line.filter_shlib, audit, depaudit,
1575 (const char * const *) command_line.auxiliary_filters,
1576 &link_info, &sinterp)))
1577 einfo ("%P%F: failed to set dynamic section sizes: %E\n");
1579 ${ELF_INTERPRETER_SET_DEFAULT}
1580 /* Let the user override the dynamic linker we are using. */
1581 if (command_line.interpreter != NULL
1584 sinterp->contents = (bfd_byte *) command_line.interpreter;
1585 sinterp->size = strlen (command_line.interpreter) + 1;
1588 /* Look for any sections named .gnu.warning. As a GNU extensions,
1589 we treat such sections as containing warning messages. We print
1590 out the warning message, and then zero out the section size so
1591 that it does not get copied into the output file. */
1594 LANG_FOR_EACH_INPUT_STATEMENT (is)
1601 if (is->flags.just_syms)
1604 s = bfd_get_section_by_name (is->the_bfd, ".gnu.warning");
1609 msg = (char *) xmalloc ((size_t) (sz + 1));
1610 if (! bfd_get_section_contents (is->the_bfd, s, msg,
1612 einfo ("%F%B: Can't read contents of section .gnu.warning: %E\n",
1615 ret = link_info.callbacks->warning (&link_info, msg,
1616 (const char *) NULL,
1617 is->the_bfd, (asection *) NULL,
1622 /* Clobber the section size, so that we don't waste space
1623 copying the warning into the output file. If we've already
1624 sized the output section, adjust its size. The adjustment
1625 is on rawsize because targets that size sections early will
1626 have called lang_reset_memory_regions after sizing. */
1627 if (s->output_section != NULL
1628 && s->output_section->rawsize >= s->size)
1629 s->output_section->rawsize -= s->size;
1633 /* Also set SEC_EXCLUDE, so that local symbols defined in the
1634 warning section don't get copied to the output. */
1635 s->flags |= SEC_EXCLUDE | SEC_KEEP;
1639 before_allocation_default ();
1641 if (!bfd_elf_size_dynsym_hash_dynstr (link_info.output_bfd, &link_info))
1642 einfo ("%P%F: failed to set dynamic section sizes: %E\n");
1644 if (ehdr_start != NULL)
1646 /* If we twiddled __ehdr_start to defined earlier, put it back
1648 ehdr_start->root.type = ehdr_start_save.type;
1649 ehdr_start->root.u = ehdr_start_save.u;
1656 if test x"$LDEMUL_OPEN_DYNAMIC_ARCHIVE" != xgld"$EMULATION_NAME"_open_dynamic_archive; then
1659 /* Try to open a dynamic archive. This is where we know that ELF
1660 dynamic libraries have an extension of .so (or .sl on oddball systems
1664 gld${EMULATION_NAME}_open_dynamic_archive
1665 (const char *arch, search_dirs_type *search, lang_input_statement_type *entry)
1667 const char *filename;
1670 bfd_boolean opened = FALSE;
1672 if (! entry->flags.maybe_archive)
1675 filename = entry->filename;
1676 len = strlen (search->name) + strlen (filename);
1677 if (entry->flags.full_name_provided)
1680 string = (char *) xmalloc (len);
1681 sprintf (string, "%s/%s", search->name, filename);
1687 len += strlen (arch) + sizeof "/lib.so";
1688 #ifdef EXTRA_SHLIB_EXTENSION
1689 xlen = (strlen (EXTRA_SHLIB_EXTENSION) > 3
1690 ? strlen (EXTRA_SHLIB_EXTENSION) - 3
1693 string = (char *) xmalloc (len + xlen);
1694 sprintf (string, "%s/lib%s%s.so", search->name, filename, arch);
1695 #ifdef EXTRA_SHLIB_EXTENSION
1696 /* Try the .so extension first. If that fails build a new filename
1697 using EXTRA_SHLIB_EXTENSION. */
1698 opened = ldfile_try_open_bfd (string, entry);
1700 strcpy (string + len - 4, EXTRA_SHLIB_EXTENSION);
1704 if (!opened && !ldfile_try_open_bfd (string, entry))
1710 entry->filename = string;
1712 /* We have found a dynamic object to include in the link. The ELF
1713 backend linker will create a DT_NEEDED entry in the .dynamic
1714 section naming this file. If this file includes a DT_SONAME
1715 entry, it will be used. Otherwise, the ELF linker will just use
1716 the name of the file. For an archive found by searching, like
1717 this one, the DT_NEEDED entry should consist of just the name of
1718 the file, without the path information used to find it. Note
1719 that we only need to do this if we have a dynamic object; an
1720 archive will never be referenced by a DT_NEEDED entry.
1722 FIXME: This approach--using bfd_elf_set_dt_needed_name--is not
1723 very pretty. I haven't been able to think of anything that is
1725 if (bfd_check_format (entry->the_bfd, bfd_object)
1726 && (entry->the_bfd->flags & DYNAMIC) != 0)
1728 ASSERT (entry->flags.maybe_archive && entry->flags.search_dirs);
1730 /* Rather than duplicating the logic above. Just use the
1731 filename we recorded earlier. */
1733 if (!entry->flags.full_name_provided)
1734 filename = lbasename (entry->filename);
1735 bfd_elf_set_dt_needed_name (entry->the_bfd, filename);
1744 if test x"$LDEMUL_PLACE_ORPHAN" != xgld"$EMULATION_NAME"_place_orphan; then
1747 /* A variant of lang_output_section_find used by place_orphan. */
1749 static lang_output_section_statement_type *
1750 output_rel_find (asection *sec, int isdyn)
1752 lang_output_section_statement_type *lookup;
1753 lang_output_section_statement_type *last = NULL;
1754 lang_output_section_statement_type *last_alloc = NULL;
1755 lang_output_section_statement_type *last_ro_alloc = NULL;
1756 lang_output_section_statement_type *last_rel = NULL;
1757 lang_output_section_statement_type *last_rel_alloc = NULL;
1758 int rela = sec->name[4] == 'a';
1760 for (lookup = &lang_output_section_statement.head->output_section_statement;
1762 lookup = lookup->next)
1764 if (lookup->constraint >= 0
1765 && CONST_STRNEQ (lookup->name, ".rel"))
1767 int lookrela = lookup->name[4] == 'a';
1769 /* .rel.dyn must come before all other reloc sections, to suit
1774 /* Don't place after .rel.plt as doing so results in wrong
1776 if (strcmp (".plt", lookup->name + 4 + lookrela) == 0)
1779 if (rela == lookrela || last_rel == NULL)
1781 if ((rela == lookrela || last_rel_alloc == NULL)
1782 && lookup->bfd_section != NULL
1783 && (lookup->bfd_section->flags & SEC_ALLOC) != 0)
1784 last_rel_alloc = lookup;
1788 if (lookup->bfd_section != NULL
1789 && (lookup->bfd_section->flags & SEC_ALLOC) != 0)
1791 last_alloc = lookup;
1792 if ((lookup->bfd_section->flags & SEC_READONLY) != 0)
1793 last_ro_alloc = lookup;
1798 return last_rel_alloc;
1804 return last_ro_alloc;
1812 /* Place an orphan section. We use this to put random SHF_ALLOC
1813 sections in the right segment. */
1815 static lang_output_section_statement_type *
1816 gld${EMULATION_NAME}_place_orphan (asection *s,
1817 const char *secname,
1820 static struct orphan_save hold[] =
1823 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE,
1826 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA,
1829 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_THREAD_LOCAL,
1832 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_DATA,
1838 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA,
1841 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA,
1844 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_SMALL_DATA,
1850 enum orphan_save_index
1862 static int orphan_init_done = 0;
1863 struct orphan_save *place;
1864 lang_output_section_statement_type *after;
1865 lang_output_section_statement_type *os;
1866 lang_output_section_statement_type *match_by_name = NULL;
1868 int iself = s->owner->xvec->flavour == bfd_target_elf_flavour;
1869 unsigned int sh_type = iself ? elf_section_type (s) : SHT_NULL;
1873 if (!bfd_link_relocatable (&link_info)
1874 && link_info.combreloc
1875 && (s->flags & SEC_ALLOC))
1881 secname = ".rela.dyn";
1885 secname = ".rel.dyn";
1891 else if (CONST_STRNEQ (secname, ".rel"))
1893 secname = secname[4] == 'a' ? ".rela.dyn" : ".rel.dyn";
1898 /* Look through the script to see where to place this section. */
1899 if (constraint == 0)
1900 for (os = lang_output_section_find (secname);
1902 os = next_matching_output_section_statement (os, 0))
1904 /* If we don't match an existing output section, tell
1905 lang_insert_orphan to create a new output section. */
1906 constraint = SPECIAL;
1908 if (os->bfd_section != NULL
1909 && (os->bfd_section->flags == 0
1910 || (((s->flags ^ os->bfd_section->flags)
1911 & (SEC_LOAD | SEC_ALLOC)) == 0
1912 && _bfd_elf_match_sections_by_type (link_info.output_bfd,
1916 /* We already have an output section statement with this
1917 name, and its bfd section has compatible flags.
1918 If the section already exists but does not have any flags
1919 set, then it has been created by the linker, probably as a
1920 result of a --section-start command line switch. */
1921 lang_add_section (&os->children, s, NULL, os);
1925 /* Save unused output sections in case we can match them
1926 against orphans later. */
1927 if (os->bfd_section == NULL)
1931 /* If we didn't match an active output section, see if we matched an
1932 unused one and use that. */
1935 lang_add_section (&match_by_name->children, s, NULL, match_by_name);
1936 return match_by_name;
1939 if (!orphan_init_done)
1941 struct orphan_save *ho;
1943 for (ho = hold; ho < hold + sizeof (hold) / sizeof (hold[0]); ++ho)
1944 if (ho->name != NULL)
1946 ho->os = lang_output_section_find (ho->name);
1947 if (ho->os != NULL && ho->os->flags == 0)
1948 ho->os->flags = ho->flags;
1950 orphan_init_done = 1;
1953 /* If this is a final link, then always put .gnu.warning.SYMBOL
1954 sections into the .text section to get them out of the way. */
1955 if (bfd_link_executable (&link_info)
1956 && CONST_STRNEQ (s->name, ".gnu.warning.")
1957 && hold[orphan_text].os != NULL)
1959 os = hold[orphan_text].os;
1960 lang_add_section (&os->children, s, NULL, os);
1965 if (!bfd_link_relocatable (&link_info))
1968 while ((nexts = bfd_get_next_section_by_name (nexts->owner, nexts))
1970 if (nexts->output_section == NULL
1971 && (nexts->flags & SEC_EXCLUDE) == 0
1972 && ((nexts->flags ^ flags) & (SEC_LOAD | SEC_ALLOC)) == 0
1973 && (nexts->owner->flags & DYNAMIC) == 0
1974 && nexts->owner->usrdata != NULL
1975 && !(((lang_input_statement_type *) nexts->owner->usrdata)
1977 && _bfd_elf_match_sections_by_type (nexts->owner, nexts,
1979 flags = (((flags ^ SEC_READONLY)
1980 | (nexts->flags ^ SEC_READONLY))
1984 /* Decide which segment the section should go in based on the
1985 section name and section flags. We put loadable .note sections
1986 right after the .interp section, so that the PT_NOTE segment is
1987 stored right after the program headers where the OS can read it
1988 in the first page. */
1991 if ((flags & (SEC_ALLOC | SEC_DEBUGGING)) == 0)
1992 place = &hold[orphan_nonalloc];
1993 else if ((flags & SEC_ALLOC) == 0)
1995 else if ((flags & SEC_LOAD) != 0
1996 && ((iself && sh_type == SHT_NOTE)
1997 || (!iself && CONST_STRNEQ (secname, ".note"))))
1998 place = &hold[orphan_interp];
1999 else if ((flags & (SEC_LOAD | SEC_HAS_CONTENTS | SEC_THREAD_LOCAL)) == 0)
2000 place = &hold[orphan_bss];
2001 else if ((flags & SEC_SMALL_DATA) != 0)
2002 place = &hold[orphan_sdata];
2003 else if ((flags & SEC_THREAD_LOCAL) != 0)
2004 place = &hold[orphan_tdata];
2005 else if ((flags & SEC_READONLY) == 0)
2006 place = &hold[orphan_data];
2007 else if (((iself && (sh_type == SHT_RELA || sh_type == SHT_REL))
2008 || (!iself && CONST_STRNEQ (secname, ".rel")))
2009 && (flags & SEC_LOAD) != 0)
2010 place = &hold[orphan_rel];
2011 else if ((flags & SEC_CODE) == 0)
2012 place = &hold[orphan_rodata];
2014 place = &hold[orphan_text];
2019 if (place->os == NULL)
2021 if (place->name != NULL)
2022 place->os = lang_output_section_find (place->name);
2024 place->os = output_rel_find (s, isdyn);
2029 = lang_output_section_find_by_flags (s, flags, &place->os,
2030 _bfd_elf_match_sections_by_type);
2032 /* *ABS* is always the first output section statement. */
2033 after = &lang_output_section_statement.head->output_section_statement;
2036 return lang_insert_orphan (s, secname, constraint, after, place, NULL, NULL);
2041 if test x"$LDEMUL_AFTER_ALLOCATION" != xgld"$EMULATION_NAME"_after_allocation; then
2045 gld${EMULATION_NAME}_after_allocation (void)
2047 int need_layout = bfd_elf_discard_info (link_info.output_bfd, &link_info);
2049 if (need_layout < 0)
2050 einfo ("%X%P: .eh_frame/.stab edit: %E\n");
2052 gld${EMULATION_NAME}_map_segments (need_layout);
2057 if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then
2061 gld${EMULATION_NAME}_get_script (int *isfile)
2064 if test x"$COMPILE_IN" = xyes
2066 # Scripts compiled in.
2068 # sed commands to quote an ld script as a C string.
2069 sc="-f stringify.sed"
2075 if (bfd_link_relocatable (&link_info) && config.build_constructors)
2078 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
2079 echo ' ; else if (bfd_link_relocatable (&link_info)) return' >> e${EMULATION_NAME}.c
2080 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
2081 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
2082 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
2083 if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then : ; else
2084 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
2085 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
2087 if test -n "$GENERATE_PIE_SCRIPT" ; then
2088 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
2089 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
2090 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
2091 echo ' && 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}.xdw >> e${EMULATION_NAME}.c
2094 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
2095 echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c
2096 sed $sc ldscripts/${EMULATION_NAME}.xdc >> e${EMULATION_NAME}.c
2098 echo ' ; else if (bfd_link_pie (&link_info)) return' >> e${EMULATION_NAME}.c
2099 sed $sc ldscripts/${EMULATION_NAME}.xd >> e${EMULATION_NAME}.c
2101 if test -n "$GENERATE_SHLIB_SCRIPT" ; then
2102 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
2103 echo ' ; else if (bfd_link_dll (&link_info) && link_info.combreloc' >> e${EMULATION_NAME}.c
2104 echo ' && link_info.relro' >> e${EMULATION_NAME}.c
2105 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
2106 sed $sc ldscripts/${EMULATION_NAME}.xsw >> e${EMULATION_NAME}.c
2107 echo ' ; else if (bfd_link_dll (&link_info) && link_info.combreloc) return' >> e${EMULATION_NAME}.c
2108 sed $sc ldscripts/${EMULATION_NAME}.xsc >> e${EMULATION_NAME}.c
2110 echo ' ; else if (bfd_link_dll (&link_info)) return' >> e${EMULATION_NAME}.c
2111 sed $sc ldscripts/${EMULATION_NAME}.xs >> e${EMULATION_NAME}.c
2113 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
2114 echo ' ; else if (link_info.combreloc && link_info.relro' >> e${EMULATION_NAME}.c
2115 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
2116 sed $sc ldscripts/${EMULATION_NAME}.xw >> e${EMULATION_NAME}.c
2117 echo ' ; else if (link_info.combreloc) return' >> e${EMULATION_NAME}.c
2118 sed $sc ldscripts/${EMULATION_NAME}.xc >> e${EMULATION_NAME}.c
2120 echo ' ; else return' >> e${EMULATION_NAME}.c
2121 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
2122 echo '; }' >> e${EMULATION_NAME}.c
2125 # Scripts read from the filesystem.
2131 if (bfd_link_relocatable (&link_info) && config.build_constructors)
2132 return "ldscripts/${EMULATION_NAME}.xu";
2133 else if (bfd_link_relocatable (&link_info))
2134 return "ldscripts/${EMULATION_NAME}.xr";
2135 else if (!config.text_read_only)
2136 return "ldscripts/${EMULATION_NAME}.xbn";
2138 if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then :
2141 else if (!config.magic_demand_paged)
2142 return "ldscripts/${EMULATION_NAME}.xn";
2145 if test -n "$GENERATE_PIE_SCRIPT" ; then
2146 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
2148 else if (bfd_link_pie (&link_info)
2149 && link_info.combreloc
2151 && (link_info.flags & DF_BIND_NOW))
2152 return "ldscripts/${EMULATION_NAME}.xdw";
2153 else if (bfd_link_pie (&link_info)
2154 && link_info.combreloc)
2155 return "ldscripts/${EMULATION_NAME}.xdc";
2159 else if (bfd_link_pie (&link_info))
2160 return "ldscripts/${EMULATION_NAME}.xd";
2163 if test -n "$GENERATE_SHLIB_SCRIPT" ; then
2164 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
2166 else if (bfd_link_dll (&link_info) && link_info.combreloc
2167 && link_info.relro && (link_info.flags & DF_BIND_NOW))
2168 return "ldscripts/${EMULATION_NAME}.xsw";
2169 else if (bfd_link_dll (&link_info) && link_info.combreloc)
2170 return "ldscripts/${EMULATION_NAME}.xsc";
2174 else if (bfd_link_dll (&link_info))
2175 return "ldscripts/${EMULATION_NAME}.xs";
2178 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
2180 else if (link_info.combreloc && link_info.relro
2181 && (link_info.flags & DF_BIND_NOW))
2182 return "ldscripts/${EMULATION_NAME}.xw";
2183 else if (link_info.combreloc)
2184 return "ldscripts/${EMULATION_NAME}.xc";
2189 return "ldscripts/${EMULATION_NAME}.x";
2196 if test -n "$PARSE_AND_LIST_PROLOGUE" ; then
2198 $PARSE_AND_LIST_PROLOGUE
2204 #define OPTION_DISABLE_NEW_DTAGS (400)
2205 #define OPTION_ENABLE_NEW_DTAGS (OPTION_DISABLE_NEW_DTAGS + 1)
2206 #define OPTION_GROUP (OPTION_ENABLE_NEW_DTAGS + 1)
2207 #define OPTION_EH_FRAME_HDR (OPTION_GROUP + 1)
2208 #define OPTION_EXCLUDE_LIBS (OPTION_EH_FRAME_HDR + 1)
2209 #define OPTION_HASH_STYLE (OPTION_EXCLUDE_LIBS + 1)
2210 #define OPTION_BUILD_ID (OPTION_HASH_STYLE + 1)
2211 #define OPTION_AUDIT (OPTION_BUILD_ID + 1)
2212 #define OPTION_COMPRESS_DEBUG (OPTION_AUDIT + 1)
2215 gld${EMULATION_NAME}_add_options
2216 (int ns, char **shortopts, int nl, struct option **longopts,
2217 int nrl ATTRIBUTE_UNUSED, struct option **really_longopts ATTRIBUTE_UNUSED)
2220 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
2222 static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:P:";
2226 static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:";
2230 static const struct option xtra_long[] = {
2232 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
2234 {"audit", required_argument, NULL, OPTION_AUDIT},
2235 {"Bgroup", no_argument, NULL, OPTION_GROUP},
2239 {"build-id", optional_argument, NULL, OPTION_BUILD_ID},
2240 {"compress-debug-sections", required_argument, NULL, OPTION_COMPRESS_DEBUG},
2242 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
2244 {"depaudit", required_argument, NULL, 'P'},
2245 {"disable-new-dtags", no_argument, NULL, OPTION_DISABLE_NEW_DTAGS},
2246 {"enable-new-dtags", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS},
2247 {"eh-frame-hdr", no_argument, NULL, OPTION_EH_FRAME_HDR},
2248 {"exclude-libs", required_argument, NULL, OPTION_EXCLUDE_LIBS},
2249 {"hash-style", required_argument, NULL, OPTION_HASH_STYLE},
2252 if test -n "$PARSE_AND_LIST_LONGOPTS" ; then
2254 $PARSE_AND_LIST_LONGOPTS
2258 {NULL, no_argument, NULL, 0}
2261 *shortopts = (char *) xrealloc (*shortopts, ns + sizeof (xtra_short));
2262 memcpy (*shortopts + ns, &xtra_short, sizeof (xtra_short));
2263 *longopts = (struct option *)
2264 xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
2265 memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
2268 #define DEFAULT_BUILD_ID_STYLE "sha1"
2271 gld${EMULATION_NAME}_handle_option (int optc)
2278 case OPTION_BUILD_ID:
2279 if (emit_note_gnu_build_id != NULL)
2281 free ((char *) emit_note_gnu_build_id);
2282 emit_note_gnu_build_id = NULL;
2285 optarg = DEFAULT_BUILD_ID_STYLE;
2286 if (strcmp (optarg, "none"))
2287 emit_note_gnu_build_id = xstrdup (optarg);
2290 case OPTION_COMPRESS_DEBUG:
2291 if (strcasecmp (optarg, "none") == 0)
2292 link_info.compress_debug = COMPRESS_DEBUG_NONE;
2293 else if (strcasecmp (optarg, "zlib") == 0)
2294 link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB;
2295 else if (strcasecmp (optarg, "zlib-gnu") == 0)
2296 link_info.compress_debug = COMPRESS_DEBUG_GNU_ZLIB;
2297 else if (strcasecmp (optarg, "zlib-gabi") == 0)
2298 link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB;
2300 einfo (_("%P%F: invalid --compress-debug-sections option: \`%s'\n"),
2305 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
2308 gld${EMULATION_NAME}_append_to_separated_string (&audit, optarg);
2312 gld${EMULATION_NAME}_append_to_separated_string (&depaudit, optarg);
2315 case OPTION_DISABLE_NEW_DTAGS:
2316 link_info.new_dtags = FALSE;
2319 case OPTION_ENABLE_NEW_DTAGS:
2320 link_info.new_dtags = TRUE;
2323 case OPTION_EH_FRAME_HDR:
2324 link_info.eh_frame_hdr_type = DWARF2_EH_HDR;
2328 link_info.flags_1 |= (bfd_vma) DF_1_GROUP;
2329 /* Groups must be self-contained. */
2330 link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
2331 link_info.unresolved_syms_in_shared_libs = RM_GENERATE_ERROR;
2334 case OPTION_EXCLUDE_LIBS:
2335 add_excluded_libs (optarg);
2338 case OPTION_HASH_STYLE:
2339 link_info.emit_hash = FALSE;
2340 link_info.emit_gnu_hash = FALSE;
2341 if (strcmp (optarg, "sysv") == 0)
2342 link_info.emit_hash = TRUE;
2343 else if (strcmp (optarg, "gnu") == 0)
2344 link_info.emit_gnu_hash = TRUE;
2345 else if (strcmp (optarg, "both") == 0)
2347 link_info.emit_hash = TRUE;
2348 link_info.emit_gnu_hash = TRUE;
2351 einfo (_("%P%F: invalid hash style \`%s'\n"), optarg);
2358 if (strcmp (optarg, "defs") == 0)
2359 link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
2360 else if (strcmp (optarg, "muldefs") == 0)
2361 link_info.allow_multiple_definition = TRUE;
2362 else if (CONST_STRNEQ (optarg, "max-page-size="))
2366 config.maxpagesize = strtoul (optarg + 14, &end, 0);
2367 if (*end || (config.maxpagesize & (config.maxpagesize - 1)) != 0)
2368 einfo (_("%P%F: invalid maxium page size \`%s'\n"),
2371 else if (CONST_STRNEQ (optarg, "common-page-size="))
2374 config.commonpagesize = strtoul (optarg + 17, &end, 0);
2376 || (config.commonpagesize & (config.commonpagesize - 1)) != 0)
2377 einfo (_("%P%F: invalid common page size \`%s'\n"),
2380 else if (CONST_STRNEQ (optarg, "stack-size="))
2383 link_info.stacksize = strtoul (optarg + 11, &end, 0);
2384 if (*end || link_info.stacksize < 0)
2385 einfo (_("%P%F: invalid stack size \`%s'\n"), optarg + 11);
2386 if (!link_info.stacksize)
2387 /* Use -1 for explicit no-stack, because zero means
2389 link_info.stacksize = -1;
2391 else if (strcmp (optarg, "execstack") == 0)
2393 link_info.execstack = TRUE;
2394 link_info.noexecstack = FALSE;
2396 else if (strcmp (optarg, "noexecstack") == 0)
2398 link_info.noexecstack = TRUE;
2399 link_info.execstack = FALSE;
2403 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
2405 else if (strcmp (optarg, "global") == 0)
2406 link_info.flags_1 |= (bfd_vma) DF_1_GLOBAL;
2407 else if (strcmp (optarg, "initfirst") == 0)
2408 link_info.flags_1 |= (bfd_vma) DF_1_INITFIRST;
2409 else if (strcmp (optarg, "interpose") == 0)
2410 link_info.flags_1 |= (bfd_vma) DF_1_INTERPOSE;
2411 else if (strcmp (optarg, "loadfltr") == 0)
2412 link_info.flags_1 |= (bfd_vma) DF_1_LOADFLTR;
2413 else if (strcmp (optarg, "nodefaultlib") == 0)
2414 link_info.flags_1 |= (bfd_vma) DF_1_NODEFLIB;
2415 else if (strcmp (optarg, "nodelete") == 0)
2416 link_info.flags_1 |= (bfd_vma) DF_1_NODELETE;
2417 else if (strcmp (optarg, "nodlopen") == 0)
2418 link_info.flags_1 |= (bfd_vma) DF_1_NOOPEN;
2419 else if (strcmp (optarg, "nodump") == 0)
2420 link_info.flags_1 |= (bfd_vma) DF_1_NODUMP;
2421 else if (strcmp (optarg, "now") == 0)
2423 link_info.flags |= (bfd_vma) DF_BIND_NOW;
2424 link_info.flags_1 |= (bfd_vma) DF_1_NOW;
2426 else if (strcmp (optarg, "lazy") == 0)
2428 link_info.flags &= ~(bfd_vma) DF_BIND_NOW;
2429 link_info.flags_1 &= ~(bfd_vma) DF_1_NOW;
2431 else if (strcmp (optarg, "origin") == 0)
2433 link_info.flags |= (bfd_vma) DF_ORIGIN;
2434 link_info.flags_1 |= (bfd_vma) DF_1_ORIGIN;
2436 else if (strcmp (optarg, "combreloc") == 0)
2437 link_info.combreloc = TRUE;
2438 else if (strcmp (optarg, "nocombreloc") == 0)
2439 link_info.combreloc = FALSE;
2440 else if (strcmp (optarg, "nocopyreloc") == 0)
2441 link_info.nocopyreloc = TRUE;
2442 else if (strcmp (optarg, "relro") == 0)
2443 link_info.relro = TRUE;
2444 else if (strcmp (optarg, "norelro") == 0)
2445 link_info.relro = FALSE;
2446 else if (strcmp (optarg, "common") == 0)
2447 link_info.elf_stt_common = elf_stt_common;
2448 else if (strcmp (optarg, "nocommon") == 0)
2449 link_info.elf_stt_common = no_elf_stt_common;
2450 else if (strcmp (optarg, "text") == 0)
2451 link_info.error_textrel = TRUE;
2452 else if (strcmp (optarg, "notext") == 0)
2453 link_info.error_textrel = FALSE;
2454 else if (strcmp (optarg, "textoff") == 0)
2455 link_info.error_textrel = FALSE;
2459 if test -n "$PARSE_AND_LIST_ARGS_CASE_Z" ; then
2461 $PARSE_AND_LIST_ARGS_CASE_Z
2467 einfo (_("%P: warning: -z %s ignored.\n"), optarg);
2471 if test -n "$PARSE_AND_LIST_ARGS_CASES" ; then
2473 $PARSE_AND_LIST_ARGS_CASES
2485 if test x"$LDEMUL_LIST_OPTIONS" != xgld"$EMULATION_NAME"_list_options; then
2486 gld_list_options="gld${EMULATION_NAME}_list_options"
2487 if test -n "$PARSE_AND_LIST_OPTIONS"; then
2491 gld${EMULATION_NAME}_list_options (FILE * file)
2495 if test -n "$PARSE_AND_LIST_OPTIONS" ; then
2497 $PARSE_AND_LIST_OPTIONS
2505 gld_list_options="NULL"
2508 if test -n "$PARSE_AND_LIST_EPILOGUE" ; then
2510 $PARSE_AND_LIST_EPILOGUE
2517 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
2519 ${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse},
2520 ${LDEMUL_SYSLIB-syslib_default},
2521 ${LDEMUL_HLL-hll_default},
2522 ${LDEMUL_AFTER_PARSE-gld${EMULATION_NAME}_after_parse},
2523 ${LDEMUL_AFTER_OPEN-gld${EMULATION_NAME}_after_open},
2524 ${LDEMUL_AFTER_ALLOCATION-gld${EMULATION_NAME}_after_allocation},
2525 ${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
2526 ${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
2527 ${LDEMUL_BEFORE_ALLOCATION-gld${EMULATION_NAME}_before_allocation},
2528 ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
2529 "${EMULATION_NAME}",
2531 ${LDEMUL_FINISH-finish_default},
2532 ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL},
2533 ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-gld${EMULATION_NAME}_open_dynamic_archive},
2534 ${LDEMUL_PLACE_ORPHAN-gld${EMULATION_NAME}_place_orphan},
2535 ${LDEMUL_SET_SYMBOLS-NULL},
2536 ${LDEMUL_PARSE_ARGS-NULL},
2537 gld${EMULATION_NAME}_add_options,
2538 gld${EMULATION_NAME}_handle_option,
2539 ${LDEMUL_UNRECOGNIZED_FILE-NULL},
2540 ${LDEMUL_LIST_OPTIONS-${gld_list_options}},
2541 ${LDEMUL_RECOGNIZED_FILE-gld${EMULATION_NAME}_load_symbols},
2542 ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL},
2543 ${LDEMUL_NEW_VERS_PATTERN-NULL},
2544 ${LDEMUL_EXTRA_MAP_FILE_TEXT-NULL}