Deleted Added
full compact
elf32.em (76232) elf32.em (77319)
1# $FreeBSD: head/contrib/binutils/ld/emultempl/elf32.em 76232 2001-05-03 01:49:58Z obrien $
1# $FreeBSD: head/contrib/binutils/ld/emultempl/elf32.em 77319 2001-05-28 06:21:27Z obrien $
2
3
2# This shell script emits a C file. -*- C -*-
3# It does some substitutions.
4# This file is now misnamed, because it supports both 32 bit and 64 bit
5# ELF emulations.
6test -z "${ELFSIZE}" && ELFSIZE=32
7cat >e${EMULATION_NAME}.c <<EOF
8/* This file is is generated by a shell script. DO NOT EDIT! */
9
10/* ${ELFSIZE} bit ELF emulation code for ${EMULATION_NAME}
4# This shell script emits a C file. -*- C -*-
5# It does some substitutions.
6# This file is now misnamed, because it supports both 32 bit and 64 bit
7# ELF emulations.
8test -z "${ELFSIZE}" && ELFSIZE=32
9cat >e${EMULATION_NAME}.c <<EOF
10/* This file is is generated by a shell script. DO NOT EDIT! */
11
12/* ${ELFSIZE} bit ELF emulation code for ${EMULATION_NAME}
11 Copyright (C) 1991, 93, 94, 95, 96, 97, 98, 99, 2000
13 Copyright (C) 1991, 93, 94, 95, 96, 97, 98, 99, 2000, 2001
12 Free Software Foundation, Inc.
13 Written by Steve Chamberlain <sac@cygnus.com>
14 ELF support by Ian Lance Taylor <ian@cygnus.com>
15
16This file is part of GLD, the Gnu Linker.
17
18This program is free software; you can redistribute it and/or modify
19it under the terms of the GNU General Public License as published by

--- 15 unchanged lines hidden (view full) ---

35#include "sysdep.h"
36
37#include <ctype.h>
38
39#include "bfdlink.h"
40
41#include "ld.h"
42#include "ldmain.h"
14 Free Software Foundation, Inc.
15 Written by Steve Chamberlain <sac@cygnus.com>
16 ELF support by Ian Lance Taylor <ian@cygnus.com>
17
18This file is part of GLD, the Gnu Linker.
19
20This program is free software; you can redistribute it and/or modify
21it under the terms of the GNU General Public License as published by

--- 15 unchanged lines hidden (view full) ---

37#include "sysdep.h"
38
39#include <ctype.h>
40
41#include "bfdlink.h"
42
43#include "ld.h"
44#include "ldmain.h"
43#include "ldemul.h"
44#include "ldfile.h"
45#include "ldmisc.h"
46#include "ldexp.h"
47#include "ldlang.h"
45#include "ldmisc.h"
46#include "ldexp.h"
47#include "ldlang.h"
48#include "ldfile.h"
49#include "ldemul.h"
48#include "ldgram.h"
50#include "ldgram.h"
51#include "elf/common.h"
49
50static void gld${EMULATION_NAME}_before_parse PARAMS ((void));
52
53static void gld${EMULATION_NAME}_before_parse PARAMS ((void));
51static boolean gld${EMULATION_NAME}_open_dynamic_archive
52 PARAMS ((const char *, search_dirs_type *, lang_input_statement_type *));
53static void gld${EMULATION_NAME}_after_open PARAMS ((void));
54static void gld${EMULATION_NAME}_check_needed
54static void gld${EMULATION_NAME}_vercheck
55 PARAMS ((lang_input_statement_type *));
56static void gld${EMULATION_NAME}_stat_needed
57 PARAMS ((lang_input_statement_type *));
55 PARAMS ((lang_input_statement_type *));
56static void gld${EMULATION_NAME}_stat_needed
57 PARAMS ((lang_input_statement_type *));
58static boolean gld${EMULATION_NAME}_try_needed PARAMS ((const char *, int));
58static boolean gld${EMULATION_NAME}_search_needed
59 PARAMS ((const char *, const char *, int));
59static boolean gld${EMULATION_NAME}_search_needed
60 PARAMS ((const char *, const char *, int));
60static boolean gld${EMULATION_NAME}_try_needed PARAMS ((const char *, int));
61static void gld${EMULATION_NAME}_vercheck
61static void gld${EMULATION_NAME}_check_needed
62 PARAMS ((lang_input_statement_type *));
62 PARAMS ((lang_input_statement_type *));
63static void gld${EMULATION_NAME}_before_allocation PARAMS ((void));
63static void gld${EMULATION_NAME}_after_open PARAMS ((void));
64static void gld${EMULATION_NAME}_find_exp_assignment PARAMS ((etree_type *));
64static void gld${EMULATION_NAME}_find_statement_assignment
65 PARAMS ((lang_statement_union_type *));
65static void gld${EMULATION_NAME}_find_statement_assignment
66 PARAMS ((lang_statement_union_type *));
66static void gld${EMULATION_NAME}_find_exp_assignment PARAMS ((etree_type *));
67static void gld${EMULATION_NAME}_before_allocation PARAMS ((void));
68static boolean gld${EMULATION_NAME}_open_dynamic_archive
69 PARAMS ((const char *, search_dirs_type *, lang_input_statement_type *));
67static lang_output_section_statement_type *output_rel_find PARAMS ((void));
68static boolean gld${EMULATION_NAME}_place_orphan
69 PARAMS ((lang_input_statement_type *, asection *));
70static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile));
71
70static lang_output_section_statement_type *output_rel_find PARAMS ((void));
71static boolean gld${EMULATION_NAME}_place_orphan
72 PARAMS ((lang_input_statement_type *, asection *));
73static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile));
74
75EOF
76
77# Import any needed special functions and/or overrides.
78#
79if test -n "$EXTRA_EM_FILE" ; then
80. ${srcdir}/emultempl/${EXTRA_EM_FILE}.em
81fi
82
83# Functions in this file can be overridden by setting the LDEMUL_* shell
84# variables. If the name of the overriding function is the same as is
85# defined in this file, then don't output this file's version.
86# If a different overriding name is given then output the standard function
87# as presumably it is called from the overriding function.
88#
89if test x"$LDEMUL_BEFORE_PARSE" != xgld"$EMULATION_NAME"_before_parse; then
90cat >>e${EMULATION_NAME}.c <<EOF
91
72static void
92static void
73gld${EMULATION_NAME}_before_parse()
93gld${EMULATION_NAME}_before_parse ()
74{
75 ldfile_output_architecture = bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`;
76 config.dynamic_link = ${DYNAMIC_LINK-true};
77 config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo true ; else echo false ; fi`;
78}
79
94{
95 ldfile_output_architecture = bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`;
96 config.dynamic_link = ${DYNAMIC_LINK-true};
97 config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo true ; else echo false ; fi`;
98}
99
80/* Try to open a dynamic archive. This is where we know that ELF
81 dynamic libraries have an extension of .so (or .sl on oddball systems
82 like hpux). */
100EOF
101fi
83
102
103cat >>e${EMULATION_NAME}.c <<EOF
104
105/* These variables are required to pass information back and forth
106 between after_open and check_needed and stat_needed and vercheck. */
107
108static struct bfd_link_needed_list *global_needed;
109static struct stat global_stat;
110static boolean global_found;
111static struct bfd_link_needed_list *global_vercheck_needed;
112static boolean global_vercheck_failed;
113
114
115/* On Linux, it's possible to have different versions of the same
116 shared library linked against different versions of libc. The
117 dynamic linker somehow tags which libc version to use in
118 /etc/ld.so.cache, and, based on the libc that it sees in the
119 executable, chooses which version of the shared library to use.
120
121 We try to do a similar check here by checking whether this shared
122 library needs any other shared libraries which may conflict with
123 libraries we have already included in the link. If it does, we
124 skip it, and try to find another shared library farther on down the
125 link path.
126
127 This is called via lang_for_each_input_file.
128 GLOBAL_VERCHECK_NEEDED is the list of objects needed by the object
129 which we are checking. This sets GLOBAL_VERCHECK_FAILED if we find
130 a conflicting version. */
131
132static void
133gld${EMULATION_NAME}_vercheck (s)
134 lang_input_statement_type *s;
135{
136 const char *soname, *f;
137 struct bfd_link_needed_list *l;
138
139 if (global_vercheck_failed)
140 return;
141 if (s->the_bfd == NULL
142 || (bfd_get_file_flags (s->the_bfd) & DYNAMIC) == 0)
143 return;
144
145 soname = bfd_elf_get_dt_soname (s->the_bfd);
146 if (soname == NULL)
147 soname = bfd_get_filename (s->the_bfd);
148
149 f = strrchr (soname, '/');
150 if (f != NULL)
151 ++f;
152 else
153 f = soname;
154
155 for (l = global_vercheck_needed; l != NULL; l = l->next)
156 {
157 const char *suffix;
158
159 if (strcmp (f, l->name) == 0)
160 {
161 /* Probably can't happen, but it's an easy check. */
162 continue;
163 }
164
165 if (strchr (l->name, '/') != NULL)
166 continue;
167
168 suffix = strstr (l->name, ".so.");
169 if (suffix == NULL)
170 continue;
171
172 suffix += sizeof ".so." - 1;
173
174 if (strncmp (f, l->name, suffix - l->name) == 0)
175 {
176 /* Here we know that S is a dynamic object FOO.SO.VER1, and
177 the object we are considering needs a dynamic object
178 FOO.SO.VER2, and VER1 and VER2 are different. This
179 appears to be a version mismatch, so we tell the caller
180 to try a different version of this library. */
181 global_vercheck_failed = true;
182 return;
183 }
184 }
185}
186
187
188/* See if an input file matches a DT_NEEDED entry by running stat on
189 the file. */
190
191static void
192gld${EMULATION_NAME}_stat_needed (s)
193 lang_input_statement_type *s;
194{
195 struct stat st;
196 const char *suffix;
197 const char *soname;
198 const char *f;
199
200 if (global_found)
201 return;
202 if (s->the_bfd == NULL)
203 return;
204
205 if (bfd_stat (s->the_bfd, &st) != 0)
206 {
207 einfo ("%P:%B: bfd_stat failed: %E\n", s->the_bfd);
208 return;
209 }
210
211 if (st.st_dev == global_stat.st_dev
212 && st.st_ino == global_stat.st_ino)
213 {
214 global_found = true;
215 return;
216 }
217
218 /* We issue a warning if it looks like we are including two
219 different versions of the same shared library. For example,
220 there may be a problem if -lc picks up libc.so.6 but some other
221 shared library has a DT_NEEDED entry of libc.so.5. This is a
222 heuristic test, and it will only work if the name looks like
223 NAME.so.VERSION. FIXME: Depending on file names is error-prone.
224 If we really want to issue warnings about mixing version numbers
225 of shared libraries, we need to find a better way. */
226
227 if (strchr (global_needed->name, '/') != NULL)
228 return;
229 suffix = strstr (global_needed->name, ".so.");
230 if (suffix == NULL)
231 return;
232 suffix += sizeof ".so." - 1;
233
234 soname = bfd_elf_get_dt_soname (s->the_bfd);
235 if (soname == NULL)
236 soname = s->filename;
237
238 f = strrchr (soname, '/');
239 if (f != NULL)
240 ++f;
241 else
242 f = soname;
243
244 if (strncmp (f, global_needed->name, suffix - global_needed->name) == 0)
245 einfo ("%P: warning: %s, needed by %B, may conflict with %s\n",
246 global_needed->name, global_needed->by, f);
247}
248
249
250/* This function is called for each possible name for a dynamic object
251 named by a DT_NEEDED entry. The FORCE parameter indicates whether
252 to skip the check for a conflicting version. */
253
84static boolean
254static boolean
85gld${EMULATION_NAME}_open_dynamic_archive (arch, search, entry)
86 const char *arch;
87 search_dirs_type *search;
88 lang_input_statement_type *entry;
255gld${EMULATION_NAME}_try_needed (name, force)
256 const char *name;
257 int force;
89{
258{
90 const char *filename;
91 char *string;
259 bfd *abfd;
260 const char *soname;
92
261
93 if (! entry->is_archive)
262 abfd = bfd_openr (name, bfd_get_target (output_bfd));
263 if (abfd == NULL)
94 return false;
264 return false;
265 if (! bfd_check_format (abfd, bfd_object))
266 {
267 (void) bfd_close (abfd);
268 return false;
269 }
270 if ((bfd_get_file_flags (abfd) & DYNAMIC) == 0)
271 {
272 (void) bfd_close (abfd);
273 return false;
274 }
95
275
96 filename = entry->filename;
276 /* Check whether this object would include any conflicting library
277 versions. If FORCE is set, then we skip this check; we use this
278 the second time around, if we couldn't find any compatible
279 instance of the shared library. */
97
280
98 /* This allocates a few bytes too many when EXTRA_SHLIB_EXTENSION
99 is defined, but it does not seem worth the headache to optimize
100 away those two bytes of space. */
101 string = (char *) xmalloc (strlen (search->name)
102 + strlen (filename)
103 + strlen (arch)
104#ifdef EXTRA_SHLIB_EXTENSION
105 + strlen (EXTRA_SHLIB_EXTENSION)
106#endif
107 + sizeof "/lib.so");
281 if (! force)
282 {
283 struct bfd_link_needed_list *needed;
108
284
109 sprintf (string, "%s/lib%s%s.so", search->name, filename, arch);
285 if (! bfd_elf_get_bfd_needed_list (abfd, &needed))
286 einfo ("%F%P:%B: bfd_elf_get_bfd_needed_list failed: %E\n", abfd);
110
287
111#ifdef EXTRA_SHLIB_EXTENSION
112 /* Try the .so extension first. If that fails build a new filename
113 using EXTRA_SHLIB_EXTENSION. */
114 if (! ldfile_try_open_bfd (string, entry))
115 sprintf (string, "%s/lib%s%s%s", search->name,
116 filename, arch, EXTRA_SHLIB_EXTENSION);
117#endif
288 if (needed != NULL)
289 {
290 global_vercheck_needed = needed;
291 global_vercheck_failed = false;
292 lang_for_each_input_file (gld${EMULATION_NAME}_vercheck);
293 if (global_vercheck_failed)
294 {
295 (void) bfd_close (abfd);
296 /* Return false to force the caller to move on to try
297 another file on the search path. */
298 return false;
299 }
118
300
119 if (! ldfile_try_open_bfd (string, entry))
301 /* But wait! It gets much worse. On Linux, if a shared
302 library does not use libc at all, we are supposed to skip
303 it the first time around in case we encounter a shared
304 library later on with the same name which does use the
305 version of libc that we want. This is much too horrible
306 to use on any system other than Linux. */
307
308EOF
309case ${target} in
310 *-*-linux-gnu*)
311 cat >>e${EMULATION_NAME}.c <<EOF
312 {
313 struct bfd_link_needed_list *l;
314
315 for (l = needed; l != NULL; l = l->next)
316 if (strncmp (l->name, "libc.so", 7) == 0)
317 break;
318 if (l == NULL)
319 {
320 (void) bfd_close (abfd);
321 return false;
322 }
323 }
324
325EOF
326 ;;
327esac
328cat >>e${EMULATION_NAME}.c <<EOF
329 }
330 }
331
332 /* We've found a dynamic object matching the DT_NEEDED entry. */
333
334 /* We have already checked that there is no other input file of the
335 same name. We must now check again that we are not including the
336 same file twice. We need to do this because on many systems
337 libc.so is a symlink to, e.g., libc.so.1. The SONAME entry will
338 reference libc.so.1. If we have already included libc.so, we
339 don't want to include libc.so.1 if they are the same file, and we
340 can only check that using stat. */
341
342 if (bfd_stat (abfd, &global_stat) != 0)
343 einfo ("%F%P:%B: bfd_stat failed: %E\n", abfd);
344
345 /* First strip off everything before the last '/'. */
346 soname = strrchr (abfd->filename, '/');
347 if (soname)
348 soname++;
349 else
350 soname = abfd->filename;
351
352 if (trace_file_tries)
353 info_msg (_("found %s at %s\n"), soname, name);
354
355 global_found = false;
356 lang_for_each_input_file (gld${EMULATION_NAME}_stat_needed);
357 if (global_found)
120 {
358 {
121 free (string);
122 return false;
359 /* Return true to indicate that we found the file, even though
360 we aren't going to do anything with it. */
361 return true;
123 }
124
362 }
363
125 entry->filename = string;
364 /* Tell the ELF backend that we don't want the output file to have a
365 DT_NEEDED entry for this file. */
366 bfd_elf_set_dt_needed_name (abfd, "");
126
367
127 /* We have found a dynamic object to include in the link. The ELF
128 backend linker will create a DT_NEEDED entry in the .dynamic
129 section naming this file. If this file includes a DT_SONAME
130 entry, it will be used. Otherwise, the ELF linker will just use
131 the name of the file. For an archive found by searching, like
132 this one, the DT_NEEDED entry should consist of just the name of
133 the file, without the path information used to find it. Note
134 that we only need to do this if we have a dynamic object; an
135 archive will never be referenced by a DT_NEEDED entry.
368 /* Tell the ELF backend that the output file needs a DT_NEEDED
369 entry for this file if it is used to resolve the reference in
370 a regular object. */
371 bfd_elf_set_dt_needed_soname (abfd, soname);
136
372
137 FIXME: This approach--using bfd_elf_set_dt_needed_name--is not
138 very pretty. I haven't been able to think of anything that is
139 pretty, though. */
140 if (bfd_check_format (entry->the_bfd, bfd_object)
141 && (entry->the_bfd->flags & DYNAMIC) != 0)
373 /* Add this file into the symbol table. */
374 if (! bfd_link_add_symbols (abfd, &link_info))
375 einfo ("%F%B: could not read symbols: %E\n", abfd);
376
377 return true;
378}
379
380
381/* Search for a needed file in a path. */
382
383static boolean
384gld${EMULATION_NAME}_search_needed (path, name, force)
385 const char *path;
386 const char *name;
387 int force;
388{
389 const char *s;
390 size_t len;
391
392 if (name[0] == '/')
393 return gld${EMULATION_NAME}_try_needed (name, force);
394
395 if (path == NULL || *path == '\0')
396 return false;
397 len = strlen (name);
398 while (1)
142 {
399 {
143 char *needed_name;
400 char *filename, *sset;
144
401
145 ASSERT (entry->is_archive && entry->search_dirs_flag);
402 s = strchr (path, ':');
403 if (s == NULL)
404 s = path + strlen (path);
146
405
147 /* Rather than duplicating the logic above. Just use the
148 filename we recorded earlier.
406 filename = (char *) xmalloc (s - path + len + 2);
407 if (s == path)
408 sset = filename;
409 else
410 {
411 memcpy (filename, path, s - path);
412 filename[s - path] = '/';
413 sset = filename + (s - path) + 1;
414 }
415 strcpy (sset, name);
149
416
150 First strip off everything before the last '/'. */
151 filename = strrchr (entry->filename, '/');
152 filename++;
417 if (gld${EMULATION_NAME}_try_needed (filename, force))
418 return true;
153
419
154 needed_name = (char *) xmalloc (strlen (filename) + 1);
155 strcpy (needed_name, filename);
156 bfd_elf_set_dt_needed_name (entry->the_bfd, needed_name);
420 free (filename);
421
422 if (*s == '\0')
423 break;
424 path = s + 1;
157 }
158
425 }
426
159 return true;
427 return false;
160}
161
162EOF
163if [ "x${host}" = "x${target}" ] ; then
164 case " ${EMULATION_LIBPATH} " in
165 *" ${EMULATION_NAME} "*)
166 case ${target} in
167 *-*-freebsd*)

--- 50 unchanged lines hidden (view full) ---

218 }
219
220 if (ld_elf_hints == NULL)
221 return false;
222
223 return gld${EMULATION_NAME}_search_needed (ld_elf_hints, name, force);
224}
225EOF
428}
429
430EOF
431if [ "x${host}" = "x${target}" ] ; then
432 case " ${EMULATION_LIBPATH} " in
433 *" ${EMULATION_NAME} "*)
434 case ${target} in
435 *-*-freebsd*)

--- 50 unchanged lines hidden (view full) ---

486 }
487
488 if (ld_elf_hints == NULL)
489 return false;
490
491 return gld${EMULATION_NAME}_search_needed (ld_elf_hints, name, force);
492}
493EOF
494 # FreeBSD
226 ;;
227
495 ;;
496
228 *linux*|*Linux*|*LINUX*)
497 *-*-linux-gnu*)
229 cat >>e${EMULATION_NAME}.c <<EOF
230
231/* For a native linker, check the file /etc/ld.so.conf for directories
232 in which we may find shared libraries. /etc/ld.so.conf is really
233 only meaningful on Linux. */
234
235static boolean gld${EMULATION_NAME}_check_ld_so_conf
236 PARAMS ((const char *, int));

--- 68 unchanged lines hidden (view full) ---

305
306 if (ld_so_conf == NULL)
307 return false;
308
309 return gld${EMULATION_NAME}_search_needed (ld_so_conf, name, force);
310}
311
312EOF
498 cat >>e${EMULATION_NAME}.c <<EOF
499
500/* For a native linker, check the file /etc/ld.so.conf for directories
501 in which we may find shared libraries. /etc/ld.so.conf is really
502 only meaningful on Linux. */
503
504static boolean gld${EMULATION_NAME}_check_ld_so_conf
505 PARAMS ((const char *, int));

--- 68 unchanged lines hidden (view full) ---

574
575 if (ld_so_conf == NULL)
576 return false;
577
578 return gld${EMULATION_NAME}_search_needed (ld_so_conf, name, force);
579}
580
581EOF
582 # Linux
313 ;;
314 esac
315 esac
316fi
317cat >>e${EMULATION_NAME}.c <<EOF
318
583 ;;
584 esac
585 esac
586fi
587cat >>e${EMULATION_NAME}.c <<EOF
588
319/* These variables are required to pass information back and forth
320 between after_open and check_needed and stat_needed and vercheck. */
589/* See if an input file matches a DT_NEEDED entry by name. */
321
590
322static struct bfd_link_needed_list *global_needed;
323static struct stat global_stat;
324static boolean global_found;
325static struct bfd_link_needed_list *global_vercheck_needed;
326static boolean global_vercheck_failed;
591static void
592gld${EMULATION_NAME}_check_needed (s)
593 lang_input_statement_type *s;
594{
595 if (global_found)
596 return;
327
597
598 if (s->filename != NULL)
599 {
600 const char *f;
601
602 if (strcmp (s->filename, global_needed->name) == 0)
603 {
604 global_found = true;
605 return;
606 }
607
608 if (s->search_dirs_flag)
609 {
610 f = strrchr (s->filename, '/');
611 if (f != NULL
612 && strcmp (f + 1, global_needed->name) == 0)
613 {
614 global_found = true;
615 return;
616 }
617 }
618 }
619
620 if (s->the_bfd != NULL)
621 {
622 const char *soname;
623
624 soname = bfd_elf_get_dt_soname (s->the_bfd);
625 if (soname != NULL
626 && strcmp (soname, global_needed->name) == 0)
627 {
628 global_found = true;
629 return;
630 }
631 }
632}
633
634EOF
635
636if test x"$LDEMUL_AFTER_OPEN" != xgld"$EMULATION_NAME"_after_open; then
637cat >>e${EMULATION_NAME}.c <<EOF
638
328/* This is called after all the input files have been opened. */
329
330static void
331gld${EMULATION_NAME}_after_open ()
332{
333 struct bfd_link_needed_list *needed, *l;
334
335 /* We only need to worry about this when doing a final link. */

--- 24 unchanged lines hidden (view full) ---

360
361 /* See if this file was included in the link explicitly. */
362 global_needed = l;
363 global_found = false;
364 lang_for_each_input_file (gld${EMULATION_NAME}_check_needed);
365 if (global_found)
366 continue;
367
639/* This is called after all the input files have been opened. */
640
641static void
642gld${EMULATION_NAME}_after_open ()
643{
644 struct bfd_link_needed_list *needed, *l;
645
646 /* We only need to worry about this when doing a final link. */

--- 24 unchanged lines hidden (view full) ---

671
672 /* See if this file was included in the link explicitly. */
673 global_needed = l;
674 global_found = false;
675 lang_for_each_input_file (gld${EMULATION_NAME}_check_needed);
676 if (global_found)
677 continue;
678
679 if (trace_file_tries)
680 info_msg (_("%s needed by %B\n"), l->name, l->by);
681
368 /* We need to find this file and include the symbol table. We
369 want to search for the file in the same way that the dynamic
370 linker will search. That means that we want to use
371 rpath_link, rpath, then the environment variable
682 /* We need to find this file and include the symbol table. We
683 want to search for the file in the same way that the dynamic
684 linker will search. That means that we want to use
685 rpath_link, rpath, then the environment variable
372 LD_LIBRARY_PATH (native only), then the linker script
373 LIB_SEARCH_DIRS. We do not search using the -L arguments.
686 LD_LIBRARY_PATH (native only), then the DT_RPATH/DT_RUNPATH
687 entries (native only), then the linker script LIB_SEARCH_DIRS.
688 We do not search using the -L arguments.
374
375 We search twice. The first time, we skip objects which may
376 introduce version mismatches. The second time, we force
377 their use. See gld${EMULATION_NAME}_vercheck comment. */
378 for (force = 0; force < 2; force++)
379 {
689
690 We search twice. The first time, we skip objects which may
691 introduce version mismatches. The second time, we force
692 their use. See gld${EMULATION_NAME}_vercheck comment. */
693 for (force = 0; force < 2; force++)
694 {
380 const char *lib_path;
381 size_t len;
382 search_dirs_type *search;
695 size_t len;
696 search_dirs_type *search;
697EOF
698if [ "x${host}" = "x${target}" ] ; then
699 case " ${EMULATION_LIBPATH} " in
700 *" ${EMULATION_NAME} "*)
701cat >>e${EMULATION_NAME}.c <<EOF
702 const char *lib_path;
703 struct bfd_link_needed_list *rp;
704 int found;
705EOF
706 ;;
707 esac
708fi
709cat >>e${EMULATION_NAME}.c <<EOF
383
384 if (gld${EMULATION_NAME}_search_needed (command_line.rpath_link,
385 l->name, force))
386 break;
710
711 if (gld${EMULATION_NAME}_search_needed (command_line.rpath_link,
712 l->name, force))
713 break;
714EOF
715if [ "x${host}" = "x${target}" ] ; then
716 case " ${EMULATION_LIBPATH} " in
717 *" ${EMULATION_NAME} "*)
718cat >>e${EMULATION_NAME}.c <<EOF
387 if (gld${EMULATION_NAME}_search_needed (command_line.rpath,
388 l->name, force))
389 break;
390 if (command_line.rpath_link == NULL
391 && command_line.rpath == NULL)
392 {
393 lib_path = (const char *) getenv ("LD_RUN_PATH");
394 if (gld${EMULATION_NAME}_search_needed (lib_path, l->name,
395 force))
396 break;
397 }
719 if (gld${EMULATION_NAME}_search_needed (command_line.rpath,
720 l->name, force))
721 break;
722 if (command_line.rpath_link == NULL
723 && command_line.rpath == NULL)
724 {
725 lib_path = (const char *) getenv ("LD_RUN_PATH");
726 if (gld${EMULATION_NAME}_search_needed (lib_path, l->name,
727 force))
728 break;
729 }
398EOF
399if [ "x${host}" = "x${target}" ] ; then
400 case " ${EMULATION_LIBPATH} " in
401 *" ${EMULATION_NAME} "*)
402cat >>e${EMULATION_NAME}.c <<EOF
403 lib_path = (const char *) getenv ("LD_LIBRARY_PATH");
404 if (gld${EMULATION_NAME}_search_needed (lib_path, l->name, force))
405 break;
730 lib_path = (const char *) getenv ("LD_LIBRARY_PATH");
731 if (gld${EMULATION_NAME}_search_needed (lib_path, l->name, force))
732 break;
733
734 found = 0;
735 rp = bfd_elf_get_runpath_list (output_bfd, &link_info);
736 for (; !found && rp != NULL; rp = rp->next)
737 {
738 found = (rp->by == l->by
739 && gld${EMULATION_NAME}_search_needed (rp->name,
740 l->name,
741 force));
742 }
743 if (found)
744 break;
745
406EOF
407 ;;
408 esac
409fi
410cat >>e${EMULATION_NAME}.c <<EOF
411 len = strlen (l->name);
412 for (search = search_head; search != NULL; search = search->next)
413 {

--- 15 unchanged lines hidden (view full) ---

429 *" ${EMULATION_NAME} "*)
430 case ${target} in
431 *-*-freebsd*)
432 cat >>e${EMULATION_NAME}.c <<EOF
433 if (gld${EMULATION_NAME}_check_ld_elf_hints (l->name, force))
434 break;
435EOF
436 ;;
746EOF
747 ;;
748 esac
749fi
750cat >>e${EMULATION_NAME}.c <<EOF
751 len = strlen (l->name);
752 for (search = search_head; search != NULL; search = search->next)
753 {

--- 15 unchanged lines hidden (view full) ---

769 *" ${EMULATION_NAME} "*)
770 case ${target} in
771 *-*-freebsd*)
772 cat >>e${EMULATION_NAME}.c <<EOF
773 if (gld${EMULATION_NAME}_check_ld_elf_hints (l->name, force))
774 break;
775EOF
776 ;;
437 *linux*|*Linux*|*LINUX*)
777 *-*-linux-gnu*)
438 cat >>e${EMULATION_NAME}.c <<EOF
439 if (gld${EMULATION_NAME}_check_ld_so_conf (l->name, force))
440 break;
441EOF
778 cat >>e${EMULATION_NAME}.c <<EOF
779 if (gld${EMULATION_NAME}_check_ld_so_conf (l->name, force))
780 break;
781EOF
782 # Linux
442 ;;
443 esac
444 ;;
445 esac
446fi
447cat >>e${EMULATION_NAME}.c <<EOF
448 }
449
450 if (force < 2)
451 continue;
452
453 einfo ("%P: warning: %s, needed by %B, not found (try using -rpath or -rpath-link)\n",
454 l->name, l->by);
455 }
456}
457
783 ;;
784 esac
785 ;;
786 esac
787fi
788cat >>e${EMULATION_NAME}.c <<EOF
789 }
790
791 if (force < 2)
792 continue;
793
794 einfo ("%P: warning: %s, needed by %B, not found (try using -rpath or -rpath-link)\n",
795 l->name, l->by);
796 }
797}
798
458/* Search for a needed file in a path. */
459
460static boolean
461gld${EMULATION_NAME}_search_needed (path, name, force)
462 const char *path;
463 const char *name;
464 int force;
465{
466 const char *s;
467 size_t len;
468
469 if (path == NULL || *path == '\0')
470 return false;
471 len = strlen (name);
472 while (1)
473 {
474 char *filename, *sset;
475
476 s = strchr (path, ':');
477 if (s == NULL)
478 s = path + strlen (path);
479
480 filename = (char *) xmalloc (s - path + len + 2);
481 if (s == path)
482 sset = filename;
483 else
484 {
485 memcpy (filename, path, s - path);
486 filename[s - path] = '/';
487 sset = filename + (s - path) + 1;
488 }
489 strcpy (sset, name);
490
491 if (gld${EMULATION_NAME}_try_needed (filename, force))
492 return true;
493
494 free (filename);
495
496 if (*s == '\0')
497 break;
498 path = s + 1;
499 }
500
501 return false;
502}
503
504/* This function is called for each possible name for a dynamic object
505 named by a DT_NEEDED entry. The FORCE parameter indicates whether
506 to skip the check for a conflicting version. */
507
508static boolean
509gld${EMULATION_NAME}_try_needed (name, force)
510 const char *name;
511 int force;
512{
513 bfd *abfd;
514
515 abfd = bfd_openr (name, bfd_get_target (output_bfd));
516 if (abfd == NULL)
517 return false;
518 if (! bfd_check_format (abfd, bfd_object))
519 {
520 (void) bfd_close (abfd);
521 return false;
522 }
523 if ((bfd_get_file_flags (abfd) & DYNAMIC) == 0)
524 {
525 (void) bfd_close (abfd);
526 return false;
527 }
528
529 /* Check whether this object would include any conflicting library
530 versions. If FORCE is set, then we skip this check; we use this
531 the second time around, if we couldn't find any compatible
532 instance of the shared library. */
533
534 if (! force)
535 {
536 struct bfd_link_needed_list *needed;
537
538 if (! bfd_elf_get_bfd_needed_list (abfd, &needed))
539 einfo ("%F%P:%B: bfd_elf_get_bfd_needed_list failed: %E\n", abfd);
540
541 if (needed != NULL)
542 {
543 global_vercheck_needed = needed;
544 global_vercheck_failed = false;
545 lang_for_each_input_file (gld${EMULATION_NAME}_vercheck);
546 if (global_vercheck_failed)
547 {
548 (void) bfd_close (abfd);
549 /* Return false to force the caller to move on to try
550 another file on the search path. */
551 return false;
552 }
553
554 /* But wait! It gets much worse. On Linux, if a shared
555 library does not use libc at all, we are supposed to skip
556 it the first time around in case we encounter a shared
557 library later on with the same name which does use the
558 version of libc that we want. This is much too horrible
559 to use on any system other than Linux. */
560
561EOF
799EOF
562case ${target} in
563 *-*-linux-gnu*)
564 cat >>e${EMULATION_NAME}.c <<EOF
565 {
566 struct bfd_link_needed_list *l;
800fi
567
801
568 for (l = needed; l != NULL; l = l->next)
569 if (strncmp (l->name, "libc.so", 7) == 0)
570 break;
571 if (l == NULL)
572 {
573 (void) bfd_close (abfd);
574 return false;
575 }
576 }
577
578EOF
579 ;;
580esac
581cat >>e${EMULATION_NAME}.c <<EOF
802cat >>e${EMULATION_NAME}.c <<EOF
582 }
583 }
584
803
585 /* We've found a dynamic object matching the DT_NEEDED entry. */
804/* Look through an expression for an assignment statement. */
586
805
587 /* We have already checked that there is no other input file of the
588 same name. We must now check again that we are not including the
589 same file twice. We need to do this because on many systems
590 libc.so is a symlink to, e.g., libc.so.1. The SONAME entry will
591 reference libc.so.1. If we have already included libc.so, we
592 don't want to include libc.so.1 if they are the same file, and we
593 can only check that using stat. */
594
595 if (bfd_stat (abfd, &global_stat) != 0)
596 einfo ("%F%P:%B: bfd_stat failed: %E\n", abfd);
597 global_found = false;
598 lang_for_each_input_file (gld${EMULATION_NAME}_stat_needed);
599 if (global_found)
600 {
601 /* Return true to indicate that we found the file, even though
602 we aren't going to do anything with it. */
603 return true;
604 }
605
606 /* Tell the ELF backend that don't want the output file to have a
607 DT_NEEDED entry for this file. */
608 bfd_elf_set_dt_needed_name (abfd, "");
609
610 /* Add this file into the symbol table. */
611 if (! bfd_link_add_symbols (abfd, &link_info))
612 einfo ("%F%B: could not read symbols: %E\n", abfd);
613
614 return true;
615}
616
617/* See if an input file matches a DT_NEEDED entry by name. */
618
619static void
806static void
620gld${EMULATION_NAME}_check_needed (s)
621 lang_input_statement_type *s;
807gld${EMULATION_NAME}_find_exp_assignment (exp)
808 etree_type *exp;
622{
809{
623 if (global_found)
624 return;
810 struct bfd_link_hash_entry *h;
625
811
626 if (s->filename != NULL
627 && strcmp (s->filename, global_needed->name) == 0)
812 switch (exp->type.node_class)
628 {
813 {
629 global_found = true;
630 return;
631 }
814 case etree_provide:
815 h = bfd_link_hash_lookup (link_info.hash, exp->assign.dst,
816 false, false, false);
817 if (h == NULL)
818 break;
632
819
633 if (s->the_bfd != NULL)
634 {
635 const char *soname;
820 /* We call record_link_assignment even if the symbol is defined.
821 This is because if it is defined by a dynamic object, we
822 actually want to use the value defined by the linker script,
823 not the value from the dynamic object (because we are setting
824 symbols like etext). If the symbol is defined by a regular
825 object, then, as it happens, calling record_link_assignment
826 will do no harm. */
636
827
637 soname = bfd_elf_get_dt_soname (s->the_bfd);
638 if (soname != NULL
639 && strcmp (soname, global_needed->name) == 0)
828 /* Fall through. */
829 case etree_assign:
830 if (strcmp (exp->assign.dst, ".") != 0)
640 {
831 {
641 global_found = true;
642 return;
832 if (! (bfd_elf${ELFSIZE}_record_link_assignment
833 (output_bfd, &link_info, exp->assign.dst,
834 exp->type.node_class == etree_provide ? true : false)))
835 einfo ("%P%F: failed to record assignment to %s: %E\n",
836 exp->assign.dst);
643 }
837 }
644 }
645
646 if (s->search_dirs_flag
647 && s->filename != NULL
648 && strchr (global_needed->name, '/') == NULL)
649 {
650 const char *f;
838 gld${EMULATION_NAME}_find_exp_assignment (exp->assign.src);
839 break;
651
840
652 f = strrchr (s->filename, '/');
653 if (f != NULL
654 && strcmp (f + 1, global_needed->name) == 0)
655 {
656 global_found = true;
657 return;
658 }
659 }
660}
841 case etree_binary:
842 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.lhs);
843 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.rhs);
844 break;
661
845
662/* See if an input file matches a DT_NEEDED entry by running stat on
663 the file. */
846 case etree_trinary:
847 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.cond);
848 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.lhs);
849 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.rhs);
850 break;
664
851
665static void
666gld${EMULATION_NAME}_stat_needed (s)
667 lang_input_statement_type *s;
668{
669 struct stat st;
670 const char *suffix;
671 const char *soname;
672 const char *f;
852 case etree_unary:
853 gld${EMULATION_NAME}_find_exp_assignment (exp->unary.child);
854 break;
673
855
674 if (global_found)
675 return;
676 if (s->the_bfd == NULL)
677 return;
678
679 if (bfd_stat (s->the_bfd, &st) != 0)
680 {
681 einfo ("%P:%B: bfd_stat failed: %E\n", s->the_bfd);
682 return;
856 default:
857 break;
683 }
858 }
684
685 if (st.st_dev == global_stat.st_dev
686 && st.st_ino == global_stat.st_ino)
687 {
688 global_found = true;
689 return;
690 }
691
692 /* We issue a warning if it looks like we are including two
693 different versions of the same shared library. For example,
694 there may be a problem if -lc picks up libc.so.6 but some other
695 shared library has a DT_NEEDED entry of libc.so.5. This is a
696 hueristic test, and it will only work if the name looks like
697 NAME.so.VERSION. FIXME: Depending on file names is error-prone.
698 If we really want to issue warnings about mixing version numbers
699 of shared libraries, we need to find a better way. */
700
701 if (strchr (global_needed->name, '/') != NULL)
702 return;
703 suffix = strstr (global_needed->name, ".so.");
704 if (suffix == NULL)
705 return;
706 suffix += sizeof ".so." - 1;
707
708 soname = bfd_elf_get_dt_soname (s->the_bfd);
709 if (soname == NULL)
710 soname = s->filename;
711
712 f = strrchr (soname, '/');
713 if (f != NULL)
714 ++f;
715 else
716 f = soname;
717
718 if (strncmp (f, global_needed->name, suffix - global_needed->name) == 0)
719 einfo ("%P: warning: %s, needed by %B, may conflict with %s\n",
720 global_needed->name, global_needed->by, f);
721}
722
859}
860
723/* On Linux, it's possible to have different versions of the same
724 shared library linked against different versions of libc. The
725 dynamic linker somehow tags which libc version to use in
726 /etc/ld.so.cache, and, based on the libc that it sees in the
727 executable, chooses which version of the shared library to use.
728
861
729 We try to do a similar check here by checking whether this shared
730 library needs any other shared libraries which may conflict with
731 libraries we have already included in the link. If it does, we
732 skip it, and try to find another shared library farther on down the
733 link path.
862/* This is called by the before_allocation routine via
863 lang_for_each_statement. It locates any assignment statements, and
864 tells the ELF backend about them, in case they are assignments to
865 symbols which are referred to by dynamic objects. */
734
866
735 This is called via lang_for_each_input_file.
736 GLOBAL_VERCHECK_NEEDED is the list of objects needed by the object
737 which we ar checking. This sets GLOBAL_VERCHECK_FAILED if we find
738 a conflicting version. */
739
740static void
867static void
741gld${EMULATION_NAME}_vercheck (s)
742 lang_input_statement_type *s;
868gld${EMULATION_NAME}_find_statement_assignment (s)
869 lang_statement_union_type *s;
743{
870{
744 const char *soname, *f;
745 struct bfd_link_needed_list *l;
871 if (s->header.type == lang_assignment_statement_enum)
872 gld${EMULATION_NAME}_find_exp_assignment (s->assignment_statement.exp);
873}
746
874
747 if (global_vercheck_failed)
748 return;
749 if (s->the_bfd == NULL
750 || (bfd_get_file_flags (s->the_bfd) & DYNAMIC) == 0)
751 return;
875EOF
752
876
753 soname = bfd_elf_get_dt_soname (s->the_bfd);
754 if (soname == NULL)
755 soname = bfd_get_filename (s->the_bfd);
877if test x"$LDEMUL_BEFORE_ALLOCATION" != xgld"$EMULATION_NAME"_before_allocation; then
878cat >>e${EMULATION_NAME}.c <<EOF
756
879
757 f = strrchr (soname, '/');
758 if (f != NULL)
759 ++f;
760 else
761 f = soname;
762
763 for (l = global_vercheck_needed; l != NULL; l = l->next)
764 {
765 const char *suffix;
766
767 if (strcmp (f, l->name) == 0)
768 {
769 /* Probably can't happen, but it's an easy check. */
770 continue;
771 }
772
773 if (strchr (l->name, '/') != NULL)
774 continue;
775
776 suffix = strstr (l->name, ".so.");
777 if (suffix == NULL)
778 continue;
779
780 suffix += sizeof ".so." - 1;
781
782 if (strncmp (f, l->name, suffix - l->name) == 0)
783 {
784 /* Here we know that S is a dynamic object FOO.SO.VER1, and
785 the object we are considering needs a dynamic object
786 FOO.SO.VER2, and VER1 and VER2 are different. This
787 appears to be a version mismatch, so we tell the caller
788 to try a different version of this library. */
789 global_vercheck_failed = true;
790 return;
791 }
792 }
793}
794
795/* This is called after the sections have been attached to output
796 sections, but before any sizes or addresses have been set. */
797
798static void
799gld${EMULATION_NAME}_before_allocation ()
800{
801 const char *rpath;
802 asection *sinterp;

--- 58 unchanged lines hidden (view full) ---

861
862 /* Clobber the section size, so that we don't waste copying the
863 warning into the output file. */
864 s->_raw_size = 0;
865 }
866 }
867}
868
880/* This is called after the sections have been attached to output
881 sections, but before any sizes or addresses have been set. */
882
883static void
884gld${EMULATION_NAME}_before_allocation ()
885{
886 const char *rpath;
887 asection *sinterp;

--- 58 unchanged lines hidden (view full) ---

946
947 /* Clobber the section size, so that we don't waste copying the
948 warning into the output file. */
949 s->_raw_size = 0;
950 }
951 }
952}
953
869/* This is called by the before_allocation routine via
870 lang_for_each_statement. It locates any assignment statements, and
871 tells the ELF backend about them, in case they are assignments to
872 symbols which are referred to by dynamic objects. */
954EOF
955fi
873
956
874static void
875gld${EMULATION_NAME}_find_statement_assignment (s)
876 lang_statement_union_type *s;
877{
878 if (s->header.type == lang_assignment_statement_enum)
879 gld${EMULATION_NAME}_find_exp_assignment (s->assignment_statement.exp);
880}
957if test x"$LDEMUL_OPEN_DYNAMIC_ARCHIVE" != xgld"$EMULATION_NAME"_open_dynamic_archive; then
958cat >>e${EMULATION_NAME}.c <<EOF
881
959
882/* Look through an expression for an assignment statement. */
960/* Try to open a dynamic archive. This is where we know that ELF
961 dynamic libraries have an extension of .so (or .sl on oddball systems
962 like hpux). */
883
963
884static void
885gld${EMULATION_NAME}_find_exp_assignment (exp)
886 etree_type *exp;
964static boolean
965gld${EMULATION_NAME}_open_dynamic_archive (arch, search, entry)
966 const char *arch;
967 search_dirs_type *search;
968 lang_input_statement_type *entry;
887{
969{
888 struct bfd_link_hash_entry *h;
970 const char *filename;
971 char *string;
889
972
890 switch (exp->type.node_class)
973 if (! entry->is_archive)
974 return false;
975
976 filename = entry->filename;
977
978 /* This allocates a few bytes too many when EXTRA_SHLIB_EXTENSION
979 is defined, but it does not seem worth the headache to optimize
980 away those two bytes of space. */
981 string = (char *) xmalloc (strlen (search->name)
982 + strlen (filename)
983 + strlen (arch)
984#ifdef EXTRA_SHLIB_EXTENSION
985 + strlen (EXTRA_SHLIB_EXTENSION)
986#endif
987 + sizeof "/lib.so");
988
989 sprintf (string, "%s/lib%s%s.so", search->name, filename, arch);
990
991#ifdef EXTRA_SHLIB_EXTENSION
992 /* Try the .so extension first. If that fails build a new filename
993 using EXTRA_SHLIB_EXTENSION. */
994 if (! ldfile_try_open_bfd (string, entry))
995 sprintf (string, "%s/lib%s%s%s", search->name,
996 filename, arch, EXTRA_SHLIB_EXTENSION);
997#endif
998
999 if (! ldfile_try_open_bfd (string, entry))
891 {
1000 {
892 case etree_provide:
893 h = bfd_link_hash_lookup (link_info.hash, exp->assign.dst,
894 false, false, false);
895 if (h == NULL)
896 break;
1001 free (string);
1002 return false;
1003 }
897
1004
898 /* We call record_link_assignment even if the symbol is defined.
899 This is because if it is defined by a dynamic object, we
900 actually want to use the value defined by the linker script,
901 not the value from the dynamic object (because we are setting
902 symbols like etext). If the symbol is defined by a regular
903 object, then, as it happens, calling record_link_assignment
904 will do no harm. */
1005 entry->filename = string;
905
1006
906 /* Fall through. */
907 case etree_assign:
908 if (strcmp (exp->assign.dst, ".") != 0)
909 {
910 if (! (bfd_elf${ELFSIZE}_record_link_assignment
911 (output_bfd, &link_info, exp->assign.dst,
912 exp->type.node_class == etree_provide ? true : false)))
913 einfo ("%P%F: failed to record assignment to %s: %E\n",
914 exp->assign.dst);
915 }
916 gld${EMULATION_NAME}_find_exp_assignment (exp->assign.src);
917 break;
1007 /* We have found a dynamic object to include in the link. The ELF
1008 backend linker will create a DT_NEEDED entry in the .dynamic
1009 section naming this file. If this file includes a DT_SONAME
1010 entry, it will be used. Otherwise, the ELF linker will just use
1011 the name of the file. For an archive found by searching, like
1012 this one, the DT_NEEDED entry should consist of just the name of
1013 the file, without the path information used to find it. Note
1014 that we only need to do this if we have a dynamic object; an
1015 archive will never be referenced by a DT_NEEDED entry.
918
1016
919 case etree_binary:
920 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.lhs);
921 gld${EMULATION_NAME}_find_exp_assignment (exp->binary.rhs);
922 break;
1017 FIXME: This approach--using bfd_elf_set_dt_needed_name--is not
1018 very pretty. I haven't been able to think of anything that is
1019 pretty, though. */
1020 if (bfd_check_format (entry->the_bfd, bfd_object)
1021 && (entry->the_bfd->flags & DYNAMIC) != 0)
1022 {
1023 char *needed_name;
923
1024
924 case etree_trinary:
925 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.cond);
926 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.lhs);
927 gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.rhs);
928 break;
1025 ASSERT (entry->is_archive && entry->search_dirs_flag);
929
1026
930 case etree_unary:
931 gld${EMULATION_NAME}_find_exp_assignment (exp->unary.child);
932 break;
1027 /* Rather than duplicating the logic above. Just use the
1028 filename we recorded earlier.
933
1029
934 default:
935 break;
1030 First strip off everything before the last '/'. */
1031 filename = strrchr (entry->filename, '/');
1032 filename++;
1033
1034 needed_name = (char *) xmalloc (strlen (filename) + 1);
1035 strcpy (needed_name, filename);
1036 bfd_elf_set_dt_needed_name (entry->the_bfd, needed_name);
936 }
1037 }
1038
1039 return true;
937}
938
1040}
1041
1042EOF
1043fi
1044cat >>e${EMULATION_NAME}.c <<EOF
1045
939/* A variant of lang_output_section_find. Used by place_orphan. */
940
941static lang_output_section_statement_type *
942output_rel_find ()
943{
944 lang_statement_union_type *u;
945 lang_output_section_statement_type *lookup;
946

--- 7 unchanged lines hidden (view full) ---

954 && (lookup->bfd_section->flags & SEC_ALLOC) != 0)
955 {
956 return lookup;
957 }
958 }
959 return (lang_output_section_statement_type *) NULL;
960}
961
1046/* A variant of lang_output_section_find. Used by place_orphan. */
1047
1048static lang_output_section_statement_type *
1049output_rel_find ()
1050{
1051 lang_statement_union_type *u;
1052 lang_output_section_statement_type *lookup;
1053

--- 7 unchanged lines hidden (view full) ---

1061 && (lookup->bfd_section->flags & SEC_ALLOC) != 0)
1062 {
1063 return lookup;
1064 }
1065 }
1066 return (lang_output_section_statement_type *) NULL;
1067}
1068
1069EOF
1070
1071if test x"$LDEMUL_PLACE_ORPHAN" != xgld"$EMULATION_NAME"_place_orphan; then
1072cat >>e${EMULATION_NAME}.c <<EOF
1073
962/* Place an orphan section. We use this to put random SHF_ALLOC
963 sections in the right segment. */
964
965struct orphan_save {
966 lang_output_section_statement_type *os;
967 asection **section;
968 lang_statement_union_type **stmt;
969};

--- 4 unchanged lines hidden (view full) ---

974 asection *s;
975{
976 static struct orphan_save hold_text;
977 static struct orphan_save hold_rodata;
978 static struct orphan_save hold_data;
979 static struct orphan_save hold_bss;
980 static struct orphan_save hold_rel;
981 static struct orphan_save hold_interp;
1074/* Place an orphan section. We use this to put random SHF_ALLOC
1075 sections in the right segment. */
1076
1077struct orphan_save {
1078 lang_output_section_statement_type *os;
1079 asection **section;
1080 lang_statement_union_type **stmt;
1081};

--- 4 unchanged lines hidden (view full) ---

1086 asection *s;
1087{
1088 static struct orphan_save hold_text;
1089 static struct orphan_save hold_rodata;
1090 static struct orphan_save hold_data;
1091 static struct orphan_save hold_bss;
1092 static struct orphan_save hold_rel;
1093 static struct orphan_save hold_interp;
1094 static struct orphan_save hold_sdata;
1095 static int count = 1;
982 struct orphan_save *place;
983 lang_statement_list_type *old;
984 lang_statement_list_type add;
985 etree_type *address;
986 const char *secname;
987 const char *outsecname;
988 const char *ps = NULL;
989 lang_output_section_statement_type *os;
990
991 secname = bfd_get_section_name (s->owner, s);
992
1096 struct orphan_save *place;
1097 lang_statement_list_type *old;
1098 lang_statement_list_type add;
1099 etree_type *address;
1100 const char *secname;
1101 const char *outsecname;
1102 const char *ps = NULL;
1103 lang_output_section_statement_type *os;
1104
1105 secname = bfd_get_section_name (s->owner, s);
1106
993 /* Look through the script to see where to place this section. */
994 os = lang_output_section_find (secname);
995
996 if (os != NULL
997 && os->bfd_section != NULL
998 && ((s->flags ^ os->bfd_section->flags) & (SEC_LOAD | SEC_ALLOC)) == 0)
1107 if (! config.unique_orphan_sections && ! unique_section_p (secname))
999 {
1108 {
1000 /* We have already placed a section with this name. */
1001 wild_doit (&os->children, s, os, file);
1002 return true;
1109 /* Look through the script to see where to place this section. */
1110 os = lang_output_section_find (secname);
1111
1112 if (os != NULL
1113 && os->bfd_section != NULL
1114 && ((s->flags ^ os->bfd_section->flags)
1115 & (SEC_LOAD | SEC_ALLOC)) == 0)
1116 {
1117 /* We have already placed a section with this name. */
1118 wild_doit (&os->children, s, os, file);
1119 return true;
1120 }
1003 }
1004
1005 if (hold_text.os == NULL)
1006 hold_text.os = lang_output_section_find (".text");
1007
1008 /* If this is a final link, then always put .gnu.warning.SYMBOL
1009 sections into the .text section to get them out of the way. */
1010 if (! link_info.shared

--- 15 unchanged lines hidden (view full) ---

1026
1027 if (s->flags & SEC_EXCLUDE)
1028 return false;
1029
1030 place = NULL;
1031 if ((s->flags & SEC_ALLOC) == 0)
1032 ;
1033 else if ((s->flags & SEC_LOAD) != 0
1121 }
1122
1123 if (hold_text.os == NULL)
1124 hold_text.os = lang_output_section_find (".text");
1125
1126 /* If this is a final link, then always put .gnu.warning.SYMBOL
1127 sections into the .text section to get them out of the way. */
1128 if (! link_info.shared

--- 15 unchanged lines hidden (view full) ---

1144
1145 if (s->flags & SEC_EXCLUDE)
1146 return false;
1147
1148 place = NULL;
1149 if ((s->flags & SEC_ALLOC) == 0)
1150 ;
1151 else if ((s->flags & SEC_LOAD) != 0
1034 && strncmp (secname, ".note", 4) == 0
1152 && strncmp (secname, ".note", 5) == 0
1035 && HAVE_SECTION (hold_interp, ".interp"))
1036 place = &hold_interp;
1037 else if ((s->flags & SEC_HAS_CONTENTS) == 0
1038 && HAVE_SECTION (hold_bss, ".bss"))
1039 place = &hold_bss;
1153 && HAVE_SECTION (hold_interp, ".interp"))
1154 place = &hold_interp;
1155 else if ((s->flags & SEC_HAS_CONTENTS) == 0
1156 && HAVE_SECTION (hold_bss, ".bss"))
1157 place = &hold_bss;
1158 else if ((s->flags & SEC_SMALL_DATA) != 0
1159 && HAVE_SECTION (hold_sdata, ".sdata"))
1160 place = &hold_sdata;
1040 else if ((s->flags & SEC_READONLY) == 0
1041 && HAVE_SECTION (hold_data, ".data"))
1042 place = &hold_data;
1043 else if (strncmp (secname, ".rel", 4) == 0
1044 && (hold_rel.os != NULL
1045 || (hold_rel.os = output_rel_find ()) != NULL))
1046 place = &hold_rel;
1047 else if ((s->flags & (SEC_CODE | SEC_READONLY)) == SEC_READONLY
1048 && HAVE_SECTION (hold_rodata, ".rodata"))
1049 place = &hold_rodata;
1050 else if ((s->flags & (SEC_CODE | SEC_READONLY)) == (SEC_CODE | SEC_READONLY)
1051 && hold_text.os != NULL)
1052 place = &hold_text;
1053
1054#undef HAVE_SECTION
1055
1056 /* Choose a unique name for the section. This will be needed if the
1057 same section name appears in the input file with different
1161 else if ((s->flags & SEC_READONLY) == 0
1162 && HAVE_SECTION (hold_data, ".data"))
1163 place = &hold_data;
1164 else if (strncmp (secname, ".rel", 4) == 0
1165 && (hold_rel.os != NULL
1166 || (hold_rel.os = output_rel_find ()) != NULL))
1167 place = &hold_rel;
1168 else if ((s->flags & (SEC_CODE | SEC_READONLY)) == SEC_READONLY
1169 && HAVE_SECTION (hold_rodata, ".rodata"))
1170 place = &hold_rodata;
1171 else if ((s->flags & (SEC_CODE | SEC_READONLY)) == (SEC_CODE | SEC_READONLY)
1172 && hold_text.os != NULL)
1173 place = &hold_text;
1174
1175#undef HAVE_SECTION
1176
1177 /* Choose a unique name for the section. This will be needed if the
1178 same section name appears in the input file with different
1058 loadable or allocateable characteristics. */
1179 loadable or allocatable characteristics. */
1059 outsecname = secname;
1060 if (bfd_get_section_by_name (output_bfd, outsecname) != NULL)
1061 {
1180 outsecname = secname;
1181 if (bfd_get_section_by_name (output_bfd, outsecname) != NULL)
1182 {
1062 unsigned int len;
1063 char *newname;
1064 unsigned int i;
1065
1066 len = strlen (outsecname);
1067 newname = xmalloc (len + 5);
1068 strcpy (newname, outsecname);
1069 i = 0;
1070 do
1071 {
1072 sprintf (newname + len, "%d", i);
1073 ++i;
1074 }
1075 while (bfd_get_section_by_name (output_bfd, newname) != NULL);
1076
1077 outsecname = newname;
1183 outsecname = bfd_get_unique_section_name (output_bfd,
1184 outsecname,
1185 &count);
1186 if (outsecname == NULL)
1187 einfo ("%F%P: place_orphan failed: %E\n");
1078 }
1079
1080 /* Start building a list of statements for this section.
1081 First save the current statement pointer. */
1082 old = stat_ptr;
1083
1084 /* If we have found an appropriate place for the output section
1085 statements for this orphan, add them to our own private list,

--- 124 unchanged lines hidden (view full) ---

1210 /* Save the end of this list. */
1211 place->stmt = add.tail;
1212 }
1213 }
1214
1215 return true;
1216}
1217
1188 }
1189
1190 /* Start building a list of statements for this section.
1191 First save the current statement pointer. */
1192 old = stat_ptr;
1193
1194 /* If we have found an appropriate place for the output section
1195 statements for this orphan, add them to our own private list,

--- 124 unchanged lines hidden (view full) ---

1320 /* Save the end of this list. */
1321 place->stmt = add.tail;
1322 }
1323 }
1324
1325 return true;
1326}
1327
1328EOF
1329fi
1330
1331if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then
1332cat >>e${EMULATION_NAME}.c <<EOF
1333
1218static char *
1334static char *
1219gld${EMULATION_NAME}_get_script(isfile)
1335gld${EMULATION_NAME}_get_script (isfile)
1220 int *isfile;
1221EOF
1222
1223if test -n "$COMPILE_IN"
1224then
1225# Scripts compiled in.
1226
1227# sed commands to quote an ld script as a C string.
1228sc="-f stringify.sed"
1229
1230cat >>e${EMULATION_NAME}.c <<EOF
1336 int *isfile;
1337EOF
1338
1339if test -n "$COMPILE_IN"
1340then
1341# Scripts compiled in.
1342
1343# sed commands to quote an ld script as a C string.
1344sc="-f stringify.sed"
1345
1346cat >>e${EMULATION_NAME}.c <<EOF
1231{
1347{
1232 *isfile = 0;
1233
1234 if (link_info.relocateable == true && config.build_constructors == true)
1235 return
1236EOF
1237sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
1238echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
1239sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c

--- 10 unchanged lines hidden (view full) ---

1250echo ' ; else return' >> e${EMULATION_NAME}.c
1251sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
1252echo '; }' >> e${EMULATION_NAME}.c
1253
1254else
1255# Scripts read from the filesystem.
1256
1257cat >>e${EMULATION_NAME}.c <<EOF
1348 *isfile = 0;
1349
1350 if (link_info.relocateable == true && config.build_constructors == true)
1351 return
1352EOF
1353sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
1354echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
1355sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c

--- 10 unchanged lines hidden (view full) ---

1366echo ' ; else return' >> e${EMULATION_NAME}.c
1367sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
1368echo '; }' >> e${EMULATION_NAME}.c
1369
1370else
1371# Scripts read from the filesystem.
1372
1373cat >>e${EMULATION_NAME}.c <<EOF
1258{
1374{
1259 *isfile = 1;
1260
1261 if (link_info.relocateable == true && config.build_constructors == true)
1262 return "ldscripts/${EMULATION_NAME}.xu";
1263 else if (link_info.relocateable == true)
1264 return "ldscripts/${EMULATION_NAME}.xr";
1265 else if (!config.text_read_only)
1266 return "ldscripts/${EMULATION_NAME}.xbn";
1267 else if (!config.magic_demand_paged)
1268 return "ldscripts/${EMULATION_NAME}.xn";
1269 else if (link_info.shared)
1270 return "ldscripts/${EMULATION_NAME}.xs";
1271 else
1272 return "ldscripts/${EMULATION_NAME}.x";
1273}
1375 *isfile = 1;
1376
1377 if (link_info.relocateable == true && config.build_constructors == true)
1378 return "ldscripts/${EMULATION_NAME}.xu";
1379 else if (link_info.relocateable == true)
1380 return "ldscripts/${EMULATION_NAME}.xr";
1381 else if (!config.text_read_only)
1382 return "ldscripts/${EMULATION_NAME}.xbn";
1383 else if (!config.magic_demand_paged)
1384 return "ldscripts/${EMULATION_NAME}.xn";
1385 else if (link_info.shared)
1386 return "ldscripts/${EMULATION_NAME}.xs";
1387 else
1388 return "ldscripts/${EMULATION_NAME}.x";
1389}
1390
1274EOF
1391EOF
1392fi
1393fi
1275
1394
1395if test -n "$PARSE_AND_LIST_ARGS_CASES" -o x"$GENERATE_SHLIB_SCRIPT" = xyes; then
1396
1397if test x"$LDEMUL_PARSE_ARGS" != xgld"$EMULATION_NAME"_parse_args; then
1398
1399if test -n "$PARSE_AND_LIST_PROLOGUE" ; then
1400cat >>e${EMULATION_NAME}.c <<EOF
1401 $PARSE_AND_LIST_PROLOGUE
1402EOF
1276fi
1277
1403fi
1404
1278if test -n "$PARSE_AND_LIST_ARGS" ; then
1279cat >>e${EMULATION_NAME}.c <<EOF
1405cat >>e${EMULATION_NAME}.c <<EOF
1280static int gld_${EMULATION_NAME}_parse_args PARAMS ((int, char **));
1281static void gld_${EMULATION_NAME}_list_options PARAMS ((FILE * file));
1282
1406
1283 $PARSE_AND_LIST_ARGS
1407#include "getopt.h"
1408
1409#define OPTION_DISABLE_NEW_DTAGS (400)
1410#define OPTION_ENABLE_NEW_DTAGS (OPTION_DISABLE_NEW_DTAGS + 1)
1411
1412static struct option longopts[] =
1413{
1284EOF
1414EOF
1285else
1286
1415
1416if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
1287cat >>e${EMULATION_NAME}.c <<EOF
1417cat >>e${EMULATION_NAME}.c <<EOF
1288#define gld_${EMULATION_NAME}_parse_args NULL
1289#define gld_${EMULATION_NAME}_list_options NULL
1418 /* getopt allows abbreviations, so we do this to stop it from
1419 treating -d/-e as abbreviations for these options. */
1420 {"disable-new-dtags", no_argument, NULL, OPTION_DISABLE_NEW_DTAGS},
1421 {"disable-new-dtags", no_argument, NULL, OPTION_DISABLE_NEW_DTAGS},
1422 {"enable-new-dtags", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS},
1423 {"enable-new-dtags", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS},
1290EOF
1424EOF
1425fi
1291
1426
1427if test -n "$PARSE_AND_LIST_LONGOPTS" ; then
1428cat >>e${EMULATION_NAME}.c <<EOF
1429 $PARSE_AND_LIST_LONGOPTS
1430EOF
1292fi
1293
1294cat >>e${EMULATION_NAME}.c <<EOF
1431fi
1432
1433cat >>e${EMULATION_NAME}.c <<EOF
1434 {NULL, no_argument, NULL, 0}
1435};
1295
1436
1296struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
1437
1438static int gld${EMULATION_NAME}_parse_args PARAMS ((int, char **));
1439
1440static int
1441gld${EMULATION_NAME}_parse_args (argc, argv)
1442 int argc;
1443 char ** argv;
1297{
1444{
1298 gld${EMULATION_NAME}_before_parse,
1299 syslib_default,
1300 hll_default,
1301 after_parse_default,
1302 gld${EMULATION_NAME}_after_open,
1303 after_allocation_default,
1304 set_output_arch_default,
1305 ldemul_default_target,
1306 gld${EMULATION_NAME}_before_allocation,
1307 gld${EMULATION_NAME}_get_script,
1445 int longind;
1446 int optc;
1447 static int prevoptind = -1;
1448 int prevopterr = opterr;
1449 int wanterror;
1450
1451 if (prevoptind != optind)
1452 opterr = 0;
1453
1454 wanterror = opterr;
1455 prevoptind = optind;
1456
1457 optc = getopt_long_only (argc, argv,
1458 "-${PARSE_AND_LIST_SHORTOPTS}z:", longopts,
1459 &longind);
1460 opterr = prevopterr;
1461
1462 switch (optc)
1463 {
1464 default:
1465 if (wanterror)
1466 xexit (1);
1467 optind = prevoptind;
1468 return 0;
1469
1470EOF
1471
1472if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
1473cat >>e${EMULATION_NAME}.c <<EOF
1474 case OPTION_DISABLE_NEW_DTAGS:
1475 link_info.new_dtags = false;
1476 break;
1477
1478 case OPTION_ENABLE_NEW_DTAGS:
1479 link_info.new_dtags = true;
1480 break;
1481
1482 case 'z':
1483 if (strcmp (optarg, "initfirst") == 0)
1484 link_info.flags_1 |= (bfd_vma) DF_1_INITFIRST;
1485 else if (strcmp (optarg, "interpose") == 0)
1486 link_info.flags_1 |= (bfd_vma) DF_1_INTERPOSE;
1487 else if (strcmp (optarg, "loadfltr") == 0)
1488 link_info.flags_1 |= (bfd_vma) DF_1_LOADFLTR;
1489 else if (strcmp (optarg, "nodefaultlib") == 0)
1490 link_info.flags_1 |= (bfd_vma) DF_1_NODEFLIB;
1491 else if (strcmp (optarg, "nodelete") == 0)
1492 link_info.flags_1 |= (bfd_vma) DF_1_NODELETE;
1493 else if (strcmp (optarg, "nodlopen") == 0)
1494 link_info.flags_1 |= (bfd_vma) DF_1_NOOPEN;
1495 else if (strcmp (optarg, "nodump") == 0)
1496 link_info.flags_1 |= (bfd_vma) DF_1_NODUMP;
1497 else if (strcmp (optarg, "now") == 0)
1498 {
1499 link_info.flags |= (bfd_vma) DF_BIND_NOW;
1500 link_info.flags_1 |= (bfd_vma) DF_1_NOW;
1501 }
1502 else if (strcmp (optarg, "origin") == 0)
1503 {
1504 link_info.flags |= (bfd_vma) DF_ORIGIN;
1505 link_info.flags_1 |= (bfd_vma) DF_1_ORIGIN;
1506 }
1507 /* What about the other Solaris -z options? FIXME. */
1508 break;
1509EOF
1510fi
1511
1512if test -n "$PARSE_AND_LIST_ARGS_CASES" ; then
1513cat >>e${EMULATION_NAME}.c <<EOF
1514 $PARSE_AND_LIST_ARGS_CASES
1515EOF
1516fi
1517
1518cat >>e${EMULATION_NAME}.c <<EOF
1519 }
1520
1521 return 1;
1522}
1523
1524EOF
1525fi
1526
1527if test x"$LDEMUL_LIST_OPTIONS" != xgld"$EMULATION_NAME"_list_options; then
1528cat >>e${EMULATION_NAME}.c <<EOF
1529
1530static void gld${EMULATION_NAME}_list_options PARAMS ((FILE * file));
1531
1532static void
1533gld${EMULATION_NAME}_list_options (file)
1534 FILE * file;
1535{
1536EOF
1537
1538if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
1539cat >>e${EMULATION_NAME}.c <<EOF
1540 fprintf (file, _(" --disable-new-dtags\tDisable new dynamic tags\n"));
1541 fprintf (file, _(" --enable-new-dtags\tEnable new dynamic tags\n"));
1542 fprintf (file, _(" -z initfirst\t\tMark DSO to be initialized first at runtime\n"));
1543 fprintf (file, _(" -z interpose\t\tMark object to interpose all DSOs but executable\n"));
1544 fprintf (file, _(" -z loadfltr\t\tMark object requiring immediate process\n"));
1545 fprintf (file, _(" -z nodefaultlib\tMark object not to use default search paths\n"));
1546 fprintf (file, _(" -z nodelete\t\tMark DSO non-deletable at runtime\n"));
1547 fprintf (file, _(" -z nodlopen\t\tMark DSO not available to dlopen\n"));
1548 fprintf (file, _(" -z nodump\t\tMark DSO not available to dldump\n"));
1549 fprintf (file, _(" -z now\t\tMark object non-lazy runtime binding\n"));
1550 fprintf (file, _(" -z origin\t\tMark object requiring immediate \$ORIGIN processing\n"));
1551 fprintf (file, _("\t\t\t at runtime\n"));
1552 fprintf (file, _(" -z KEYWORD\t\tIgnored for Solaris compatibility\n"));
1553EOF
1554fi
1555
1556if test -n "$PARSE_AND_LIST_OPTIONS" ; then
1557cat >>e${EMULATION_NAME}.c <<EOF
1558 $PARSE_AND_LIST_OPTIONS
1559EOF
1560fi
1561
1562cat >>e${EMULATION_NAME}.c <<EOF
1563}
1564EOF
1565
1566if test -n "$PARSE_AND_LIST_EPILOGUE" ; then
1567cat >>e${EMULATION_NAME}.c <<EOF
1568 $PARSE_AND_LIST_EPILOGUE
1569EOF
1570fi
1571fi
1572else
1573if test x"$LDEMUL_PARSE_ARGS" != xgld"$EMULATION_NAME"_parse_args; then
1574cat >>e${EMULATION_NAME}.c <<EOF
1575#define gld${EMULATION_NAME}_parse_args NULL
1576EOF
1577fi
1578if test x"$LDEMUL_LIST_OPTIONS" != xgld"$EMULATION_NAME"_list_options; then
1579cat >>e${EMULATION_NAME}.c <<EOF
1580#define gld${EMULATION_NAME}_list_options NULL
1581EOF
1582fi
1583fi
1584
1585cat >>e${EMULATION_NAME}.c <<EOF
1586
1587struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
1588{
1589 ${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse},
1590 ${LDEMUL_SYSLIB-syslib_default},
1591 ${LDEMUL_HLL-hll_default},
1592 ${LDEMUL_AFTER_PARSE-after_parse_default},
1593 ${LDEMUL_AFTER_OPEN-gld${EMULATION_NAME}_after_open},
1594 ${LDEMUL_AFTER_ALLOCATION-after_allocation_default},
1595 ${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
1596 ${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
1597 ${LDEMUL_BEFORE_ALLOCATION-gld${EMULATION_NAME}_before_allocation},
1598 ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
1308 "${EMULATION_NAME}",
1309 "${OUTPUT_FORMAT}",
1599 "${EMULATION_NAME}",
1600 "${OUTPUT_FORMAT}",
1310 NULL, /* finish */
1311 NULL, /* create output section statements */
1312 gld${EMULATION_NAME}_open_dynamic_archive,
1313 gld${EMULATION_NAME}_place_orphan,
1314 NULL, /* set_symbols */
1315 gld_${EMULATION_NAME}_parse_args,
1316 NULL, /* unrecognized_file */
1317 gld_${EMULATION_NAME}_list_options,
1318 NULL, /* recognized_file */
1319 NULL /* find_potential_libraries */
1601 ${LDEMUL_FINISH-NULL},
1602 ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL},
1603 ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-gld${EMULATION_NAME}_open_dynamic_archive},
1604 ${LDEMUL_PLACE_ORPHAN-gld${EMULATION_NAME}_place_orphan},
1605 ${LDEMUL_SET_SYMBOLS-NULL},
1606 ${LDEMUL_PARSE_ARGS-gld${EMULATION_NAME}_parse_args},
1607 ${LDEMUL_UNRECOGNIZED_FILE-NULL},
1608 ${LDEMUL_LIST_OPTIONS-gld${EMULATION_NAME}_list_options},
1609 ${LDEMUL_RECOGNIZED_FILE-NULL},
1610 ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL},
1320};
1321EOF
1611};
1612EOF