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`;
108 link_info.relro = DEFAULT_LD_Z_RELRO;
114 if test x"$LDEMUL_AFTER_PARSE" != xgld"$EMULATION_NAME"_after_parse; then
118 gld${EMULATION_NAME}_after_parse (void)
120 if (bfd_link_pie (&link_info))
121 link_info.flags_1 |= (bfd_vma) DF_1_PIE;
123 after_parse_default ();
129 if test x"$LDEMUL_RECOGNIZED_FILE" != xgld"${EMULATION_NAME}"_load_symbols; then
131 /* Handle the generation of DT_NEEDED tags. */
134 gld${EMULATION_NAME}_load_symbols (lang_input_statement_type *entry)
138 /* Tell the ELF linker that we don't want the output file to have a
139 DT_NEEDED entry for this file, unless it is used to resolve
140 references in a regular object. */
141 if (entry->flags.add_DT_NEEDED_for_regular)
142 link_class = DYN_AS_NEEDED;
144 /* Tell the ELF linker that we don't want the output file to have a
145 DT_NEEDED entry for any dynamic library in DT_NEEDED tags from
147 if (!entry->flags.add_DT_NEEDED_for_dynamic)
148 link_class |= DYN_NO_ADD_NEEDED;
150 if (entry->flags.just_syms
151 && (bfd_get_file_flags (entry->the_bfd) & DYNAMIC) != 0)
152 einfo (_("%P%F: --just-symbols may not be used on DSO: %B\n"),
156 || (bfd_get_file_flags (entry->the_bfd) & DYNAMIC) == 0)
159 bfd_elf_set_dyn_lib_class (entry->the_bfd,
160 (enum dynamic_lib_link_class) link_class);
162 /* Continue on with normal load_symbols processing. */
170 /* These variables are required to pass information back and forth
171 between after_open and check_needed and stat_needed and vercheck. */
173 static struct bfd_link_needed_list *global_needed;
174 static struct stat global_stat;
175 static lang_input_statement_type *global_found;
176 static struct bfd_link_needed_list *global_vercheck_needed;
177 static bfd_boolean global_vercheck_failed;
179 /* These variables are used to implement target options */
181 static char *audit; /* colon (typically) separated list of libs */
182 static char *depaudit; /* colon (typically) separated list of libs */
184 /* Style of .note.gnu.build-id section. */
185 static const char *emit_note_gnu_build_id;
187 /* On Linux, it's possible to have different versions of the same
188 shared library linked against different versions of libc. The
189 dynamic linker somehow tags which libc version to use in
190 /etc/ld.so.cache, and, based on the libc that it sees in the
191 executable, chooses which version of the shared library to use.
193 We try to do a similar check here by checking whether this shared
194 library needs any other shared libraries which may conflict with
195 libraries we have already included in the link. If it does, we
196 skip it, and try to find another shared library farther on down the
199 This is called via lang_for_each_input_file.
200 GLOBAL_VERCHECK_NEEDED is the list of objects needed by the object
201 which we are checking. This sets GLOBAL_VERCHECK_FAILED if we find
202 a conflicting version. */
205 gld${EMULATION_NAME}_vercheck (lang_input_statement_type *s)
208 struct bfd_link_needed_list *l;
210 if (global_vercheck_failed)
212 if (s->the_bfd == NULL
213 || (bfd_get_file_flags (s->the_bfd) & DYNAMIC) == 0)
216 soname = bfd_elf_get_dt_soname (s->the_bfd);
218 soname = lbasename (bfd_get_filename (s->the_bfd));
220 for (l = global_vercheck_needed; l != NULL; l = l->next)
224 if (filename_cmp (soname, l->name) == 0)
226 /* Probably can't happen, but it's an easy check. */
230 if (strchr (l->name, '/') != NULL)
233 suffix = strstr (l->name, ".so.");
237 suffix += sizeof ".so." - 1;
239 if (filename_ncmp (soname, l->name, suffix - l->name) == 0)
241 /* Here we know that S is a dynamic object FOO.SO.VER1, and
242 the object we are considering needs a dynamic object
243 FOO.SO.VER2, and VER1 and VER2 are different. This
244 appears to be a version mismatch, so we tell the caller
245 to try a different version of this library. */
246 global_vercheck_failed = TRUE;
253 /* See if an input file matches a DT_NEEDED entry by running stat on
257 gld${EMULATION_NAME}_stat_needed (lang_input_statement_type *s)
263 if (global_found != NULL)
265 if (s->the_bfd == NULL)
268 /* If this input file was an as-needed entry, and wasn't found to be
269 needed at the stage it was linked, then don't say we have loaded it. */
270 if ((bfd_elf_get_dyn_lib_class (s->the_bfd) & DYN_AS_NEEDED) != 0)
273 if (bfd_stat (s->the_bfd, &st) != 0)
275 einfo ("%P:%B: bfd_stat failed: %E\n", s->the_bfd);
279 /* Some operating systems, e.g. Windows, do not provide a meaningful
280 st_ino; they always set it to zero. (Windows does provide a
281 meaningful st_dev.) Do not indicate a duplicate library in that
282 case. While there is no guarantee that a system that provides
283 meaningful inode numbers will never set st_ino to zero, this is
284 merely an optimization, so we do not need to worry about false
286 if (st.st_dev == global_stat.st_dev
287 && st.st_ino == global_stat.st_ino
294 /* We issue a warning if it looks like we are including two
295 different versions of the same shared library. For example,
296 there may be a problem if -lc picks up libc.so.6 but some other
297 shared library has a DT_NEEDED entry of libc.so.5. This is a
298 heuristic test, and it will only work if the name looks like
299 NAME.so.VERSION. FIXME: Depending on file names is error-prone.
300 If we really want to issue warnings about mixing version numbers
301 of shared libraries, we need to find a better way. */
303 if (strchr (global_needed->name, '/') != NULL)
305 suffix = strstr (global_needed->name, ".so.");
308 suffix += sizeof ".so." - 1;
310 soname = bfd_elf_get_dt_soname (s->the_bfd);
312 soname = lbasename (s->filename);
314 if (filename_ncmp (soname, global_needed->name, suffix - global_needed->name) == 0)
315 einfo ("%P: warning: %s, needed by %B, may conflict with %s\n",
316 global_needed->name, global_needed->by, soname);
325 /* This function is called for each possible name for a dynamic object
326 named by a DT_NEEDED entry. The FORCE parameter indicates whether
327 to skip the check for a conflicting version. */
330 gld${EMULATION_NAME}_try_needed (struct dt_needed *needed,
334 const char *name = needed->name;
338 abfd = bfd_openr (name, bfd_get_target (link_info.output_bfd));
342 info_msg (_("attempt to open %s failed\n"), name);
346 /* Linker needs to decompress sections. */
347 abfd->flags |= BFD_DECOMPRESS;
349 if (! bfd_check_format (abfd, bfd_object))
354 if ((bfd_get_file_flags (abfd) & DYNAMIC) == 0)
360 /* For DT_NEEDED, they have to match. */
361 if (abfd->xvec != link_info.output_bfd->xvec)
367 /* Check whether this object would include any conflicting library
368 versions. If FORCE is set, then we skip this check; we use this
369 the second time around, if we couldn't find any compatible
370 instance of the shared library. */
374 struct bfd_link_needed_list *needs;
376 if (! bfd_elf_get_bfd_needed_list (abfd, &needs))
377 einfo ("%F%P:%B: bfd_elf_get_bfd_needed_list failed: %E\n", abfd);
381 global_vercheck_needed = needs;
382 global_vercheck_failed = FALSE;
383 lang_for_each_input_file (gld${EMULATION_NAME}_vercheck);
384 if (global_vercheck_failed)
387 /* Return FALSE to force the caller to move on to try
388 another file on the search path. */
392 /* But wait! It gets much worse. On Linux, if a shared
393 library does not use libc at all, we are supposed to skip
394 it the first time around in case we encounter a shared
395 library later on with the same name which does use the
396 version of libc that we want. This is much too horrible
397 to use on any system other than Linux. */
401 *-*-linux-* | *-*-k*bsd*-* | *-*-gnu*)
404 struct bfd_link_needed_list *l;
406 for (l = needs; l != NULL; l = l->next)
407 if (CONST_STRNEQ (l->name, "libc.so"))
423 /* We've found a dynamic object matching the DT_NEEDED entry. */
425 /* We have already checked that there is no other input file of the
426 same name. We must now check again that we are not including the
427 same file twice. We need to do this because on many systems
428 libc.so is a symlink to, e.g., libc.so.1. The SONAME entry will
429 reference libc.so.1. If we have already included libc.so, we
430 don't want to include libc.so.1 if they are the same file, and we
431 can only check that using stat. */
433 if (bfd_stat (abfd, &global_stat) != 0)
434 einfo ("%F%P:%B: bfd_stat failed: %E\n", abfd);
436 /* First strip off everything before the last '/'. */
437 soname = lbasename (abfd->filename);
440 info_msg (_("found %s at %s\n"), soname, name);
443 lang_for_each_input_file (gld${EMULATION_NAME}_stat_needed);
444 if (global_found != NULL)
446 /* Return TRUE to indicate that we found the file, even though
447 we aren't going to do anything with it. */
451 /* Specify the soname to use. */
452 bfd_elf_set_dt_needed_name (abfd, soname);
454 /* Tell the ELF linker that we don't want the output file to have a
455 DT_NEEDED entry for this file, unless it is used to resolve
456 references in a regular object. */
457 link_class = DYN_DT_NEEDED;
459 /* Tell the ELF linker that we don't want the output file to have a
460 DT_NEEDED entry for this file at all if the entry is from a file
461 with DYN_NO_ADD_NEEDED. */
462 if (needed->by != NULL
463 && (bfd_elf_get_dyn_lib_class (needed->by) & DYN_NO_ADD_NEEDED) != 0)
464 link_class |= DYN_NO_NEEDED | DYN_NO_ADD_NEEDED;
466 bfd_elf_set_dyn_lib_class (abfd, (enum dynamic_lib_link_class) link_class);
468 /* Add this file into the symbol table. */
469 if (! bfd_link_add_symbols (abfd, &link_info))
470 einfo ("%F%B: error adding symbols: %E\n", abfd);
476 /* Search for a needed file in a path. */
479 gld${EMULATION_NAME}_search_needed (const char *path,
480 struct dt_needed *n, int force)
483 const char *name = n->name;
485 struct dt_needed needed;
488 return gld${EMULATION_NAME}_try_needed (n, force);
490 if (path == NULL || *path == '\0')
494 needed.name = n->name;
499 char *filename, *sset;
501 s = strchr (path, config.rpath_separator);
503 s = path + strlen (path);
505 #if HAVE_DOS_BASED_FILE_SYSTEM
506 /* Assume a match on the second char is part of drive specifier. */
507 else if (config.rpath_separator == ':'
511 s = strchr (s + 1, config.rpath_separator);
513 s = path + strlen (path);
516 filename = (char *) xmalloc (s - path + len + 2);
521 memcpy (filename, path, s - path);
522 filename[s - path] = '/';
523 sset = filename + (s - path) + 1;
527 needed.name = filename;
528 if (gld${EMULATION_NAME}_try_needed (&needed, force))
542 if [ "x${USE_LIBPATH}" = xyes ] ; then
545 /* Add the sysroot to every entry in a path separated by
546 config.rpath_separator. */
549 gld${EMULATION_NAME}_add_sysroot (const char *path)
558 if (path[i++] == config.rpath_separator)
564 len = len + (colons + 1) * strlen (ld_sysroot);
565 ret = xmalloc (len + 1);
566 strcpy (ret, ld_sysroot);
567 p = ret + strlen (ret);
570 if (path[i] == config.rpath_separator)
573 strcpy (p, ld_sysroot);
585 *-*-freebsd* | *-*-dragonfly*)
587 /* Read the system search path the FreeBSD way rather than the Linux way. */
588 #ifdef HAVE_ELF_HINTS_H
589 #include <elf-hints.h>
591 #include "elf-hints-local.h"
595 gld${EMULATION_NAME}_check_ld_elf_hints (const struct bfd_link_needed_list *l,
598 static bfd_boolean initialized;
599 static char *ld_elf_hints;
600 struct dt_needed needed;
607 tmppath = concat (ld_sysroot, _PATH_ELF_HINTS, (const char *) NULL);
608 f = fopen (tmppath, FOPEN_RB);
612 struct elfhints_hdr hdr;
614 if (fread (&hdr, 1, sizeof (hdr), f) == sizeof (hdr)
615 && hdr.magic == ELFHINTS_MAGIC
618 if (fseek (f, hdr.strtab + hdr.dirlist, SEEK_SET) != -1)
622 b = xmalloc (hdr.dirlistlen + 1);
623 if (fread (b, 1, hdr.dirlistlen + 1, f) ==
625 ld_elf_hints = gld${EMULATION_NAME}_add_sysroot (b);
636 if (ld_elf_hints == NULL)
640 needed.name = l->name;
641 return gld${EMULATION_NAME}_search_needed (ld_elf_hints, &needed, force);
647 *-*-linux-* | *-*-k*bsd*-* | *-*-gnu*)
649 /* For a native linker, check the file /etc/ld.so.conf for directories
650 in which we may find shared libraries. /etc/ld.so.conf is really
651 only meaningful on Linux. */
653 struct gld${EMULATION_NAME}_ld_so_conf
660 gld${EMULATION_NAME}_parse_ld_so_conf
661 (struct gld${EMULATION_NAME}_ld_so_conf *info, const char *filename);
664 gld${EMULATION_NAME}_parse_ld_so_conf_include
665 (struct gld${EMULATION_NAME}_ld_so_conf *info, const char *filename,
673 if (pattern[0] != '/')
675 char *p = strrchr (filename, '/');
676 size_t patlen = strlen (pattern) + 1;
678 newp = xmalloc (p - filename + 1 + patlen);
679 memcpy (newp, filename, p - filename + 1);
680 memcpy (newp + (p - filename + 1), pattern, patlen);
685 if (glob (pattern, 0, NULL, &gl) == 0)
689 for (i = 0; i < gl.gl_pathc; ++i)
690 gld${EMULATION_NAME}_parse_ld_so_conf (info, gl.gl_pathv[i]);
694 /* If we do not have glob, treat the pattern as a literal filename. */
695 gld${EMULATION_NAME}_parse_ld_so_conf (info, pattern);
703 gld${EMULATION_NAME}_parse_ld_so_conf
704 (struct gld${EMULATION_NAME}_ld_so_conf *info, const char *filename)
706 FILE *f = fopen (filename, FOPEN_RT);
714 line = xmalloc (linelen);
719 /* Normally this would use getline(3), but we need to be portable. */
720 while ((q = fgets (p, linelen - (p - line), f)) != NULL
721 && strlen (q) == linelen - (p - line) - 1
722 && line[linelen - 2] != '\n')
724 line = xrealloc (line, 2 * linelen);
725 p = line + linelen - 1;
729 if (q == NULL && p == line)
732 p = strchr (line, '\n');
736 /* Because the file format does not know any form of quoting we
737 can search forward for the next '#' character and if found
738 make it terminating the line. */
739 p = strchr (line, '#');
743 /* Remove leading whitespace. NUL is no whitespace character. */
745 while (*p == ' ' || *p == '\f' || *p == '\r' || *p == '\t' || *p == '\v')
748 /* If the line is blank it is ignored. */
752 if (CONST_STRNEQ (p, "include") && (p[7] == ' ' || p[7] == '\t'))
758 while (*p == ' ' || *p == '\t')
766 while (*p != ' ' && *p != '\t' && *p)
772 gld${EMULATION_NAME}_parse_ld_so_conf_include (info, filename,
780 while (*p && *p != '=' && *p != ' ' && *p != '\t' && *p != '\f'
781 && *p != '\r' && *p != '\v')
784 while (p != dir && p[-1] == '/')
786 if (info->path == NULL)
788 info->alloc = p - dir + 1 + 256;
789 info->path = xmalloc (info->alloc);
794 if (info->len + 1 + (p - dir) >= info->alloc)
796 info->alloc += p - dir + 256;
797 info->path = xrealloc (info->path, info->alloc);
799 info->path[info->len++] = config.rpath_separator;
801 memcpy (info->path + info->len, dir, p - dir);
802 info->len += p - dir;
803 info->path[info->len] = '\0';
813 gld${EMULATION_NAME}_check_ld_so_conf (const struct bfd_link_needed_list *l,
816 static bfd_boolean initialized;
817 static char *ld_so_conf;
818 struct dt_needed needed;
823 struct gld${EMULATION_NAME}_ld_so_conf info;
826 info.len = info.alloc = 0;
827 tmppath = concat (ld_sysroot, "${prefix}/etc/ld.so.conf",
828 (const char *) NULL);
829 if (!gld${EMULATION_NAME}_parse_ld_so_conf (&info, tmppath))
832 tmppath = concat (ld_sysroot, "/etc/ld.so.conf",
833 (const char *) NULL);
834 gld${EMULATION_NAME}_parse_ld_so_conf (&info, tmppath);
840 char *d = gld${EMULATION_NAME}_add_sysroot (info.path);
847 if (ld_so_conf == NULL)
852 needed.name = l->name;
853 return gld${EMULATION_NAME}_search_needed (ld_so_conf, &needed, force);
863 /* See if an input file matches a DT_NEEDED entry by name. */
866 gld${EMULATION_NAME}_check_needed (lang_input_statement_type *s)
870 /* Stop looking if we've found a loaded lib. */
871 if (global_found != NULL
872 && (bfd_elf_get_dyn_lib_class (global_found->the_bfd)
873 & DYN_AS_NEEDED) == 0)
876 if (s->filename == NULL || s->the_bfd == NULL)
879 /* Don't look for a second non-loaded as-needed lib. */
880 if (global_found != NULL
881 && (bfd_elf_get_dyn_lib_class (s->the_bfd) & DYN_AS_NEEDED) != 0)
884 if (filename_cmp (s->filename, global_needed->name) == 0)
890 if (s->flags.search_dirs)
892 const char *f = strrchr (s->filename, '/');
894 && filename_cmp (f + 1, global_needed->name) == 0)
901 soname = bfd_elf_get_dt_soname (s->the_bfd);
903 && filename_cmp (soname, global_needed->name) == 0)
912 if test x"$LDEMUL_AFTER_OPEN" != xgld"$EMULATION_NAME"_after_open; then
916 id_note_section_size (bfd *abfd ATTRIBUTE_UNUSED)
918 const char *style = emit_note_gnu_build_id;
920 bfd_size_type build_id_size;
922 size = offsetof (Elf_External_Note, name[sizeof "GNU"]);
923 size = (size + 3) & -(bfd_size_type) 4;
925 build_id_size = compute_build_id_size (style);
927 size += build_id_size;
935 write_build_id (bfd *abfd)
937 const struct elf_backend_data *bed = get_elf_backend_data (abfd);
938 struct elf_obj_tdata *t = elf_tdata (abfd);
941 Elf_Internal_Shdr *i_shdr;
942 unsigned char *contents, *id_bits;
945 Elf_External_Note *e_note;
947 style = t->o->build_id.style;
948 asec = t->o->build_id.sec;
949 if (bfd_is_abs_section (asec->output_section))
951 einfo (_("%P: warning: .note.gnu.build-id section discarded,"
952 " --build-id ignored.\n"));
955 i_shdr = &elf_section_data (asec->output_section)->this_hdr;
957 if (i_shdr->contents == NULL)
959 if (asec->contents == NULL)
960 asec->contents = (unsigned char *) xmalloc (asec->size);
961 contents = asec->contents;
964 contents = i_shdr->contents + asec->output_offset;
966 e_note = (Elf_External_Note *) contents;
967 size = offsetof (Elf_External_Note, name[sizeof "GNU"]);
968 size = (size + 3) & -(bfd_size_type) 4;
969 id_bits = contents + size;
970 size = asec->size - size;
972 bfd_h_put_32 (abfd, sizeof "GNU", &e_note->namesz);
973 bfd_h_put_32 (abfd, size, &e_note->descsz);
974 bfd_h_put_32 (abfd, NT_GNU_BUILD_ID, &e_note->type);
975 memcpy (e_note->name, "GNU", sizeof "GNU");
977 generate_build_id (abfd, style, bed->s->checksum_contents, id_bits, size);
979 position = i_shdr->sh_offset + asec->output_offset;
981 return (bfd_seek (abfd, position, SEEK_SET) == 0
982 && bfd_bwrite (contents, size, abfd) == size);
985 /* Make .note.gnu.build-id section, and set up elf_tdata->build_id. */
988 setup_build_id (bfd *ibfd)
994 size = id_note_section_size (ibfd);
997 einfo ("%P: warning: unrecognized --build-id style ignored.\n");
1001 flags = (SEC_ALLOC | SEC_LOAD | SEC_IN_MEMORY
1002 | SEC_LINKER_CREATED | SEC_READONLY | SEC_DATA);
1003 s = bfd_make_section_with_flags (ibfd, ".note.gnu.build-id", flags);
1004 if (s != NULL && bfd_set_section_alignment (ibfd, s, 2))
1006 struct elf_obj_tdata *t = elf_tdata (link_info.output_bfd);
1007 t->o->build_id.after_write_object_contents = &write_build_id;
1008 t->o->build_id.style = emit_note_gnu_build_id;
1009 t->o->build_id.sec = s;
1010 elf_section_type (s) = SHT_NOTE;
1015 einfo ("%P: warning: Cannot create .note.gnu.build-id section,"
1016 " --build-id ignored.\n");
1020 /* This is called after all the input files have been opened. */
1023 gld${EMULATION_NAME}_after_open (void)
1025 struct bfd_link_needed_list *needed, *l;
1026 struct elf_link_hash_table *htab;
1028 after_open_default ();
1030 htab = elf_hash_table (&link_info);
1031 if (!is_elf_hash_table (htab))
1034 if (command_line.out_implib_filename)
1036 unlink_if_ordinary (command_line.out_implib_filename);
1037 link_info.out_implib_bfd
1038 = bfd_openw (command_line.out_implib_filename,
1039 bfd_get_target (link_info.output_bfd));
1041 if (link_info.out_implib_bfd == NULL)
1043 einfo ("%F%s: Can't open for writing: %E\n",
1044 command_line.out_implib_filename);
1048 if (emit_note_gnu_build_id != NULL)
1052 /* Find an ELF input. */
1053 for (abfd = link_info.input_bfds;
1054 abfd != (bfd *) NULL; abfd = abfd->link.next)
1055 if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
1056 && bfd_count_sections (abfd) != 0)
1059 /* PR 10555: If there are no ELF input files do not try to
1060 create a .note.gnu-build-id section. */
1062 || !setup_build_id (abfd))
1064 free ((char *) emit_note_gnu_build_id);
1065 emit_note_gnu_build_id = NULL;
1069 if (bfd_link_relocatable (&link_info))
1071 if (link_info.execstack == ! link_info.noexecstack)
1072 /* PR ld/16744: If "-z [no]execstack" has been specified on the
1073 command line and we are perfoming a relocatable link then no
1074 PT_GNU_STACK segment will be created and so the
1075 linkinfo.[no]execstack values set in _handle_option() will have no
1076 effect. Instead we create a .note.GNU-stack section in much the
1077 same way as the assembler does with its --[no]execstack option. */
1078 (void) bfd_make_section_with_flags (link_info.input_bfds,
1080 SEC_READONLY | (link_info.execstack ? SEC_CODE : 0));
1085 if (!link_info.traditional_format)
1087 bfd *abfd, *elfbfd = NULL;
1088 bfd_boolean warn_eh_frame = FALSE;
1092 for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
1095 for (s = abfd->sections; s && type < COMPACT_EH_HDR; s = s->next)
1097 const char *name = bfd_get_section_name (abfd, s);
1099 if (bfd_is_abs_section (s->output_section))
1101 if (CONST_STRNEQ (name, ".eh_frame_entry"))
1102 type = COMPACT_EH_HDR;
1103 else if (strcmp (name, ".eh_frame") == 0 && s->size > 8)
1104 type = DWARF2_EH_HDR;
1113 else if (seen_type != type)
1115 einfo (_("%P%F: compact frame descriptions incompatible with"
1116 " DWARF2 .eh_frame from %B\n"),
1117 type == DWARF2_EH_HDR ? abfd : elfbfd);
1122 && (type == COMPACT_EH_HDR || link_info.eh_frame_hdr_type != 0))
1124 if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
1127 warn_eh_frame = TRUE;
1131 if (seen_type == COMPACT_EH_HDR)
1132 link_info.eh_frame_hdr_type = COMPACT_EH_HDR;
1134 if (bfd_count_sections (abfd) == 0)
1139 const struct elf_backend_data *bed;
1141 bed = get_elf_backend_data (elfbfd);
1142 s = bfd_make_section_with_flags (elfbfd, ".eh_frame_hdr",
1143 bed->dynamic_sec_flags
1146 && bfd_set_section_alignment (elfbfd, s, 2))
1148 htab->eh_info.hdr_sec = s;
1149 warn_eh_frame = FALSE;
1153 einfo ("%P: warning: Cannot create .eh_frame_hdr section,"
1154 " --eh-frame-hdr ignored.\n");
1157 /* Get the list of files which appear in DT_NEEDED entries in
1158 dynamic objects included in the link (often there will be none).
1159 For each such file, we want to track down the corresponding
1160 library, and include the symbol table in the link. This is what
1161 the runtime dynamic linker will do. Tracking the files down here
1162 permits one dynamic object to include another without requiring
1163 special action by the person doing the link. Note that the
1164 needed list can actually grow while we are stepping through this
1166 needed = bfd_elf_get_needed_list (link_info.output_bfd, &link_info);
1167 for (l = needed; l != NULL; l = l->next)
1169 struct bfd_link_needed_list *ll;
1170 struct dt_needed n, nn;
1173 /* If the lib that needs this one was --as-needed and wasn't
1174 found to be needed, then this lib isn't needed either. */
1176 && (bfd_elf_get_dyn_lib_class (l->by) & DYN_AS_NEEDED) != 0)
1179 /* Skip the lib if --no-copy-dt-needed-entries and
1180 --allow-shlib-undefined is in effect. */
1182 && link_info.unresolved_syms_in_shared_libs == RM_IGNORE
1183 && (bfd_elf_get_dyn_lib_class (l->by) & DYN_NO_ADD_NEEDED) != 0)
1186 /* If we've already seen this file, skip it. */
1187 for (ll = needed; ll != l; ll = ll->next)
1189 || (bfd_elf_get_dyn_lib_class (ll->by) & DYN_AS_NEEDED) == 0)
1190 && strcmp (ll->name, l->name) == 0)
1195 /* See if this file was included in the link explicitly. */
1197 global_found = NULL;
1198 lang_for_each_input_file (gld${EMULATION_NAME}_check_needed);
1199 if (global_found != NULL
1200 && (bfd_elf_get_dyn_lib_class (global_found->the_bfd)
1201 & DYN_AS_NEEDED) == 0)
1208 info_msg (_("%s needed by %B\n"), l->name, l->by);
1210 /* As-needed libs specified on the command line (or linker script)
1211 take priority over libs found in search dirs. */
1212 if (global_found != NULL)
1214 nn.name = global_found->filename;
1215 if (gld${EMULATION_NAME}_try_needed (&nn, TRUE))
1219 /* We need to find this file and include the symbol table. We
1220 want to search for the file in the same way that the dynamic
1221 linker will search. That means that we want to use
1222 rpath_link, rpath, then the environment variable
1223 LD_LIBRARY_PATH (native only), then the DT_RPATH/DT_RUNPATH
1224 entries (native only), then the linker script LIB_SEARCH_DIRS.
1225 We do not search using the -L arguments.
1227 We search twice. The first time, we skip objects which may
1228 introduce version mismatches. The second time, we force
1229 their use. See gld${EMULATION_NAME}_vercheck comment. */
1230 for (force = 0; force < 2; force++)
1233 search_dirs_type *search;
1235 if [ "x${NATIVE}" = xyes ] ; then
1237 const char *lib_path;
1240 if [ "x${USE_LIBPATH}" = xyes ] ; then
1242 struct bfd_link_needed_list *rp;
1248 if (gld${EMULATION_NAME}_search_needed (command_line.rpath_link,
1252 if [ "x${USE_LIBPATH}" = xyes ] ; then
1254 if (gld${EMULATION_NAME}_search_needed (command_line.rpath,
1259 if [ "x${NATIVE}" = xyes ] ; then
1261 if (command_line.rpath_link == NULL
1262 && command_line.rpath == NULL)
1264 lib_path = (const char *) getenv ("LD_RUN_PATH");
1265 if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
1269 lib_path = (const char *) getenv ("LD_LIBRARY_PATH");
1270 if (gld${EMULATION_NAME}_search_needed (lib_path, &n, force))
1274 if [ "x${USE_LIBPATH}" = xyes ] ; then
1277 rp = bfd_elf_get_runpath_list (link_info.output_bfd, &link_info);
1278 for (; !found && rp != NULL; rp = rp->next)
1280 const char *tmpname = rp->name;
1282 if (IS_ABSOLUTE_PATH (tmpname))
1283 tmpname = gld${EMULATION_NAME}_add_sysroot (tmpname);
1284 found = (rp->by == l->by
1285 && gld${EMULATION_NAME}_search_needed (tmpname,
1288 if (tmpname != rp->name)
1289 free ((char *) tmpname);
1296 if [ "x${USE_LIBPATH}" = xyes ] ; then
1298 *-*-freebsd* | *-*-dragonfly*)
1300 if (gld${EMULATION_NAME}_check_ld_elf_hints (l, force))
1306 *-*-linux-* | *-*-k*bsd*-* | *-*-gnu*)
1308 if (gld${EMULATION_NAME}_check_ld_so_conf (l, force))
1317 len = strlen (l->name);
1318 for (search = search_head; search != NULL; search = search->next)
1322 if (search->cmdline)
1324 filename = (char *) xmalloc (strlen (search->name) + len + 2);
1325 sprintf (filename, "%s/%s", search->name, l->name);
1327 if (gld${EMULATION_NAME}_try_needed (&nn, force))
1340 einfo ("%P: warning: %s, needed by %B, not found (try using -rpath or -rpath-link)\n",
1344 if (link_info.eh_frame_hdr_type == COMPACT_EH_HDR)
1345 if (bfd_elf_parse_eh_frame_entries (NULL, &link_info) == FALSE)
1346 einfo (_("%P%F: Failed to parse EH frame entries.\n"));
1354 /* Look through an expression for an assignment statement. */
1357 gld${EMULATION_NAME}_find_exp_assignment (etree_type *exp)
1359 bfd_boolean provide = FALSE;
1361 switch (exp->type.node_class)
1364 case etree_provided:
1368 /* We call record_link_assignment even if the symbol is defined.
1369 This is because if it is defined by a dynamic object, we
1370 actually want to use the value defined by the linker script,
1371 not the value from the dynamic object (because we are setting
1372 symbols like etext). If the symbol is defined by a regular
1373 object, then, as it happens, calling record_link_assignment
1375 if (strcmp (exp->assign.dst, ".") != 0)
1377 if (!bfd_elf_record_link_assignment (link_info.output_bfd,
1379 exp->assign.dst, provide,
1380 exp->assign.hidden))
1381 einfo ("%P%F: failed to record assignment to %s: %E\n",
1384 gld${EMULATION_NAME}_find_exp_assignment (exp->assign.src);
1388 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.lhs);
1389 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.rhs);
1393 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.cond);
1394 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.lhs);
1395 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.rhs);
1399 gld${EMULATION_NAME}_find_exp_assignment (exp->unary.child);
1408 /* This is called by the before_allocation routine via
1409 lang_for_each_statement. It locates any assignment statements, and
1410 tells the ELF backend about them, in case they are assignments to
1411 symbols which are referred to by dynamic objects. */
1414 gld${EMULATION_NAME}_find_statement_assignment (lang_statement_union_type *s)
1416 if (s->header.type == lang_assignment_statement_enum)
1417 gld${EMULATION_NAME}_find_exp_assignment (s->assignment_statement.exp);
1422 if test x"$LDEMUL_BEFORE_ALLOCATION" != xgld"$EMULATION_NAME"_before_allocation; then
1423 if test x"${ELF_INTERPRETER_NAME+set}" = xset; then
1424 ELF_INTERPRETER_SET_DEFAULT="
1425 if (sinterp != NULL)
1427 sinterp->contents = (unsigned char *) ${ELF_INTERPRETER_NAME};
1428 sinterp->size = strlen ((char *) sinterp->contents) + 1;
1433 ELF_INTERPRETER_SET_DEFAULT=
1437 /* used by before_allocation and handle_option. */
1439 gld${EMULATION_NAME}_append_to_separated_string (char **to, char *op_arg)
1442 *to = xstrdup (op_arg);
1445 size_t to_len = strlen (*to);
1446 size_t op_arg_len = strlen (op_arg);
1450 /* First see whether OPTARG is already in the path. */
1453 if (strncmp (op_arg, cp, op_arg_len) == 0
1454 && (cp[op_arg_len] == 0
1455 || cp[op_arg_len] == config.rpath_separator))
1459 /* Not yet found. */
1460 cp = strchr (cp, config.rpath_separator);
1468 buf = xmalloc (to_len + op_arg_len + 2);
1469 sprintf (buf, "%s%c%s", *to,
1470 config.rpath_separator, op_arg);
1477 #if defined(__GNUC__) && GCC_VERSION < 4006
1478 /* Work around a GCC uninitialized warning bug fixed in GCC 4.6. */
1479 static struct bfd_link_hash_entry ehdr_start_empty;
1482 /* This is called after the sections have been attached to output
1483 sections, but before any sizes or addresses have been set. */
1486 gld${EMULATION_NAME}_before_allocation (void)
1491 struct elf_link_hash_entry *ehdr_start = NULL;
1492 #if defined(__GNUC__) && GCC_VERSION < 4006
1493 /* Work around a GCC uninitialized warning bug fixed in GCC 4.6. */
1494 struct bfd_link_hash_entry ehdr_start_save = ehdr_start_empty;
1496 struct bfd_link_hash_entry ehdr_start_save;
1499 if (is_elf_hash_table (link_info.hash))
1501 _bfd_elf_tls_setup (link_info.output_bfd, &link_info);
1503 /* Make __ehdr_start hidden if it has been referenced, to
1504 prevent the symbol from being dynamic. */
1505 if (!bfd_link_relocatable (&link_info))
1507 struct elf_link_hash_entry *h
1508 = elf_link_hash_lookup (elf_hash_table (&link_info), "__ehdr_start",
1509 FALSE, FALSE, TRUE);
1511 /* Only adjust the export class if the symbol was referenced
1512 and not defined, otherwise leave it alone. */
1514 && (h->root.type == bfd_link_hash_new
1515 || h->root.type == bfd_link_hash_undefined
1516 || h->root.type == bfd_link_hash_undefweak
1517 || h->root.type == bfd_link_hash_common))
1519 _bfd_elf_link_hash_hide_symbol (&link_info, h, TRUE);
1520 if (ELF_ST_VISIBILITY (h->other) != STV_INTERNAL)
1521 h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN;
1522 /* Don't leave the symbol undefined. Undefined hidden
1523 symbols typically won't have dynamic relocations, but
1524 we most likely will need dynamic relocations for
1525 __ehdr_start if we are building a PIE or shared
1528 ehdr_start_save = h->root;
1529 h->root.type = bfd_link_hash_defined;
1530 h->root.u.def.section = bfd_abs_section_ptr;
1531 h->root.u.def.value = 0;
1535 /* If we are going to make any variable assignments, we need to
1536 let the ELF backend know about them in case the variables are
1537 referred to by dynamic objects. */
1538 lang_for_each_statement (gld${EMULATION_NAME}_find_statement_assignment);
1541 /* Let the ELF backend work out the sizes of any sections required
1542 by dynamic linking. */
1543 rpath = command_line.rpath;
1545 rpath = (const char *) getenv ("LD_RUN_PATH");
1547 for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
1548 if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
1550 const char *audit_libs = elf_dt_audit (abfd);
1552 /* If the input bfd contains an audit entry, we need to add it as
1553 a dep audit entry. */
1554 if (audit_libs && *audit_libs != '\0')
1556 char *cp = xstrdup (audit_libs);
1560 char *cp2 = strchr (cp, config.rpath_separator);
1568 if (cp != NULL && *cp != '\0')
1569 gld${EMULATION_NAME}_append_to_separated_string (&depaudit, cp);
1571 cp = more ? ++cp2 : NULL;
1577 if (! (bfd_elf_size_dynamic_sections
1578 (link_info.output_bfd, command_line.soname, rpath,
1579 command_line.filter_shlib, audit, depaudit,
1580 (const char * const *) command_line.auxiliary_filters,
1581 &link_info, &sinterp)))
1582 einfo ("%P%F: failed to set dynamic section sizes: %E\n");
1584 ${ELF_INTERPRETER_SET_DEFAULT}
1585 /* Let the user override the dynamic linker we are using. */
1586 if (command_line.interpreter != NULL
1589 sinterp->contents = (bfd_byte *) command_line.interpreter;
1590 sinterp->size = strlen (command_line.interpreter) + 1;
1593 /* Look for any sections named .gnu.warning. As a GNU extensions,
1594 we treat such sections as containing warning messages. We print
1595 out the warning message, and then zero out the section size so
1596 that it does not get copied into the output file. */
1599 LANG_FOR_EACH_INPUT_STATEMENT (is)
1605 if (is->flags.just_syms)
1608 s = bfd_get_section_by_name (is->the_bfd, ".gnu.warning");
1613 msg = (char *) xmalloc ((size_t) (sz + 1));
1614 if (! bfd_get_section_contents (is->the_bfd, s, msg,
1616 einfo ("%F%B: Can't read contents of section .gnu.warning: %E\n",
1619 (*link_info.callbacks->warning) (&link_info, msg,
1620 (const char *) NULL, is->the_bfd,
1621 (asection *) NULL, (bfd_vma) 0);
1624 /* Clobber the section size, so that we don't waste space
1625 copying the warning into the output file. If we've already
1626 sized the output section, adjust its size. The adjustment
1627 is on rawsize because targets that size sections early will
1628 have called lang_reset_memory_regions after sizing. */
1629 if (s->output_section != NULL
1630 && s->output_section->rawsize >= s->size)
1631 s->output_section->rawsize -= s->size;
1635 /* Also set SEC_EXCLUDE, so that local symbols defined in the
1636 warning section don't get copied to the output. */
1637 s->flags |= SEC_EXCLUDE | SEC_KEEP;
1641 before_allocation_default ();
1643 if (!bfd_elf_size_dynsym_hash_dynstr (link_info.output_bfd, &link_info))
1644 einfo ("%P%F: failed to set dynamic section sizes: %E\n");
1646 if (ehdr_start != NULL)
1648 /* If we twiddled __ehdr_start to defined earlier, put it back
1650 ehdr_start->root.type = ehdr_start_save.type;
1651 ehdr_start->root.u = ehdr_start_save.u;
1658 if test x"$LDEMUL_OPEN_DYNAMIC_ARCHIVE" != xgld"$EMULATION_NAME"_open_dynamic_archive; then
1661 /* Try to open a dynamic archive. This is where we know that ELF
1662 dynamic libraries have an extension of .so (or .sl on oddball systems
1666 gld${EMULATION_NAME}_open_dynamic_archive
1667 (const char *arch, search_dirs_type *search, lang_input_statement_type *entry)
1669 const char *filename;
1672 bfd_boolean opened = FALSE;
1674 if (! entry->flags.maybe_archive)
1677 filename = entry->filename;
1678 len = strlen (search->name) + strlen (filename);
1679 if (entry->flags.full_name_provided)
1682 string = (char *) xmalloc (len);
1683 sprintf (string, "%s/%s", search->name, filename);
1689 len += strlen (arch) + sizeof "/lib.so";
1690 #ifdef EXTRA_SHLIB_EXTENSION
1691 xlen = (strlen (EXTRA_SHLIB_EXTENSION) > 3
1692 ? strlen (EXTRA_SHLIB_EXTENSION) - 3
1695 string = (char *) xmalloc (len + xlen);
1696 sprintf (string, "%s/lib%s%s.so", search->name, filename, arch);
1697 #ifdef EXTRA_SHLIB_EXTENSION
1698 /* Try the .so extension first. If that fails build a new filename
1699 using EXTRA_SHLIB_EXTENSION. */
1700 opened = ldfile_try_open_bfd (string, entry);
1702 strcpy (string + len - 4, EXTRA_SHLIB_EXTENSION);
1706 if (!opened && !ldfile_try_open_bfd (string, entry))
1712 entry->filename = string;
1714 /* We have found a dynamic object to include in the link. The ELF
1715 backend linker will create a DT_NEEDED entry in the .dynamic
1716 section naming this file. If this file includes a DT_SONAME
1717 entry, it will be used. Otherwise, the ELF linker will just use
1718 the name of the file. For an archive found by searching, like
1719 this one, the DT_NEEDED entry should consist of just the name of
1720 the file, without the path information used to find it. Note
1721 that we only need to do this if we have a dynamic object; an
1722 archive will never be referenced by a DT_NEEDED entry.
1724 FIXME: This approach--using bfd_elf_set_dt_needed_name--is not
1725 very pretty. I haven't been able to think of anything that is
1727 if (bfd_check_format (entry->the_bfd, bfd_object)
1728 && (entry->the_bfd->flags & DYNAMIC) != 0)
1730 ASSERT (entry->flags.maybe_archive && entry->flags.search_dirs);
1732 /* Rather than duplicating the logic above. Just use the
1733 filename we recorded earlier. */
1735 if (!entry->flags.full_name_provided)
1736 filename = lbasename (entry->filename);
1737 bfd_elf_set_dt_needed_name (entry->the_bfd, filename);
1746 if test x"$LDEMUL_PLACE_ORPHAN" != xgld"$EMULATION_NAME"_place_orphan; then
1749 /* A variant of lang_output_section_find used by place_orphan. */
1751 static lang_output_section_statement_type *
1752 output_rel_find (asection *sec, int isdyn)
1754 lang_output_section_statement_type *lookup;
1755 lang_output_section_statement_type *last = NULL;
1756 lang_output_section_statement_type *last_alloc = NULL;
1757 lang_output_section_statement_type *last_ro_alloc = NULL;
1758 lang_output_section_statement_type *last_rel = NULL;
1759 lang_output_section_statement_type *last_rel_alloc = NULL;
1760 int rela = sec->name[4] == 'a';
1762 for (lookup = &lang_output_section_statement.head->output_section_statement;
1764 lookup = lookup->next)
1766 if (lookup->constraint >= 0
1767 && CONST_STRNEQ (lookup->name, ".rel"))
1769 int lookrela = lookup->name[4] == 'a';
1771 /* .rel.dyn must come before all other reloc sections, to suit
1776 /* Don't place after .rel.plt as doing so results in wrong
1778 if (strcmp (".plt", lookup->name + 4 + lookrela) == 0)
1781 if (rela == lookrela || last_rel == NULL)
1783 if ((rela == lookrela || last_rel_alloc == NULL)
1784 && lookup->bfd_section != NULL
1785 && (lookup->bfd_section->flags & SEC_ALLOC) != 0)
1786 last_rel_alloc = lookup;
1790 if (lookup->bfd_section != NULL
1791 && (lookup->bfd_section->flags & SEC_ALLOC) != 0)
1793 last_alloc = lookup;
1794 if ((lookup->bfd_section->flags & SEC_READONLY) != 0)
1795 last_ro_alloc = lookup;
1800 return last_rel_alloc;
1806 return last_ro_alloc;
1814 /* Place an orphan section. We use this to put random SHF_ALLOC
1815 sections in the right segment. */
1817 static lang_output_section_statement_type *
1818 gld${EMULATION_NAME}_place_orphan (asection *s,
1819 const char *secname,
1822 static struct orphan_save hold[] =
1825 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE,
1828 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA,
1831 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_THREAD_LOCAL,
1834 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_DATA,
1840 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA,
1843 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA,
1846 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_SMALL_DATA,
1852 enum orphan_save_index
1864 static int orphan_init_done = 0;
1865 struct orphan_save *place;
1866 lang_output_section_statement_type *after;
1867 lang_output_section_statement_type *os;
1868 lang_output_section_statement_type *match_by_name = NULL;
1870 int iself = s->owner->xvec->flavour == bfd_target_elf_flavour;
1871 unsigned int sh_type = iself ? elf_section_type (s) : SHT_NULL;
1875 if (!bfd_link_relocatable (&link_info)
1876 && link_info.combreloc
1877 && (s->flags & SEC_ALLOC))
1883 secname = ".rela.dyn";
1887 secname = ".rel.dyn";
1893 else if (CONST_STRNEQ (secname, ".rel"))
1895 secname = secname[4] == 'a' ? ".rela.dyn" : ".rel.dyn";
1900 /* Look through the script to see where to place this section. */
1901 if (constraint == 0)
1902 for (os = lang_output_section_find (secname);
1904 os = next_matching_output_section_statement (os, 0))
1906 /* If we don't match an existing output section, tell
1907 lang_insert_orphan to create a new output section. */
1908 constraint = SPECIAL;
1910 if (os->bfd_section != NULL
1911 && (os->bfd_section->flags == 0
1912 || (((s->flags ^ os->bfd_section->flags)
1913 & (SEC_LOAD | SEC_ALLOC)) == 0
1914 && _bfd_elf_match_sections_by_type (link_info.output_bfd,
1918 /* We already have an output section statement with this
1919 name, and its bfd section has compatible flags.
1920 If the section already exists but does not have any flags
1921 set, then it has been created by the linker, probably as a
1922 result of a --section-start command line switch. */
1923 lang_add_section (&os->children, s, NULL, os);
1927 /* Save unused output sections in case we can match them
1928 against orphans later. */
1929 if (os->bfd_section == NULL)
1933 /* If we didn't match an active output section, see if we matched an
1934 unused one and use that. */
1937 lang_add_section (&match_by_name->children, s, NULL, match_by_name);
1938 return match_by_name;
1941 if (!orphan_init_done)
1943 struct orphan_save *ho;
1945 for (ho = hold; ho < hold + sizeof (hold) / sizeof (hold[0]); ++ho)
1946 if (ho->name != NULL)
1948 ho->os = lang_output_section_find (ho->name);
1949 if (ho->os != NULL && ho->os->flags == 0)
1950 ho->os->flags = ho->flags;
1952 orphan_init_done = 1;
1955 /* If this is a final link, then always put .gnu.warning.SYMBOL
1956 sections into the .text section to get them out of the way. */
1957 if (bfd_link_executable (&link_info)
1958 && CONST_STRNEQ (s->name, ".gnu.warning.")
1959 && hold[orphan_text].os != NULL)
1961 os = hold[orphan_text].os;
1962 lang_add_section (&os->children, s, NULL, os);
1967 if (!bfd_link_relocatable (&link_info))
1970 while ((nexts = bfd_get_next_section_by_name (nexts->owner, nexts))
1972 if (nexts->output_section == NULL
1973 && (nexts->flags & SEC_EXCLUDE) == 0
1974 && ((nexts->flags ^ flags) & (SEC_LOAD | SEC_ALLOC)) == 0
1975 && (nexts->owner->flags & DYNAMIC) == 0
1976 && nexts->owner->usrdata != NULL
1977 && !(((lang_input_statement_type *) nexts->owner->usrdata)
1979 && _bfd_elf_match_sections_by_type (nexts->owner, nexts,
1981 flags = (((flags ^ SEC_READONLY)
1982 | (nexts->flags ^ SEC_READONLY))
1986 /* Decide which segment the section should go in based on the
1987 section name and section flags. We put loadable .note sections
1988 right after the .interp section, so that the PT_NOTE segment is
1989 stored right after the program headers where the OS can read it
1990 in the first page. */
1993 if ((flags & (SEC_ALLOC | SEC_DEBUGGING)) == 0)
1994 place = &hold[orphan_nonalloc];
1995 else if ((flags & SEC_ALLOC) == 0)
1997 else if ((flags & SEC_LOAD) != 0
1998 && ((iself && sh_type == SHT_NOTE)
1999 || (!iself && CONST_STRNEQ (secname, ".note"))))
2000 place = &hold[orphan_interp];
2001 else if ((flags & (SEC_LOAD | SEC_HAS_CONTENTS | SEC_THREAD_LOCAL)) == 0)
2002 place = &hold[orphan_bss];
2003 else if ((flags & SEC_SMALL_DATA) != 0)
2004 place = &hold[orphan_sdata];
2005 else if ((flags & SEC_THREAD_LOCAL) != 0)
2006 place = &hold[orphan_tdata];
2007 else if ((flags & SEC_READONLY) == 0)
2008 place = &hold[orphan_data];
2009 else if (((iself && (sh_type == SHT_RELA || sh_type == SHT_REL))
2010 || (!iself && CONST_STRNEQ (secname, ".rel")))
2011 && (flags & SEC_LOAD) != 0)
2012 place = &hold[orphan_rel];
2013 else if ((flags & SEC_CODE) == 0)
2014 place = &hold[orphan_rodata];
2016 place = &hold[orphan_text];
2021 if (place->os == NULL)
2023 if (place->name != NULL)
2024 place->os = lang_output_section_find (place->name);
2026 place->os = output_rel_find (s, isdyn);
2031 = lang_output_section_find_by_flags (s, flags, &place->os,
2032 _bfd_elf_match_sections_by_type);
2034 /* *ABS* is always the first output section statement. */
2035 after = &lang_output_section_statement.head->output_section_statement;
2038 return lang_insert_orphan (s, secname, constraint, after, place, NULL, NULL);
2043 if test x"$LDEMUL_AFTER_ALLOCATION" != xgld"$EMULATION_NAME"_after_allocation; then
2047 gld${EMULATION_NAME}_after_allocation (void)
2049 int need_layout = bfd_elf_discard_info (link_info.output_bfd, &link_info);
2051 if (need_layout < 0)
2052 einfo ("%X%P: .eh_frame/.stab edit: %E\n");
2054 gld${EMULATION_NAME}_map_segments (need_layout);
2059 if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then
2063 gld${EMULATION_NAME}_get_script (int *isfile)
2066 if test x"$COMPILE_IN" = xyes
2068 # Scripts compiled in.
2070 # sed commands to quote an ld script as a C string.
2071 sc="-f stringify.sed"
2077 if (bfd_link_relocatable (&link_info) && config.build_constructors)
2080 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
2081 echo ' ; else if (bfd_link_relocatable (&link_info)) return' >> e${EMULATION_NAME}.c
2082 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
2083 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
2084 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
2085 if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then : ; else
2086 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
2087 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
2089 if test -n "$GENERATE_PIE_SCRIPT" ; then
2090 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
2091 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
2092 echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c
2093 echo ' && link_info.relro' >> e${EMULATION_NAME}.c
2094 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
2095 sed $sc ldscripts/${EMULATION_NAME}.xdw >> e${EMULATION_NAME}.c
2096 echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c
2097 echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c
2098 sed $sc ldscripts/${EMULATION_NAME}.xdc >> e${EMULATION_NAME}.c
2100 echo ' ; else if (bfd_link_pie (&link_info)) return' >> e${EMULATION_NAME}.c
2101 sed $sc ldscripts/${EMULATION_NAME}.xd >> e${EMULATION_NAME}.c
2103 if test -n "$GENERATE_SHLIB_SCRIPT" ; then
2104 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
2105 echo ' ; else if (bfd_link_dll (&link_info) && link_info.combreloc' >> e${EMULATION_NAME}.c
2106 echo ' && link_info.relro' >> e${EMULATION_NAME}.c
2107 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
2108 sed $sc ldscripts/${EMULATION_NAME}.xsw >> e${EMULATION_NAME}.c
2109 echo ' ; else if (bfd_link_dll (&link_info) && link_info.combreloc) return' >> e${EMULATION_NAME}.c
2110 sed $sc ldscripts/${EMULATION_NAME}.xsc >> e${EMULATION_NAME}.c
2112 echo ' ; else if (bfd_link_dll (&link_info)) return' >> e${EMULATION_NAME}.c
2113 sed $sc ldscripts/${EMULATION_NAME}.xs >> e${EMULATION_NAME}.c
2115 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
2116 echo ' ; else if (link_info.combreloc && link_info.relro' >> e${EMULATION_NAME}.c
2117 echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
2118 sed $sc ldscripts/${EMULATION_NAME}.xw >> e${EMULATION_NAME}.c
2119 echo ' ; else if (link_info.combreloc) return' >> e${EMULATION_NAME}.c
2120 sed $sc ldscripts/${EMULATION_NAME}.xc >> e${EMULATION_NAME}.c
2122 echo ' ; else return' >> e${EMULATION_NAME}.c
2123 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
2124 echo '; }' >> e${EMULATION_NAME}.c
2127 # Scripts read from the filesystem.
2133 if (bfd_link_relocatable (&link_info) && config.build_constructors)
2134 return "ldscripts/${EMULATION_NAME}.xu";
2135 else if (bfd_link_relocatable (&link_info))
2136 return "ldscripts/${EMULATION_NAME}.xr";
2137 else if (!config.text_read_only)
2138 return "ldscripts/${EMULATION_NAME}.xbn";
2140 if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then :
2143 else if (!config.magic_demand_paged)
2144 return "ldscripts/${EMULATION_NAME}.xn";
2147 if test -n "$GENERATE_PIE_SCRIPT" ; then
2148 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
2150 else if (bfd_link_pie (&link_info)
2151 && link_info.combreloc
2153 && (link_info.flags & DF_BIND_NOW))
2154 return "ldscripts/${EMULATION_NAME}.xdw";
2155 else if (bfd_link_pie (&link_info)
2156 && link_info.combreloc)
2157 return "ldscripts/${EMULATION_NAME}.xdc";
2161 else if (bfd_link_pie (&link_info))
2162 return "ldscripts/${EMULATION_NAME}.xd";
2165 if test -n "$GENERATE_SHLIB_SCRIPT" ; then
2166 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
2168 else if (bfd_link_dll (&link_info) && link_info.combreloc
2169 && link_info.relro && (link_info.flags & DF_BIND_NOW))
2170 return "ldscripts/${EMULATION_NAME}.xsw";
2171 else if (bfd_link_dll (&link_info) && link_info.combreloc)
2172 return "ldscripts/${EMULATION_NAME}.xsc";
2176 else if (bfd_link_dll (&link_info))
2177 return "ldscripts/${EMULATION_NAME}.xs";
2180 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
2182 else if (link_info.combreloc && link_info.relro
2183 && (link_info.flags & DF_BIND_NOW))
2184 return "ldscripts/${EMULATION_NAME}.xw";
2185 else if (link_info.combreloc)
2186 return "ldscripts/${EMULATION_NAME}.xc";
2191 return "ldscripts/${EMULATION_NAME}.x";
2198 if test -n "$PARSE_AND_LIST_PROLOGUE" ; then
2200 $PARSE_AND_LIST_PROLOGUE
2208 OPTION_DISABLE_NEW_DTAGS = 400,
2209 OPTION_ENABLE_NEW_DTAGS,
2211 OPTION_EH_FRAME_HDR,
2212 OPTION_NO_EH_FRAME_HDR,
2213 OPTION_EXCLUDE_LIBS,
2217 OPTION_COMPRESS_DEBUG
2221 gld${EMULATION_NAME}_add_options
2222 (int ns, char **shortopts, int nl, struct option **longopts,
2223 int nrl ATTRIBUTE_UNUSED, struct option **really_longopts ATTRIBUTE_UNUSED)
2226 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
2228 static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:P:";
2232 static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:";
2236 static const struct option xtra_long[] = {
2238 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
2240 {"audit", required_argument, NULL, OPTION_AUDIT},
2241 {"Bgroup", no_argument, NULL, OPTION_GROUP},
2245 {"build-id", optional_argument, NULL, OPTION_BUILD_ID},
2246 {"compress-debug-sections", required_argument, NULL, OPTION_COMPRESS_DEBUG},
2248 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
2250 {"depaudit", required_argument, NULL, 'P'},
2251 {"disable-new-dtags", no_argument, NULL, OPTION_DISABLE_NEW_DTAGS},
2252 {"enable-new-dtags", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS},
2253 {"eh-frame-hdr", no_argument, NULL, OPTION_EH_FRAME_HDR},
2254 {"no-eh-frame-hdr", no_argument, NULL, OPTION_NO_EH_FRAME_HDR},
2255 {"exclude-libs", required_argument, NULL, OPTION_EXCLUDE_LIBS},
2256 {"hash-style", required_argument, NULL, OPTION_HASH_STYLE},
2259 if test -n "$PARSE_AND_LIST_LONGOPTS" ; then
2261 $PARSE_AND_LIST_LONGOPTS
2265 {NULL, no_argument, NULL, 0}
2268 *shortopts = (char *) xrealloc (*shortopts, ns + sizeof (xtra_short));
2269 memcpy (*shortopts + ns, &xtra_short, sizeof (xtra_short));
2270 *longopts = (struct option *)
2271 xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
2272 memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
2275 #define DEFAULT_BUILD_ID_STYLE "sha1"
2278 gld${EMULATION_NAME}_handle_option (int optc)
2285 case OPTION_BUILD_ID:
2286 if (emit_note_gnu_build_id != NULL)
2288 free ((char *) emit_note_gnu_build_id);
2289 emit_note_gnu_build_id = NULL;
2292 optarg = DEFAULT_BUILD_ID_STYLE;
2293 if (strcmp (optarg, "none"))
2294 emit_note_gnu_build_id = xstrdup (optarg);
2297 case OPTION_COMPRESS_DEBUG:
2298 if (strcasecmp (optarg, "none") == 0)
2299 link_info.compress_debug = COMPRESS_DEBUG_NONE;
2300 else if (strcasecmp (optarg, "zlib") == 0)
2301 link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB;
2302 else if (strcasecmp (optarg, "zlib-gnu") == 0)
2303 link_info.compress_debug = COMPRESS_DEBUG_GNU_ZLIB;
2304 else if (strcasecmp (optarg, "zlib-gabi") == 0)
2305 link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB;
2307 einfo (_("%P%F: invalid --compress-debug-sections option: \`%s'\n"),
2312 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
2315 gld${EMULATION_NAME}_append_to_separated_string (&audit, optarg);
2319 gld${EMULATION_NAME}_append_to_separated_string (&depaudit, optarg);
2322 case OPTION_DISABLE_NEW_DTAGS:
2323 link_info.new_dtags = FALSE;
2326 case OPTION_ENABLE_NEW_DTAGS:
2327 link_info.new_dtags = TRUE;
2330 case OPTION_EH_FRAME_HDR:
2331 link_info.eh_frame_hdr_type = DWARF2_EH_HDR;
2334 case OPTION_NO_EH_FRAME_HDR:
2335 link_info.eh_frame_hdr_type = 0;
2339 link_info.flags_1 |= (bfd_vma) DF_1_GROUP;
2340 /* Groups must be self-contained. */
2341 link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
2342 link_info.unresolved_syms_in_shared_libs = RM_GENERATE_ERROR;
2345 case OPTION_EXCLUDE_LIBS:
2346 add_excluded_libs (optarg);
2349 case OPTION_HASH_STYLE:
2350 link_info.emit_hash = FALSE;
2351 link_info.emit_gnu_hash = FALSE;
2352 if (strcmp (optarg, "sysv") == 0)
2353 link_info.emit_hash = TRUE;
2354 else if (strcmp (optarg, "gnu") == 0)
2355 link_info.emit_gnu_hash = TRUE;
2356 else if (strcmp (optarg, "both") == 0)
2358 link_info.emit_hash = TRUE;
2359 link_info.emit_gnu_hash = TRUE;
2362 einfo (_("%P%F: invalid hash style \`%s'\n"), optarg);
2369 if (strcmp (optarg, "defs") == 0)
2370 link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
2371 else if (strcmp (optarg, "muldefs") == 0)
2372 link_info.allow_multiple_definition = TRUE;
2373 else if (CONST_STRNEQ (optarg, "max-page-size="))
2377 config.maxpagesize = strtoul (optarg + 14, &end, 0);
2378 if (*end || (config.maxpagesize & (config.maxpagesize - 1)) != 0)
2379 einfo (_("%P%F: invalid maxium page size \`%s'\n"),
2382 else if (CONST_STRNEQ (optarg, "common-page-size="))
2385 config.commonpagesize = strtoul (optarg + 17, &end, 0);
2387 || (config.commonpagesize & (config.commonpagesize - 1)) != 0)
2388 einfo (_("%P%F: invalid common page size \`%s'\n"),
2391 else if (CONST_STRNEQ (optarg, "stack-size="))
2394 link_info.stacksize = strtoul (optarg + 11, &end, 0);
2395 if (*end || link_info.stacksize < 0)
2396 einfo (_("%P%F: invalid stack size \`%s'\n"), optarg + 11);
2397 if (!link_info.stacksize)
2398 /* Use -1 for explicit no-stack, because zero means
2400 link_info.stacksize = -1;
2402 else if (strcmp (optarg, "execstack") == 0)
2404 link_info.execstack = TRUE;
2405 link_info.noexecstack = FALSE;
2407 else if (strcmp (optarg, "noexecstack") == 0)
2409 link_info.noexecstack = TRUE;
2410 link_info.execstack = FALSE;
2414 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
2416 else if (strcmp (optarg, "global") == 0)
2417 link_info.flags_1 |= (bfd_vma) DF_1_GLOBAL;
2418 else if (strcmp (optarg, "initfirst") == 0)
2419 link_info.flags_1 |= (bfd_vma) DF_1_INITFIRST;
2420 else if (strcmp (optarg, "interpose") == 0)
2421 link_info.flags_1 |= (bfd_vma) DF_1_INTERPOSE;
2422 else if (strcmp (optarg, "loadfltr") == 0)
2423 link_info.flags_1 |= (bfd_vma) DF_1_LOADFLTR;
2424 else if (strcmp (optarg, "nodefaultlib") == 0)
2425 link_info.flags_1 |= (bfd_vma) DF_1_NODEFLIB;
2426 else if (strcmp (optarg, "nodelete") == 0)
2427 link_info.flags_1 |= (bfd_vma) DF_1_NODELETE;
2428 else if (strcmp (optarg, "nodlopen") == 0)
2429 link_info.flags_1 |= (bfd_vma) DF_1_NOOPEN;
2430 else if (strcmp (optarg, "nodump") == 0)
2431 link_info.flags_1 |= (bfd_vma) DF_1_NODUMP;
2432 else if (strcmp (optarg, "now") == 0)
2434 link_info.flags |= (bfd_vma) DF_BIND_NOW;
2435 link_info.flags_1 |= (bfd_vma) DF_1_NOW;
2437 else if (strcmp (optarg, "lazy") == 0)
2439 link_info.flags &= ~(bfd_vma) DF_BIND_NOW;
2440 link_info.flags_1 &= ~(bfd_vma) DF_1_NOW;
2442 else if (strcmp (optarg, "origin") == 0)
2444 link_info.flags |= (bfd_vma) DF_ORIGIN;
2445 link_info.flags_1 |= (bfd_vma) DF_1_ORIGIN;
2447 else if (strcmp (optarg, "combreloc") == 0)
2448 link_info.combreloc = TRUE;
2449 else if (strcmp (optarg, "nocombreloc") == 0)
2450 link_info.combreloc = FALSE;
2451 else if (strcmp (optarg, "nocopyreloc") == 0)
2452 link_info.nocopyreloc = TRUE;
2453 else if (strcmp (optarg, "relro") == 0)
2454 link_info.relro = TRUE;
2455 else if (strcmp (optarg, "norelro") == 0)
2456 link_info.relro = FALSE;
2457 else if (strcmp (optarg, "common") == 0)
2458 link_info.elf_stt_common = elf_stt_common;
2459 else if (strcmp (optarg, "nocommon") == 0)
2460 link_info.elf_stt_common = no_elf_stt_common;
2461 else if (strcmp (optarg, "text") == 0)
2462 link_info.error_textrel = TRUE;
2463 else if (strcmp (optarg, "notext") == 0)
2464 link_info.error_textrel = FALSE;
2465 else if (strcmp (optarg, "textoff") == 0)
2466 link_info.error_textrel = FALSE;
2470 if test -n "$PARSE_AND_LIST_ARGS_CASE_Z" ; then
2472 $PARSE_AND_LIST_ARGS_CASE_Z
2478 einfo (_("%P: warning: -z %s ignored.\n"), optarg);
2482 if test -n "$PARSE_AND_LIST_ARGS_CASES" ; then
2484 $PARSE_AND_LIST_ARGS_CASES
2496 if test x"$LDEMUL_LIST_OPTIONS" != xgld"$EMULATION_NAME"_list_options; then
2497 gld_list_options="gld${EMULATION_NAME}_list_options"
2498 if test -n "$PARSE_AND_LIST_OPTIONS"; then
2502 gld${EMULATION_NAME}_list_options (FILE * file)
2506 if test -n "$PARSE_AND_LIST_OPTIONS" ; then
2508 $PARSE_AND_LIST_OPTIONS
2516 gld_list_options="NULL"
2519 if test -n "$PARSE_AND_LIST_EPILOGUE" ; then
2521 $PARSE_AND_LIST_EPILOGUE
2528 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
2530 ${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse},
2531 ${LDEMUL_SYSLIB-syslib_default},
2532 ${LDEMUL_HLL-hll_default},
2533 ${LDEMUL_AFTER_PARSE-gld${EMULATION_NAME}_after_parse},
2534 ${LDEMUL_AFTER_OPEN-gld${EMULATION_NAME}_after_open},
2535 ${LDEMUL_AFTER_ALLOCATION-gld${EMULATION_NAME}_after_allocation},
2536 ${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
2537 ${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
2538 ${LDEMUL_BEFORE_ALLOCATION-gld${EMULATION_NAME}_before_allocation},
2539 ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
2540 "${EMULATION_NAME}",
2542 ${LDEMUL_FINISH-finish_default},
2543 ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL},
2544 ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-gld${EMULATION_NAME}_open_dynamic_archive},
2545 ${LDEMUL_PLACE_ORPHAN-gld${EMULATION_NAME}_place_orphan},
2546 ${LDEMUL_SET_SYMBOLS-NULL},
2547 ${LDEMUL_PARSE_ARGS-NULL},
2548 gld${EMULATION_NAME}_add_options,
2549 gld${EMULATION_NAME}_handle_option,
2550 ${LDEMUL_UNRECOGNIZED_FILE-NULL},
2551 ${LDEMUL_LIST_OPTIONS-${gld_list_options}},
2552 ${LDEMUL_RECOGNIZED_FILE-gld${EMULATION_NAME}_load_symbols},
2553 ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL},
2554 ${LDEMUL_NEW_VERS_PATTERN-NULL},
2555 ${LDEMUL_EXTRA_MAP_FILE_TEXT-NULL}