Forcing BIND_NOW for a symbol

Florian Weimer
Mon Nov 2 16:14:00 GMT 2015

On 11/02/2015 05:12 PM, Carlos O'Donell wrote:
> On 11/02/2015 10:19 AM, Florian Weimer wrote:
>>>> I'm interested in both the case where this is a completely new symbol
>>>> (so we can do anything we want to make this happen), and existing
>>>> versioned function symbol.
>>> How are they any different?
>> For new interfaces, we can mark them in some way when the final link
>> happens with ld.  For existing binaries, we would have to traverse the
>> list of unresolved symbols at least once, and I think lazy binding is
>> there to avoid exactly that.
> Correct, each undefined symbol would have to get matched up to the definition
> to determine if the definition was declared STT_GNU_IFUNC. Which is equivalent
> to LD_BIND_NOW=1. The optimization is to mark such undefined uses in some way
> and use that list to reduce the number of lookups required.
> Did I understand that right?

Yes, that's why I had in mind.  The question if this is reasonable.

>>>> The idea is to ensure that if there is an IFUNC handler for the symbol,
>>>> the handler is called at load time, and not later during program execution.
>>> Why?
>> I think it's needed for a high-quality implementation of getrandom with
>> an emulation that cannot fail.
> Exactly what failure modes are you considering?

First call to getrandom after chroot, or in a rarely-executed error
handler.  (The latter is not as obscure at it sounds, sometimes
randomness is recommended as a way to obfuscate the case of a
cryptography-related failure.)


More information about the Libc-help mailing list