aboutsummaryrefslogtreecommitdiff
path: root/gcc/collect2.c
diff options
context:
space:
mode:
authorJason Merrill <merrill@gnu.org>1995-02-13 20:21:44 +0000
committerJason Merrill <merrill@gnu.org>1995-02-13 20:21:44 +0000
commit9f21696b100aee891659bb39d4850295f7877912 (patch)
treec3773f34c1bfdd99f54d975ffef28d44d0a9d281 /gcc/collect2.c
parentd1e1adfb128e33b98deb622af8e33844c1d98d2b (diff)
downloadgcc-9f21696b100aee891659bb39d4850295f7877912.zip
gcc-9f21696b100aee891659bb39d4850295f7877912.tar.gz
gcc-9f21696b100aee891659bb39d4850295f7877912.tar.bz2
Fix collecting under AIX
From-SVN: r8933
Diffstat (limited to 'gcc/collect2.c')
-rw-r--r--gcc/collect2.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/gcc/collect2.c b/gcc/collect2.c
index be28cc6..c47a167 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -824,6 +824,8 @@ main (argc, argv)
char **ld1 = ld1_argv;
char **ld2_argv = (char **) xcalloc (sizeof (char *), argc+5);
char **ld2 = ld2_argv;
+ char **object_lst = (char **) xcalloc (sizeof (char *), argc);
+ char **object = object_lst;
int first_file;
int num_c_args = argc+7;
@@ -1154,15 +1156,19 @@ main (argc, argv)
break;
}
}
- else if (first_file
- && (p = rindex (arg, '.')) != (char *)0
+ else if ((p = rindex (arg, '.')) != (char *)0
&& (strcmp (p, ".o") == 0 || strcmp (p, ".a") == 0))
{
- first_file = 0;
- /* place o_file BEFORE this argument! */
- ld2--;
- *ld2++ = o_file;
- *ld2++ = arg;
+ if (first_file)
+ {
+ first_file = 0;
+ /* place o_file BEFORE this argument! */
+ ld2--;
+ *ld2++ = o_file;
+ *ld2++ = arg;
+ }
+ if (p[1] == 'o')
+ *object++ = arg;
}
}
@@ -1261,6 +1267,13 @@ main (argc, argv)
if (rflag)
return 0;
+#ifdef COLLECT_SCAN_OBJECTS
+ /* The AIX linker will discard static constructors in object files if
+ nothing else in the file is referenced, so look at them first. */
+ while (object_lst < object)
+ scan_prog_file (*object_lst++, PASS_FIRST);
+#endif
+
scan_prog_file (output_file, PASS_FIRST);
#ifdef SCAN_LIBRARIES