[Bug c++/13150] New: WEAK symbols not exported by collect2
greed at pobox dot com
gcc-bugzilla@gcc.gnu.org
Fri Nov 21 16:03:00 GMT 2003
GCC 3.3 and up on AIX 5.2 correctly detect that the native assembler and linker
finally support weak symbols (though there are still issues...).
But collect2 doesn't recognize any weak exported symbol as being exported, so
GCC's C++ libraries, wind up with Important Things inaccessible. Here's a
simple testcase, using only C, to show the problem:
% cat >lib.c <<'EOF'
int __attribute__ ((weak)) a = 20;
int foo (void) { return a; }
EOF
% cat >prog.c <<'EOF'
extern int a;
int main(int argc,char ** argv) { return a; }
EOF
Compiled using:
% gcc -shared -o liblib.so lib.c
% gcc -Wl,-brtl,-bnortllib -o prog prog.c -L. -llib
ld: 0711-317 ERROR: Undefined symbol: a
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: ld returned 8 exit status
If we examine the static symbol table of liblib.so, we see 'a' is present and
marked weak as expected:
% dump -tv liblib.so | grep ' a'
[2] m 0x20000340 .data 1 unamex a
[14] m 0x20000290 .data 1 weak a
But the dynamic symbol table does not have 'a':
% dump -Tv liblib.so | grep ' a'
[no output]
I have updated collect2.c to recognize AIX's C_WEAKEXT and consider such symbols
candidates for exporting. The patch will be attached after I open this.
With the patch, the dynamic symbol table becomes:
[1] 0x20000290 .data wEXP RW Ldef [noIMid] a
(Also, the unused function foo is no longer required to fool linker into keeping
'a'.)
--
Summary: WEAK symbols not exported by collect2
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: greed at pobox dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: powerpc-ibm-aix5.2.0.0
GCC host triplet: powerpc-ibm-aix5.2.0.0
GCC target triplet: powerpc-ibm-aix5.2.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13150
More information about the Gcc-bugs
mailing list