summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/collect2.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-09-18 05:45:16 +0000
committerpeter <peter@FreeBSD.org>1996-09-18 05:45:16 +0000
commitacb2bcd1679fc89c82b1ebd30a92fe0538b7f4dc (patch)
tree63294164689f80893cbbe6bd77927b5abe4339e9 /contrib/gcc/collect2.c
parentd4691e641ba47cb86eef80f5c879e13f9d961724 (diff)
downloadFreeBSD-src-acb2bcd1679fc89c82b1ebd30a92fe0538b7f4dc.zip
FreeBSD-src-acb2bcd1679fc89c82b1ebd30a92fe0538b7f4dc.tar.gz
Import of 2.7.2.1 into vendor branch
Diffstat (limited to 'contrib/gcc/collect2.c')
-rw-r--r--contrib/gcc/collect2.c106
1 files changed, 52 insertions, 54 deletions
diff --git a/contrib/gcc/collect2.c b/contrib/gcc/collect2.c
index a74a7f0..30fb49d 100644
--- a/contrib/gcc/collect2.c
+++ b/contrib/gcc/collect2.c
@@ -255,7 +255,6 @@ static char *temp_filename; /* Base of temp filenames */
static char *c_file; /* <xxx>.c for constructor/destructor list. */
static char *o_file; /* <xxx>.o for constructor/destructor list. */
static char *export_file; /* <xxx>.x for AIX export list. */
-static int auto_export = 1; /* true if exporting everything. */
char *ldout; /* File for ld errors. */
static char *output_file; /* Output file for ld. */
static char *nm_file_name; /* pathname of nm */
@@ -1243,15 +1242,6 @@ main (argc, argv)
}
break;
-#ifdef COLLECT_EXPORT_LIST
- case 'b':
- if ((!strncmp (arg, "-bE:", 4)
- || !strncmp (arg, "-bexport:", 9))
- && strcmp (arg, "-bexport:/usr/lib/libg.exp"))
- auto_export = 0;
- break;
-#endif
-
case 'l':
if (first_file)
{
@@ -2554,8 +2544,6 @@ scan_prog_file (prog_name, which_pass)
break;
default: /* not a constructor or destructor */
- if (which_pass == PASS_OBJ && auto_export)
- add_to_list (&exports, name);
continue;
}
@@ -2606,62 +2594,72 @@ scan_libraries (prog_name)
{
LDHDR ldh;
char *impbuf;
- int idx;
+ int entry;
+
FSEEK (ldptr, ldsh.s_scnptr, BEGINNING);
- FREAD (&ldh, sizeof ldh, 1, ldptr);
+ FREAD (&ldh, sizeof (ldh), 1, ldptr);
/* read import library list */
impbuf = alloca (ldh.l_istlen);
FSEEK (ldptr, ldh.l_impoff + ldsh.s_scnptr, BEGINNING);
FREAD (impbuf, ldh.l_istlen, 1, ldptr);
- idx = strlen (impbuf) + 1;
- idx += strlen (impbuf+idx) + 1;
+
if (debug)
fprintf (stderr, "LIBPATH=%s\n", impbuf);
prefix_from_string (impbuf, &libpath);
- while (idx < ldh.l_istlen)
+
+ /* skip LIBPATH and empty base and member fields */
+ impbuf += strlen (impbuf) + 3;
+ for (entry = 1; entry < ldh.l_nimpid; ++entry)
{
- char *implib = impbuf + idx;
+ char *impath = impbuf;
+ char *implib = impath + strlen (impath) + 1;
char *impmem = implib + strlen (implib) + 1;
- char *soname = 0;
+ char *soname = NULL;
+ char *trial;
+ int pathlen;
LDFILE *libptr = NULL;
struct prefix_list *pl;
ARCHDR ah;
- idx += strlen (implib) + 1;
- if (!implib[0])
+
+ impbuf = impmem + strlen (impmem) + 1;
+ if (debug)
+ fprintf (stderr, "PATH+BASE=%s%s\n", impath, implib);
+ /* Skip AIX kernel exports */
+ if (*impath == '/' && *(impath+1) == '\0'
+ && strcmp (implib, "unix") == 0)
continue;
- idx += strlen (impmem) + 1;
- if (*implib == '/')
+ pathlen = strlen (impath);
+ trial = alloca (MAX (pathlen + 1, libpath.max_len)
+ + strlen (implib) + 1);
+ if (*impath)
{
- if (access (soname, R_OK) == 0)
- soname = implib;
+ strcpy (trial, impath);
+ if (impath[pathlen - 1] != '/')
+ trial[pathlen++] = '/';
+ strcpy (trial + pathlen, implib);
+ if (access (trial, R_OK) == 0)
+ soname = trial;
}
else
- {
- char *temp = alloca (libpath.max_len + strlen (implib) + 1);
- for (pl = libpath.plist; pl; pl = pl->next)
- {
- strcpy (temp, pl->prefix);
- strcat (temp, implib);
- if (access (temp, R_OK) == 0)
- {
- soname = temp;
- break;
- }
- }
- }
- if (!soname)
- {
- fatal ("%s: library not found", implib);
- continue;
- }
+ for (pl = libpath.plist; pl; pl = pl->next)
+ {
+ strcpy (trial, pl->prefix);
+ strcat (trial, implib);
+ if (access (trial, R_OK) == 0)
+ {
+ soname = trial;
+ break;
+ }
+ }
+
+ if (! soname)
+ fatal ("%s: library not found", implib);
if (debug)
- {
- if (impmem[0])
- fprintf (stderr, "%s (%s)\n", soname, impmem);
- else
- fprintf (stderr, "%s\n", soname);
- }
- ah.ar_name[0] = 0;
+ if (*impmem)
+ fprintf (stderr, "%s (%s)\n", soname, impmem);
+ else
+ fprintf (stderr, "%s\n", soname);
+
do
{
/* scan imported shared objects for GCC GLOBAL ctors */
@@ -2671,7 +2669,7 @@ scan_libraries (prog_name)
if (TYPE (libptr) == ARTYPE)
{
LDFILE *memptr;
- if (!impmem[0])
+ if (! *impmem)
fatal ("%s: no archive member specified", soname);
ldahread (libptr, &ah);
if (strcmp (ah.ar_name, impmem))
@@ -2688,12 +2686,12 @@ scan_libraries (prog_name)
if (!ldnshread (libptr, _LOADER, &soldsh))
fatal ("%s: not an import library", soname);
FSEEK (libptr, soldsh.s_scnptr, BEGINNING);
- if (FREAD (&soldh, sizeof soldh, 1, libptr) != 1)
+ if (FREAD (&soldh, sizeof (soldh), 1, libptr) != 1)
fatal ("%s: can't read loader section", soname);
/*fprintf (stderr, "\tscanning %s\n", soname);*/
symcnt = soldh.l_nsyms;
- lsyms = (LDSYM*) alloca (symcnt * sizeof *lsyms);
- symcnt = FREAD (lsyms, sizeof *lsyms, symcnt, libptr);
+ lsyms = (LDSYM*) alloca (symcnt * sizeof (*lsyms));
+ symcnt = FREAD (lsyms, sizeof (*lsyms), symcnt, libptr);
ldstrings = alloca (soldh.l_stlen);
FSEEK (libptr, soldsh.s_scnptr+soldh.l_stoff, BEGINNING);
FREAD (ldstrings, soldh.l_stlen, 1, libptr);
OpenPOWER on IntegriCloud