aboutsummaryrefslogtreecommitdiff
path: root/gcc/collect2.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@wasabisystems.com>2004-03-10 00:17:36 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2004-03-10 00:17:36 +0000
commit9acd4a03dd2135cfe47c6c9f23c3d98181004fa4 (patch)
treefa0ff5561398e46327d7b72534f74cfe5b34fdb5 /gcc/collect2.c
parentb86f05b692ab2084facc03c49ff231ef1b9388c6 (diff)
downloadgcc-9acd4a03dd2135cfe47c6c9f23c3d98181004fa4.zip
gcc-9acd4a03dd2135cfe47c6c9f23c3d98181004fa4.tar.gz
gcc-9acd4a03dd2135cfe47c6c9f23c3d98181004fa4.tar.bz2
system.h (SUNOS4_SHARED_LIBRARIES): Poison.
* system.h (SUNOS4_SHARED_LIBRARIES): Poison. * collect2.c: Remove SUNOS4_SHARED_LIBRARIES code. * config/sparc/aout.h (TARGET_ASM_SELECT_SECTION): Don't define. * config/sparc/sparc.c (sparc_aout_select_section): Remove. (sparc_aout_select_rtx_section): Don't check SUNOS4_SHARED_LIBRARIES. * config/sparc/sparc.h (SUNOS4_SHARED_LIBRARIES): Don't define. From-SVN: r79216
Diffstat (limited to 'gcc/collect2.c')
-rw-r--r--gcc/collect2.c267
1 files changed, 1 insertions, 266 deletions
diff --git a/gcc/collect2.c b/gcc/collect2.c
index 4fbe3a4..b9c7cae 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -67,7 +67,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
cross-versions are in the proper directories. */
#ifdef CROSS_COMPILE
-#undef SUNOS4_SHARED_LIBRARIES
#undef OBJECT_FORMAT_COFF
#undef MD_EXEC_PREFIX
#undef REAL_LD_FILE_NAME
@@ -140,7 +139,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
fprintf ((STREAM), "void _GLOBAL__DD() {\n\t%s();\n}\n", (FUNC))
#endif
-#if defined (LDD_SUFFIX) || SUNOS4_SHARED_LIBRARIES
+#ifdef LDD_SUFFIX
#define SCAN_LIBRARIES
#endif
@@ -2148,269 +2147,6 @@ scan_prog_file (const char *prog_name, enum pass which_pass)
#endif
}
-#if SUNOS4_SHARED_LIBRARIES
-
-/* Routines to scan the SunOS 4 _DYNAMIC structure to find shared libraries
- that the output file depends upon and their initialization/finalization
- routines, if any. */
-
-#include <a.out.h>
-#include <fcntl.h>
-#include <link.h>
-#include <sys/mman.h>
-#include <sys/param.h>
-#include <unistd.h>
-#include <sys/dir.h>
-
-/* pointers to the object file */
-unsigned object; /* address of memory mapped file */
-unsigned objsize; /* size of memory mapped to file */
-char * code; /* pointer to code segment */
-char * data; /* pointer to data segment */
-struct nlist *symtab; /* pointer to symbol table */
-struct link_dynamic *ld;
-struct link_dynamic_2 *ld_2;
-struct head libraries;
-
-/* Map the file indicated by NAME into memory and store its address. */
-
-static void
-mapfile (const char *name)
-{
- int fp;
- struct stat s;
- if ((fp = open (name, O_RDONLY)) == -1)
- fatal ("unable to open file '%s'", name);
- if (fstat (fp, &s) == -1)
- fatal ("unable to stat file '%s'", name);
-
- objsize = s.st_size;
- object = (unsigned) mmap (0, objsize, PROT_READ|PROT_WRITE, MAP_PRIVATE,
- fp, 0);
- if (object == (unsigned)-1)
- fatal ("unable to mmap file '%s'", name);
-
- close (fp);
-}
-
-/* Helpers for locatelib. */
-
-static const char *libname;
-
-static int
-libselect (struct direct *d)
-{
- return (strncmp (libname, d->d_name, strlen (libname)) == 0);
-}
-
-/* If one file has an additional numeric extension past LIBNAME, then put
- that one first in the sort. If both files have additional numeric
- extensions, then put the one with the higher number first in the sort.
-
- We must verify that the extension is numeric, because Sun saves the
- original versions of patched libraries with a .FCS extension. Files with
- invalid extensions must go last in the sort, so that they will not be used. */
-
-static int
-libcompare (struct direct **d1, struct direct **d2)
-{
- int i1, i2 = strlen (libname);
- char *e1 = (*d1)->d_name + i2;
- char *e2 = (*d2)->d_name + i2;
-
- while (*e1 && *e2 && *e1 == '.' && *e2 == '.'
- && e1[1] && ISDIGIT (e1[1]) && e2[1] && ISDIGIT (e2[1]))
- {
- ++e1;
- ++e2;
- i1 = strtol (e1, &e1, 10);
- i2 = strtol (e2, &e2, 10);
- if (i1 != i2)
- return i1 - i2;
- }
-
- if (*e1)
- {
- /* It has a valid numeric extension, prefer this one. */
- if (*e1 == '.' && e1[1] && ISDIGIT (e1[1]))
- return 1;
- /* It has an invalid numeric extension, must prefer the other one. */
- else
- return -1;
- }
- else if (*e2)
- {
- /* It has a valid numeric extension, prefer this one. */
- if (*e2 == '.' && e2[1] && ISDIGIT (e2[1]))
- return -1;
- /* It has an invalid numeric extension, must prefer the other one. */
- else
- return 1;
- }
- else
- return 0;
-}
-
-/* Given the name NAME of a dynamic dependency, find its pathname and add
- it to the list of libraries. */
-
-static void
-locatelib (const char *name)
-{
- static const char **l;
- static int cnt;
- char buf[MAXPATHLEN];
- char *p, *q;
- const char **pp;
-
- if (l == 0)
- {
- char *ld_rules;
- char *ldr = 0;
- /* counting elements in array, need 1 extra for null */
- cnt = 1;
- ld_rules = (char *) (ld_2->ld_rules + code);
- if (ld_rules)
- {
- cnt++;
- for (; *ld_rules != 0; ld_rules++)
- if (*ld_rules == ':')
- cnt++;
- ld_rules = (char *) (ld_2->ld_rules + code);
- ldr = xstrdup (ld_rules);
- }
- p = getenv ("LD_LIBRARY_PATH");
- q = 0;
- if (p)
- {
- cnt++;
- for (q = p ; *q != 0; q++)
- if (*q == ':')
- cnt++;
- q = xstrdup (p);
- }
- l = xmalloc ((cnt + 3) * sizeof (char *));
- pp = l;
- if (ldr)
- {
- *pp++ = ldr;
- for (; *ldr != 0; ldr++)
- if (*ldr == ':')
- {
- *ldr++ = 0;
- *pp++ = ldr;
- }
- }
- if (q)
- {
- *pp++ = q;
- for (; *q != 0; q++)
- if (*q == ':')
- {
- *q++ = 0;
- *pp++ = q;
- }
- }
- /* built in directories are /lib, /usr/lib, and /usr/local/lib */
- *pp++ = "/lib";
- *pp++ = "/usr/lib";
- *pp++ = "/usr/local/lib";
- *pp = 0;
- }
- libname = name;
- for (pp = l; *pp != 0 ; pp++)
- {
- struct direct **namelist;
- int entries;
- if ((entries = scandir (*pp, &namelist, libselect, libcompare)) > 0)
- {
- sprintf (buf, "%s/%s", *pp, namelist[entries - 1]->d_name);
- add_to_list (&libraries, buf);
- if (debug)
- fprintf (stderr, "%s\n", buf);
- break;
- }
- }
- if (*pp == 0)
- {
- if (debug)
- notice ("not found\n");
- else
- fatal ("dynamic dependency %s not found", name);
- }
-}
-
-/* Scan the _DYNAMIC structure of the output file to find shared libraries
- that it depends upon and any constructors or destructors they contain. */
-
-static void
-scan_libraries (const char *prog_name)
-{
- struct exec *header;
- char *base;
- struct link_object *lo;
- char buff[MAXPATHLEN];
- struct id *list;
-
- mapfile (prog_name);
- header = (struct exec *)object;
- if (N_BADMAG (*header))
- fatal ("bad magic number in file '%s'", prog_name);
- if (header->a_dynamic == 0)
- return;
-
- code = (char *) (N_TXTOFF (*header) + (long) header);
- data = (char *) (N_DATOFF (*header) + (long) header);
- symtab = (struct nlist *) (N_SYMOFF (*header) + (long) header);
-
- if (header->a_magic == ZMAGIC && header->a_entry == 0x20)
- {
- /* shared object */
- ld = (struct link_dynamic *) (symtab->n_value + code);
- base = code;
- }
- else
- {
- /* executable */
- ld = (struct link_dynamic *) data;
- base = code-PAGSIZ;
- }
-
- if (debug)
- notice ("dynamic dependencies.\n");
-
- ld_2 = (struct link_dynamic_2 *) ((long) ld->ld_un.ld_2 + (long)base);
- for (lo = (struct link_object *) ld_2->ld_need; lo;
- lo = (struct link_object *) lo->lo_next)
- {
- char *name;
- lo = (struct link_object *) ((long) lo + code);
- name = (char *) (code + lo->lo_name);
- if (lo->lo_library)
- {
- if (debug)
- fprintf (stderr, "\t-l%s.%d => ", name, lo->lo_major);
- sprintf (buff, "lib%s.so.%d.%d", name, lo->lo_major, lo->lo_minor);
- locatelib (buff);
- }
- else
- {
- if (debug)
- fprintf (stderr, "\t%s\n", name);
- add_to_list (&libraries, name);
- }
- }
-
- if (debug)
- fprintf (stderr, "\n");
-
- /* Now iterate through the library list adding their symbols to
- the list. */
- for (list = libraries.first; list; list = list->next)
- scan_prog_file (list->name, PASS_LIB);
-}
-
-#else /* SUNOS4_SHARED_LIBRARIES */
#ifdef LDD_SUFFIX
/* Use the List Dynamic Dependencies program to find shared libraries that
@@ -2547,7 +2283,6 @@ scan_libraries (const char *prog_name)
}
#endif /* LDD_SUFFIX */
-#endif /* SUNOS4_SHARED_LIBRARIES */
#endif /* OBJECT_FORMAT_NONE */