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} |
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" |
38#include "libiberty.h" |
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{ |
137 const char *soname; |
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) |
148 soname = basename (bfd_get_filename (s->the_bfd)); |
149 |
150 for (l = global_vercheck_needed; l != NULL; l = l->next) 151 { 152 const char *suffix; 153 |
154 if (strcmp (soname, l->name) == 0) |
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 |
169 if (strncmp (soname, l->name, suffix - l->name) == 0) |
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; |
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) |
230 soname = basename (s->filename); |
231 |
232 if (strncmp (soname, global_needed->name, 233 suffix - global_needed->name) == 0) |
234 einfo ("%P: warning: %s, needed by %B, may conflict with %s\n", |
235 global_needed->name, global_needed->by, soname); |
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 '/'. */ |
335 soname = basename (abfd->filename); |
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 { |
1008 ASSERT (entry->is_archive && entry->search_dirs_flag); 1009 1010 /* Rather than duplicating the logic above. Just use the |
1011 filename we recorded earlier. */ |
1012 |
1013 filename = xstrdup (basename (entry->filename)); 1014 bfd_elf_set_dt_needed_name (entry->the_bfd, filename); |
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) |
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}, |
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 |
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; |
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")); |
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")); |
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 --- |