[PATCH] AIX collect2, check for -brtl etc before reading libraries/objects
Peter O'Gorman
pogma@thewrittenword.com
Fri Sep 25 19:07:00 GMT 2009
Hi,
AIX collect2 looks for symbols in libraries ending in .a unless there is
a -brtl on the link line, in which case it looks for .so. We had an
issue where libtool + gcc (4.2.4 in this case) was generating programs
that would not run because of undefined symbols. It was getting
constructor/destructor names from .a libs even though there was a -brtl
on the link line (it was the last thing on the link line), and a .so lib
sitting there saying 'Hi!'.
Turns out that collect2 was treating -brtl as a position dependent flag,
which it is not. This patch moves the check for -brtl, -bexport/-bE, and
-64 to before any libraries are added to the list. This fixed our build
issue for gcc-4.2.4. The issue doesn't appear to have changed any for
trunk.
Ok?
2009-09-25 Peter O'Gorman <pogma@thewrittenword.com>
collect2.c (main): Look for -brtl before adding libraries.
Peter
--
Peter O'Gorman
pogma@thewrittenword.com
-------------- next part --------------
Index: collect2.c
===================================================================
--- collect2.c (revision 152127)
+++ collect2.c (working copy)
@@ -943,6 +943,22 @@
{
if (! strcmp (argv[i], "-debug"))
debug = 1;
+#ifdef COLLECT_EXPORT_LIST
+ /* since -brtl, -bexport, -b64 are not position dependent
+ * also check for them here */
+ if ((argv[i][0] == '-') && (argv[i][1] == 'b'))
+ {
+ arg = argv[i];
+ /* We want to disable automatic exports on AIX when user
+ explicitly puts an export list in command line */
+ if (arg[2] == 'E' || strncmp (&arg[2], "export", 6) == 0)
+ export_flag = 1;
+ else if (arg[2] == '6' && arg[3] == '4')
+ aix64_flag = 1;
+ else if (arg[2] == 'r' && arg[3] == 't' && arg[4] == 'l')
+ aixrtl_flag = 1;
+ }
+#endif
}
vflag = debug;
}
@@ -1164,19 +1180,6 @@
{
switch (arg[1])
{
-#ifdef COLLECT_EXPORT_LIST
- /* We want to disable automatic exports on AIX when user
- explicitly puts an export list in command line */
- case 'b':
- if (arg[2] == 'E' || strncmp (&arg[2], "export", 6) == 0)
- export_flag = 1;
- else if (arg[2] == '6' && arg[3] == '4')
- aix64_flag = 1;
- else if (arg[2] == 'r' && arg[3] == 't' && arg[4] == 'l')
- aixrtl_flag = 1;
- break;
-#endif
-
case 'd':
if (!strcmp (arg, "-debug"))
{
More information about the Gcc-patches
mailing list