Deleted Added
full compact
elf32.em (77319) elf32.em (78841)
1# $FreeBSD: head/contrib/binutils/ld/emultempl/elf32.em 77319 2001-05-28 06:21:27Z obrien $
1# $FreeBSD: head/contrib/binutils/ld/emultempl/elf32.em 78841 2001-06-26 17:57:37Z obrien $
2
3
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}
2
3
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}
13 Copyright (C) 1991, 93, 94, 95, 96, 97, 98, 99, 2000, 2001
13 Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
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

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

30You should have received a copy of the GNU General Public License
31along with this program; if not, write to the Free Software
32Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
33
34#define TARGET_IS_${EMULATION_NAME}
35
36#include "bfd.h"
37#include "sysdep.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

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

30You should have received a copy of the GNU General Public License
31along with this program; if not, write to the Free Software
32Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
33
34#define TARGET_IS_${EMULATION_NAME}
35
36#include "bfd.h"
37#include "sysdep.h"
38#include "libiberty.h"
38
39#include <ctype.h>
40
41#include "bfdlink.h"
42
43#include "ld.h"
44#include "ldmain.h"
45#include "ldmisc.h"

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

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{
39
40#include <ctype.h>
41
42#include "bfdlink.h"
43
44#include "ld.h"
45#include "ldmain.h"
46#include "ldmisc.h"

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

129 GLOBAL_VERCHECK_NEEDED is the list of objects needed by the object
130 which we are checking. This sets GLOBAL_VERCHECK_FAILED if we find
131 a conflicting version. */
132
133static void
134gld${EMULATION_NAME}_vercheck (s)
135 lang_input_statement_type *s;
136{
136 const char *soname, *f;
137 const char *soname;
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)
138 struct bfd_link_needed_list *l;
139
140 if (global_vercheck_failed)
141 return;
142 if (s->the_bfd == NULL
143 || (bfd_get_file_flags (s->the_bfd) & DYNAMIC) == 0)
144 return;
145
146 soname = bfd_elf_get_dt_soname (s->the_bfd);
147 if (soname == NULL)
147 soname = bfd_get_filename (s->the_bfd);
148 soname = basename (bfd_get_filename (s->the_bfd));
148
149
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
150 for (l = global_vercheck_needed; l != NULL; l = l->next)
151 {
152 const char *suffix;
153
159 if (strcmp (f, l->name) == 0)
154 if (strcmp (soname, 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
155 {
156 /* Probably can't happen, but it's an easy check. */
157 continue;
158 }
159
160 if (strchr (l->name, '/') != NULL)
161 continue;
162
163 suffix = strstr (l->name, ".so.");
164 if (suffix == NULL)
165 continue;
166
167 suffix += sizeof ".so." - 1;
168
174 if (strncmp (f, l->name, suffix - l->name) == 0)
169 if (strncmp (soname, 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;

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

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;
170 {
171 /* Here we know that S is a dynamic object FOO.SO.VER1, and
172 the object we are considering needs a dynamic object
173 FOO.SO.VER2, and VER1 and VER2 are different. This
174 appears to be a version mismatch, so we tell the caller
175 to try a different version of this library. */
176 global_vercheck_failed = true;
177 return;

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

185
186static void
187gld${EMULATION_NAME}_stat_needed (s)
188 lang_input_statement_type *s;
189{
190 struct stat st;
191 const char *suffix;
192 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 {

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

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)
193
194 if (global_found)
195 return;
196 if (s->the_bfd == NULL)
197 return;
198
199 if (bfd_stat (s->the_bfd, &st) != 0)
200 {

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

222 return;
223 suffix = strstr (global_needed->name, ".so.");
224 if (suffix == NULL)
225 return;
226 suffix += sizeof ".so." - 1;
227
228 soname = bfd_elf_get_dt_soname (s->the_bfd);
229 if (soname == NULL)
236 soname = s->filename;
230 soname = basename (s->filename);
237
231
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)
232 if (strncmp (soname, global_needed->name,
233 suffix - global_needed->name) == 0)
245 einfo ("%P: warning: %s, needed by %B, may conflict with %s\n",
234 einfo ("%P: warning: %s, needed by %B, may conflict with %s\n",
246 global_needed->name, global_needed->by, f);
235 global_needed->name, global_needed->by, soname);
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
254static boolean

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

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 '/'. */
236}
237
238
239/* This function is called for each possible name for a dynamic object
240 named by a DT_NEEDED entry. The FORCE parameter indicates whether
241 to skip the check for a conflicting version. */
242
243static boolean

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

327 reference libc.so.1. If we have already included libc.so, we
328 don't want to include libc.so.1 if they are the same file, and we
329 can only check that using stat. */
330
331 if (bfd_stat (abfd, &global_stat) != 0)
332 einfo ("%F%P:%B: bfd_stat failed: %E\n", abfd);
333
334 /* First strip off everything before the last '/'. */
346 soname = strrchr (abfd->filename, '/');
347 if (soname)
348 soname++;
349 else
350 soname = abfd->filename;
335 soname = basename (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)
358 {

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

1015 archive will never be referenced by a DT_NEEDED entry.
1016
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 {
336
337 if (trace_file_tries)
338 info_msg (_("found %s at %s\n"), soname, name);
339
340 global_found = false;
341 lang_for_each_input_file (gld${EMULATION_NAME}_stat_needed);
342 if (global_found)
343 {

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

1000 archive will never be referenced by a DT_NEEDED entry.
1001
1002 FIXME: This approach--using bfd_elf_set_dt_needed_name--is not
1003 very pretty. I haven't been able to think of anything that is
1004 pretty, though. */
1005 if (bfd_check_format (entry->the_bfd, bfd_object)
1006 && (entry->the_bfd->flags & DYNAMIC) != 0)
1007 {
1023 char *needed_name;
1024
1025 ASSERT (entry->is_archive && entry->search_dirs_flag);
1026
1027 /* Rather than duplicating the logic above. Just use the
1008 ASSERT (entry->is_archive && entry->search_dirs_flag);
1009
1010 /* Rather than duplicating the logic above. Just use the
1028 filename we recorded earlier.
1011 filename we recorded earlier. */
1029
1012
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);
1013 filename = xstrdup (basename (entry->filename));
1014 bfd_elf_set_dt_needed_name (entry->the_bfd, filename);
1037 }
1038
1039 return true;
1040}
1041
1042EOF
1043fi
1044cat >>e${EMULATION_NAME}.c <<EOF

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

1403fi
1404
1405cat >>e${EMULATION_NAME}.c <<EOF
1406
1407#include "getopt.h"
1408
1409#define OPTION_DISABLE_NEW_DTAGS (400)
1410#define OPTION_ENABLE_NEW_DTAGS (OPTION_DISABLE_NEW_DTAGS + 1)
1015 }
1016
1017 return true;
1018}
1019
1020EOF
1021fi
1022cat >>e${EMULATION_NAME}.c <<EOF

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

1381fi
1382
1383cat >>e${EMULATION_NAME}.c <<EOF
1384
1385#include "getopt.h"
1386
1387#define OPTION_DISABLE_NEW_DTAGS (400)
1388#define OPTION_ENABLE_NEW_DTAGS (OPTION_DISABLE_NEW_DTAGS + 1)
1389#define OPTION_GROUP (OPTION_ENABLE_NEW_DTAGS + 1)
1411
1412static struct option longopts[] =
1413{
1414EOF
1415
1416if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
1417cat >>e${EMULATION_NAME}.c <<EOF
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},
1390
1391static struct option longopts[] =
1392{
1393EOF
1394
1395if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
1396cat >>e${EMULATION_NAME}.c <<EOF
1397 /* getopt allows abbreviations, so we do this to stop it from
1398 treating -d/-e as abbreviations for these options. */
1399 {"disable-new-dtags", no_argument, NULL, OPTION_DISABLE_NEW_DTAGS},
1400 {"disable-new-dtags", no_argument, NULL, OPTION_DISABLE_NEW_DTAGS},
1401 {"enable-new-dtags", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS},
1402 {"enable-new-dtags", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS},
1403 {"Bgroup", no_argument, NULL, OPTION_GROUP},
1404 {"Bgroup", no_argument, NULL, OPTION_GROUP},
1424EOF
1425fi
1426
1427if test -n "$PARSE_AND_LIST_LONGOPTS" ; then
1428cat >>e${EMULATION_NAME}.c <<EOF
1429 $PARSE_AND_LIST_LONGOPTS
1430EOF
1431fi

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

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
1405EOF
1406fi
1407
1408if test -n "$PARSE_AND_LIST_LONGOPTS" ; then
1409cat >>e${EMULATION_NAME}.c <<EOF
1410 $PARSE_AND_LIST_LONGOPTS
1411EOF
1412fi

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

1455 case OPTION_DISABLE_NEW_DTAGS:
1456 link_info.new_dtags = false;
1457 break;
1458
1459 case OPTION_ENABLE_NEW_DTAGS:
1460 link_info.new_dtags = true;
1461 break;
1462
1463 case OPTION_GROUP:
1464 link_info.flags_1 |= (bfd_vma) DF_1_GROUP;
1465 /* Groups must be self-contained. */
1466 link_info.no_undefined = true;
1467 break;
1468
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)

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

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 }
1469 case 'z':
1470 if (strcmp (optarg, "initfirst") == 0)
1471 link_info.flags_1 |= (bfd_vma) DF_1_INITFIRST;
1472 else if (strcmp (optarg, "interpose") == 0)
1473 link_info.flags_1 |= (bfd_vma) DF_1_INTERPOSE;
1474 else if (strcmp (optarg, "loadfltr") == 0)
1475 link_info.flags_1 |= (bfd_vma) DF_1_LOADFLTR;
1476 else if (strcmp (optarg, "nodefaultlib") == 0)

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

1486 link_info.flags |= (bfd_vma) DF_BIND_NOW;
1487 link_info.flags_1 |= (bfd_vma) DF_1_NOW;
1488 }
1489 else if (strcmp (optarg, "origin") == 0)
1490 {
1491 link_info.flags |= (bfd_vma) DF_ORIGIN;
1492 link_info.flags_1 |= (bfd_vma) DF_1_ORIGIN;
1493 }
1494 else if (strcmp (optarg, "defs") == 0)
1495 link_info.no_undefined = true;
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

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

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
1496 /* What about the other Solaris -z options? FIXME. */
1497 break;
1498EOF
1499fi
1500
1501if test -n "$PARSE_AND_LIST_ARGS_CASES" ; then
1502cat >>e${EMULATION_NAME}.c <<EOF
1503 $PARSE_AND_LIST_ARGS_CASES

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

1521static void
1522gld${EMULATION_NAME}_list_options (file)
1523 FILE * file;
1524{
1525EOF
1526
1527if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
1528cat >>e${EMULATION_NAME}.c <<EOF
1529 fprintf (file, _(" -Bgroup\t\tSelects group name lookup rules for DSO\n"));
1540 fprintf (file, _(" --disable-new-dtags\tDisable new dynamic tags\n"));
1541 fprintf (file, _(" --enable-new-dtags\tEnable new dynamic tags\n"));
1530 fprintf (file, _(" --disable-new-dtags\tDisable new dynamic tags\n"));
1531 fprintf (file, _(" --enable-new-dtags\tEnable new dynamic tags\n"));
1532 fprintf (file, _(" -z defs\t\tDisallows undefined symbols\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"));

--- 63 unchanged lines hidden ---
1533 fprintf (file, _(" -z initfirst\t\tMark DSO to be initialized first at runtime\n"));
1534 fprintf (file, _(" -z interpose\t\tMark object to interpose all DSOs but executable\n"));
1535 fprintf (file, _(" -z loadfltr\t\tMark object requiring immediate process\n"));
1536 fprintf (file, _(" -z nodefaultlib\tMark object not to use default search paths\n"));
1537 fprintf (file, _(" -z nodelete\t\tMark DSO non-deletable at runtime\n"));
1538 fprintf (file, _(" -z nodlopen\t\tMark DSO not available to dlopen\n"));
1539 fprintf (file, _(" -z nodump\t\tMark DSO not available to dldump\n"));
1540 fprintf (file, _(" -z now\t\tMark object non-lazy runtime binding\n"));

--- 63 unchanged lines hidden ---