This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Forcing BIND_NOW for a symbol
- From: Florian Weimer <fweimer at redhat dot com>
- To: "Carlos O'Donell" <carlos at redhat dot com>
- Cc: libc-help <libc-help at sourceware dot org>
- Date: Mon, 2 Nov 2015 17:14:54 +0100
- Subject: Re: Forcing BIND_NOW for a symbol
- Authentication-results: sourceware.org; auth=none
- References: <56376829 dot 7050707 at redhat dot com> <56377C77 dot 2010209 at redhat dot com> <56377EEA dot 3030302 at redhat dot com> <56378B60 dot 7070803 at redhat dot com>
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.)
Florian