This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
rtld: resolve incoming STT_GNU_IFUNC only after DT_INIT
- From: John Reiser <jreiser at bitwagon dot com>
- To: binutils at sourceware dot org
- Date: Wed, 1 Nov 2017 09:10:32 -0700
- Subject: rtld: resolve incoming STT_GNU_IFUNC only after DT_INIT
- Authentication-results: sourceware.org; auth=none
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?
--