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, 10 Aug 2015, 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.

I see that OndÅej already replied to you, but since I found his response hard
to follow (even being familiar with the topic), I'll try to explain in my own
words.

> Doesn't each shared
> library provide the one true PLT entry for each function it exports?

No, shared libraries have PLT entries for functions they "import".  Also, the
main (non-PIE) executable will have simpler PLT entries for functions it
calls, and when it does, the address of the PLT entry in the main executable
becomes the canonical address for the function.

> If not, how can we be obeying the C standard's rules about function
> pointer equality?

If the main executable does not have the PLT slot that would be the canonical
address, then with an IFUNC resolver that returns different addresses at
different invocations, you can get to a situation when functions with the same
name can be seen from different DSOs as having different addresses.  If
there's interest I'll send a testcase.  But overall it simply demonstrates
that if you do an unusual thing in the resolver, you get an unusual result.
There's no specification on what resolvers can and cannot do.

Hope that helps.
Alexander

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