bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug ld/2143] New: Unresolvable reference by DSO to hidden symbol de


From: vamsi krishna
Subject: Re: [Bug ld/2143] New: Unresolvable reference by DSO to hidden symbol despite --allow-shlib-undefined
Date: Thu, 12 Jan 2006 23:22:06 +0530

Hello,

Dont use 'ld' directly to create the shared libraries. Use gcc --shared. I had the same problem earlier and this seems to be the workaround.
<------------------------------------------>
$ gcc -Wall -W -fPIC -c -o oldlib.o oldlib.c
$ gcc  --shared -o liboldlib.so oldlib.o
<----------------------------------------->

gcc has a much better linker driver than bare ld.

Thank you,
Vamsi


On 12 Jan 2006 11:40:56 -0000, jan dot echternach at group-technologies dot com <address@hidden > wrote:
I'm getting a "hidden symbol is referenced by DSO" error if I link a program
with both LSB2's libc.so and an old libnotes.so from Lotus Domino 6.
libnotes.so has an undefined reference to atexit, LSB2's libc.so has no
definition of that symbol, but there is a hidden atexit symbol in
libc_nonshared.a.

I tried both the preinstalled ld (GNU ld version 2.15.94.0.2.2 20041220 (SuSE
Linux)) and the ld from binutils-2.16.91.0.5 (GNU ld version 2.16.91.0.5
20051219).

I can reproduce the error without libnotes.so by linking with a dummy DSO that
has only an undefined 'atexit' reference.  It is possible to work around the
problem by removing the hidden atexit symbol from libc_nonshared.a.

$ cat oldlib.c
#include < stdlib.h>
int (*oldlib_ptr) (void (*) (void)) = atexit;
$ cat main.c
int main (void) { return 0; }

$ gcc -Wall -W -fPIC -c -o oldlib.o oldlib.c
$ ld -shared -o liboldlib.so oldlib.o

$ gcc -Wall -W -o main1 main.c -Wl,--allow-shlib-undefined -L. -loldlib \
        -I/opt/lsb/include -L/opt/lsb/lib -lc -lc_nonshared
/usr/lib/gcc-lib/i586-suse-linux/3.3.5/../../../../i586-suse-linux/bin/ld:
main1: hidden symbol `atexit' in /usr/lib/gcc-lib/i586-suse-
linux/3.3.5/../../../libc_nonshared.a(atexit.oS) is referenced by DSO
/usr/lib/gcc-lib/i586-suse-linux/3.3.5/../../../../i586-suse-linux/bin/ld:
final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status

$ cp /usr/lib/libc_nonshared.a libc_nonshared_noatexit.a
$ ar d libc_nonshared_noatexit.a atexit.oS
$ gcc -Wall -W -o main2 main.c -Wl,--allow-shlib-undefined -L. -loldlib \
        -I/opt/lsb/include -L/opt/lsb/lib -lc -lc_nonshared_noatexit

(No error in this case.)

There's no doubt that the hidden symbol can't resolve the reference by the
DSO.  But I think ld should just leave the reference unresolved if --allow-
shlib-undefined is specified.  There are plenty of other references in
libnotes.so that can't be resolved and cause no complaints.

--
           Summary: Unresolvable reference by DSO to hidden symbol despite -
                    -allow-shlib-undefined
           Product: binutils
           Version: 2.16
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
        AssignedTo: unassigned at sources dot redhat dot com
        ReportedBy: jan dot echternach at group-technologies dot com
                CC: bug-binutils at gnu dot org
  GCC host triplet: i586-suse-linux
GCC target triplet: i586-suse-linux


http://sourceware.org/bugzilla/show_bug.cgi?id=2143

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/bug-binutils


reply via email to

[Prev in Thread] Current Thread [Next in Thread]