Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 08 Feb 2002 11:15:43 +0200
From:      Maxim Sobolev <sobomax@FreeBSD.org>
To:        Terry Lambert <tlambert2@mindspring.com>
Cc:        jdp@FreeBSD.org, deischen@FreeBSD.org, jasone@FreeBSD.org, hackers@FreeBSD.org, jlemon@FreeBSD.org
Subject:   Re: Linking libc before libc_r into application causes weird problems
Message-ID:  <3C63973F.111CF6D1@FreeBSD.org>
References:  <1013147180.73417.2.camel@notebook> <3C637097.13B8C35A@mindspring.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Terry Lambert wrote:
> 
> Maxim Sobolev wrote:
> > $ cc test.c -o test -lc -lc_r
> >
> > When either of -lc or -lc_r is omitted, or their order is reversed the
> > problem disappears. The problem doesn't exist on 4-STABLE.
> >
> > Any ideas, comments and suggestions are welcome.
> 
> Symbols are resolved from libraries in the order in which
> they are specified to the linker.
> 
> So the fix is obvious: specify them in the right order.
> 
> Linux doesn't see this because libc_r is just there for
> the reentrant calls, and their threading uses processes,
> instead of a user space ("quantum conservation") scheduler.

All not as easy as it seems to be. -lc could come not from the command
line, but from one of the other libraries the binary being linked
with. Therefore, in real life resolving this problem could be a little
more tricky, especially with large applications (e.g. Evolution), that
uses code from 30+ shared libraries. I think that ld(1) should be
smart enough to reorder libc/libc_r so that libc_r is always linked
before libc.

-Maxim

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3C63973F.111CF6D1>