1# $FreeBSD: head/contrib/binutils/ld/emultempl/elf32.em 77319 2001-05-28 06:21:27Z 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}
13 Copyright (C) 1991, 93, 94, 95, 96, 97, 98, 99, 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"
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{
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;
--- 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;
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)
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
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 '/'. */
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)
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 {
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
1028 filename we recorded earlier.
1029
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);
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)
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},
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
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 }
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
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"));
--- 63 unchanged lines hidden ---
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
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
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{
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;
--- 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;
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)
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
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 '/'. */
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)
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 {
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
1028 filename we recorded earlier.
1029
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);
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)
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},
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
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 }
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
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"));
--- 63 unchanged lines hidden ---