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: [PATCH] Remove unnecessary IFUNC dispatch for __memset_chk.


On Mon, Aug 17, 2015 at 9:33 AM, Alexander Monakov <amonakov@ispras.ru> wrote:
> On Mon, 17 Aug 2015, H.J. Lu wrote:
>> On Mon, Aug 17, 2015 at 8:54 AM, Alexander Monakov <amonakov@ispras.ru> wrote:
>> > On Tue, 11 Aug 2015, H.J. Lu wrote:
>> >
>> >> On Tue, Aug 11, 2015 at 1:30 PM, OndÅej BÃlka <neleai@seznam.cz> wrote:
>> >> > On Tue, Aug 11, 2015 at 12:55:31PM -0700, H.J. Lu wrote:
>> >> >> On Tue, Aug 11, 2015 at 12:41 PM, Alexander Monakov <amonakov@ispras.ru> wrote:
>> >> >> > On Tue, 11 Aug 2015, H.J. Lu wrote:
>> >> >> >> > Didn't know its explicitly forbidden to use nonstatic resolvers. Do we document that requirement somewhere?
>> >> >> >> > If not then we should add it to documentation.
>> >> >> >>
>> >> >> >> It makes no senses for IFUNC selector to return the address of
>> >> >> >> a global function, which may be preempted at run-time.
>> >> >> >
>> >> >> > That would be imposing a policy while providing a mechanism.
>> >> >> >
>> >> >> > I think there are plausible scenarios where returning a global function from
>> >> >> > an ifunc resolver would be natural.
>> >> >> >
>> >> >> > To give a specific example, imagine an ifunc symbol
>> >> >> > 'printf_fortified_opportunistically', which resolves to 'printf_chk' if it is
>> >> >> > available in the global namespace, or normal 'printf' otherwise.
>> >> >> >
>> >> >> > Such a symbol could be in any DSO, not necessarily libc, and thus it has to be
>> >> >> > able to pick up global symbol definitions.
>> >> >> >
>> >> >>
>> >> >> By the nature of preemption, you have NO control over which definition
>> >> >> will be used at run-time.  It can be literally anything, including segfault.
>> >> >>
>> >> > Could you document that somewhere? Sorry for earlier confusion where I
>> >> > thought you meant resolver must be static. Its about that users could
>> >> > have similar ideas like making symbol global for silly reasons like
>> >> >  be able to profile variant with LD_PRELOAD.
>> >>
>> >> Something like:
>> >>
>> >> If the returned function has non-local binding, the run-time behavior
>> >> is undefined
>> >> as it may be preempted at run-time.
>> >
>> > I still don't understand why you point that out specifically for IFUNC.
>> > Symbol preemption is normal for ELF symbol lookups.  To me it sounds like
>> > saying that "with LD_PRELOAD, the run-time behavior is undefined, as some
>> > symbols are preempted at run-time".
>> >
>>
>> IFUNC selector should be deterministic at run-time on a given hardware.
>> If the function returned by IFUNC selector can be preempted, IFUNC isn't
>> the appropriate approach for this use case.
>
> You appear to be arguing from a standpoint that IFUNC is *exclusively* for
> choosing a CPU-specific variant.  Why do you reject the possibility of using
> IFUNC for different purposes?  I gave one example earlier.
>

I said " IFUNC selector should be deterministic at run-time on a given
hardware."
You can use it for other purpose as long as it is deterministic.  The
whole IFUNC
implementation on x86 is built on this assumption.

-- 
H.J.


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