From patchwork Mon Feb 4 13:56:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: collect2 should accept more AIX linker flags to change shared library search order From: Michael Haubenwallner X-Patchwork-Id: 217932 Message-Id: <510FBE02.40704@salomon.at> To: GCC Patches Date: Mon, 04 Feb 2013 14:56:18 +0100 Hi, when using "-shared -Wl,-G" to create AIX shared libraries for use with runtime linking, without also using "-Wl,-brtl" collect2 still does search for lib.a before lib.so, eventually registering global constructors found in static lib.a, which are not exported by lib.so, so the subsequent link step fails resolving these symbols. Thank you! /haubi/ 2013-02-04 Michael Haubenwallner Accept all flags that enable aix runtime linking to change the library search order. Also there is a disabling flag. * collect2.c (aixrtl_flag): Enabled by -G and -bsvr4 too. Disabled by -bnortl. No false positive on -brtllib or -bnortllib. --- gcc/collect2.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gcc/collect2.c b/gcc/collect2.c index 0db908f..a9fd7a7 100644 --- a/gcc/collect2.c +++ b/gcc/collect2.c @@ -1033,9 +1033,15 @@ main (int argc, char **argv) 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; + else if (arg[2] == 'r' && arg[3] == 't' && arg[4] == 'l' && arg[5] == '\0') + aixrtl_flag = 1; /* -brtl (not -brtllib) */ + else if (arg[2] == 'n' && arg[3] == 'o' && arg[4] == 'r' && arg[5] == 't' && arg[6] == 'l' && arg[7] == '\0') + aixrtl_flag = 0; /* -bnortl (not -bnortllib) */ + else if (arg[2] == 's' && arg[3] == 'v' && arg[4] == 'r' && arg[5] == '4') + aixrtl_flag = 1; /* -bsvr4 enables -brtl */ } + if ((argv[i][0] == '-') && (argv[i][1] == 'G')) + aixrtl_flag = 1; /* -G enables -brtl */ #endif } vflag = debug; -- 1.7.3.4