This is the mail archive of the libc-alpha@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: rtld: resolve incoming STT_GNU_IFUNC only after DT_INIT


On 01/11/17 17:57, John Reiser wrote:
> On 11/01/2017 1724Z, Florian Weimer wrote:
>> * John Reiser:
>>
>>> However, a relocation from some other module to a STT_GNU_IFUNC symbol
>>> in the current shared library cannot be intercepted like that.
>>> That's why DT_INIT should be called before such a relocation is resolved,
>>> so that the IFUNC code can be de-compressed into the right place
>>> before it gets called.
>>
>> I don't think it's safe at all to call DT_INIT during relocation
>> processing.  You need to explain why you think it is.
> 
> If all processing is done in dependency order (thus "B depends on A"
> requires that all processing of A occurs before any processing of B;
> this includes "B has a relocation that designates a symbol that is
> resolved by A with type STT_GNU_IFUNC")
> *and* if internal STT_GNU_IFUNC resolution within the same module
> is hidden from rtld like I have suggested, then calling the DT_INIT
> will be safe.

the dynamic linker must call DT_INIT after relocation
processing is finished:

"After the dynamic linker has built the process image
and performed the relocations, each shared object and
the executable file get the opportunity to execute some
initialization functions."
http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#init_fini

so doing .text decompression in DT_INIT does not
conform to the elf spec (what if there are textrels?).

>  All the STT_GNU_IFUNC symbols in predecessor modules
> in the dependency order will be available, and all the STT_GNU_IFUNC
> symbols in the same current module will be specially processed (transformed
> into R_*_IRELATIVE by /bin/ld, hidden from rtld by the compressor, and
> resolved by DT_INIT as soon as their instructions have been de-compressed
> and before any "normal" execution begins.)
> 

ifuncs of the same module can be used from DT_INIT,
this should work otherwise the dynamic linker is
non-conforming, which means their relocation cannot
be delayed after DT_INIT.


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