About hacking libc

Nix nix@esperi.org.uk
Wed Apr 24 21:40:00 GMT 2013

On 24 Apr 2013, Ondřej Bílka told this:

> On Tue, Apr 23, 2013 at 05:53:05PM -0400, Xinyang Ge wrote:
>> Thank you, Carlos.
>> I think the preload way is cleaner and doesn't require recompilation
>> of glibc. However, will there be any symbol conflict between my
>> library and glibc since both have the open() function? How do dynamic
>> linked library avoid symbol conflict? I am really newbie in this
>> field, could you recommend some reading materials to me if possible?
> On conflict resolution symbol that is loaded first wins.

That's not true in general. The ELF rules are much more complex,
since they have to take into account \( .. \) (DT_GROUP), -Bsymbolic,
libraries loaded with dlmopen() and so on.

But, in general, if you avoid all of that, the rules for shared
libraries appear to be the same as for static libraries: i.e., symbols
appearing in libraries specified earlier on the link line take priority
over symbols appearing in libraries specified later.

NULL && (void)

More information about the Libc-help mailing list