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 11/01/2017 1815Z, Szabolcs Nagy wrote:

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?).

The compressor, of course, declines to compress when it sees DT_TEXTREL.

Because that standard does not explain why DT_INIT processing should be
delayed until the entire process image has been built (instead of
allowing DT_INIT to be called at any time in dependency order),
and because I can find no corresponding rationale document, and
because it seems that important opinions are against an "as if"
interpretation that would allow dependency order, then I now have
an excuse for compression to introduce a 1-instruction trampoline
for every STT_GNU_IFUNC symbol.  The compressor will change IFUNC to
a regular FUNC, and point the symbol at a trampoline similar in spirit
to a PLT (ProgramLinkageTable).  The de-compressor will manage it.
If IFUNC provides such a great advantage, then 1 more branch delay
can be tolerated.

Of course it is possible for a DT_INIT to create significant mischief,
such as by calling dlopen() and/or dlclose() of successors in the
dependency order; or by calling dl_iterate_phdr(), etc.; but that's
what it is: mischief.  [And there are other ways, too.]
Yet dependency order has *many* advantages.

Thank you all for consultation.

--


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