Runtime problem with duplicate symbols
nick clifton
nickc@redhat.com
Fri Oct 26 16:21:00 GMT 2012
Hi Florian,
> $ gcc -o demo A.o B.o C.o -lbase
> The binary is just linked fine but it crashes at runtime. The reason
> is that the calls to libbase's init_ATree go to the one of A.o.
>
> Is there any way that we get an error message and link failure at link
> time such that we know that we must rename some symbols instead of
> difficult bug detection?
Not really no. :-( You could try linking with --whole-archive. Ie:
gcc -o demo A.o B.o -Wl,--whole-archive -lbase -Wl,--no-whole-archive
This might work (I have not actually tried it). You would probably only
want to enable this during testing however as it will make your
executables bigger.
Cheers
Nick
More information about the Binutils
mailing list