static linking failed with sigaction testing program

Kevin Cernekee cernekee at gmail.com
Sun Mar 27 07:33:20 UTC 2011


On Sat, Mar 26, 2011 at 10:26 PM, Mike Frysinger <vapier at gentoo.org> wrote:
> really you should be looking at how the linker processes things.  use
> -Wl,-M for both.

Thanks for the tip.  That is useful.

So, for "-static -lpthread -lc" on uClibc:

The test program needs sigaction(), and this pulls in
libpthread.a(pt-sigaction.os).  So far so good.

But later on, libc.a(abort.os) needs __GI_sigaction().  This symbol
exists in libc.a(sigaction.os) but not in
libpthread.a(pt-sigaction.os).  So the linker winds up grabbing both
.os files.  A few strong symbols are duplicated in both
libc.a(sigaction.os) and libpthread.a(pt-sigaction.os), which causes
the link to fail.

For "-static -lpthread -lc" on glibc, there is no __GI_sigaction() to
complicate matters.  abort() calls __sigaction().  Either
libc.a(sigaction.o) or libpthread.a(sigaction.o) can satisfy this
dependency, so there is no reason why the linker would ever try to
grab both copies of sigaction.o .

Interestingly, if I rebuild uClibc with DOPIC disabled,
libpthread.a(pt-sigaction.o) now contains __GI_sigaction() and thus
the conflict vanishes.

I don't know why DOPIC was enabled in the first place, or what else
might break due to the change.  Time to run some more tests.


More information about the uClibc mailing list