This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: rtld: resolve incoming STT_GNU_IFUNC only after DT_INIT


On 11/01/2017 09:10 AM, John Reiser wrote:
> When loading a shared library, either DT_NEEDED or via dlopen(), then the
> processing by rtld of relocations in other modules which refer to STT_GNU_IFUNC
> symbols in the current library causes problems for me.  Relocating
> a reference from outside to a STT_GNU_IFUNC symbol causes the IFUNC code
> to be called before the DT_INIT executes.  This is not nice.  The _addresses_
> in the relocation struct and symbol table are correct, but the instructions
> are not there until DT_INIT executes.  My DT_INIT is a decompressor of the
> tail of PT_LOAD[0], and the IFUNC code often is in the compressed tail.
> [A reference to an STT_GNU_IFUNC symbol from inside the same library
> is handled via an R_*_IRELATIVE relocation which the compressor hides
> from rtld, and the decompressor handles separately.  A similar dodge
> cannot be done for references from other modules.]
> 
> It seems to me that rtld could change the order of evaluation, so that
> DT_INIT is called before any other code in the library is executed,
> including the code for resolving incoming references to STT_GNU_IFUNC
> symbols in the library.  Comments?
 
The dynamic loader lives in glibc, please repost to libc-alpha@sourceware.org.

Please CC Florian Weimer <fweimer@redhat.com> since we're looking at making
IFUNCs into a 2-pass process to avoid some of the more conceptually complex
ordering issues.

-- 
Cheers,
Carlos.


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