This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to detect symbol interposition?


On 06/28/2016 07:00 PM, Carlos O'Donell wrote:
On 06/28/2016 10:12 AM, Florian Weimer wrote:
I need a way to detect symbol interposition from within libc.

I assume you mean you will be writing code that lives in libc and needs
to determine that ld.so has interposed a libc symbol with a symbol from
another library?

Yes.

It seems that this is not directly distinguishable from interposition
based on addresses alone:

[snip]

If I have a hidden alias of malloc within libc (say, __libc_malloc),
so that I can get the original address, it will be not equal to
malloc because malloc in the entire process will point to the PLT
stub.  The PLT stub will call malloc, of course, but you cannot tell
this from its address.

And this changes depending on the architecture details.

Are their architectures where the interposition is made explicit and shows up in .dynsym?

The only solution that I know of is to use the LD_AUDIT mechanisms to
catch the PLT resolution and observe the final address of the resolution.

The logic has to go into libc.so proper, so LD_AUDIT is not an option.

Unless there are architectures where the static linker constructs PLT stubs with special relocations (RTLD_NEXT-style) and then interposes the PLT stub via .dynsym, surely ld.so has access to this information, at least at a conceptual level?

Thanks,
Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]