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 Tue, Aug 11, 2015 at 1:04 AM, OndÅej BÃlka <neleai@seznam.cz> wrote:
> On Mon, Aug 10, 2015 at 07:41:49PM -0400, Zack Weinberg wrote:
>> On Mon, Aug 10, 2015 at 5:12 PM, OndÅej BÃlka <neleai@seznam.cz> wrote:
>> > On Sun, Aug 09, 2015 at 11:09:20PM -0400, Mike Frysinger wrote:
>> >> On 09 Aug 2015 14:24, Zack Weinberg wrote:
>> >> > Is an IFUNC's variant-selecting function called only once per process,
>> >> > or every time?
>> >>
>> >> it's once-per-process.  if it were every time, it'd defeat the point of the
>> >> optimization.
>> >
>> > No, its once per each shared library.
>>
>> I don't see how that can possibly be right.  Doesn't each shared
>> library provide the one true PLT entry for each function it exports?
>
> No, what you said couldn't possibly work as you would need resolver for resolver to see where these plt entries are.
>
> Its completely opposite as each library generates plt stub for each
> function it uses to save space of repeatedly setting up tables for
> different dso.
>
>> If not, how can we be obeying the C standard's rules about function
>> pointer equality?
>>
> Simple, we return null. Following causes segmentation fault.
>
> gcc -fPIC -shared x.c -o libx.so
> void foo (int x) __attribute__ ((ifunc ("resolve_foo")));
>
> int foo_impl(int x)
^^^^^^^^^^^^^^^^^^^^

This should be static.

> {
>   return 42;
> }
> int bar()
> {
>   foo(5);
>   void (*f)(int) = foo;
>   f(42);
> }
>
>
> static void (*resolve_foo (void)) (void)
> {
>  // printf("ifunc\n");
>   return foo_impl; // we'll just always select this routine
> }

-- 
H.J.


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