This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Remove unnecessary IFUNC dispatch for __memset_chk.
- From: Alexander Monakov <amonakov at ispras dot ru>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Ondřej Bílka <neleai at seznam dot cz>, Zack Weinberg <zackw at panix dot com>, Andreas Schwab <schwab at linux-m68k dot org>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 17 Aug 2015 23:22:38 +0300 (MSK)
- Subject: Re: [PATCH] Remove unnecessary IFUNC dispatch for __memset_chk.
- Authentication-results: sourceware.org; auth=none
- References: <55C79AD8 dot 3070301 at panix dot com> <alpine dot LNX dot 2 dot 20 dot 1508171837140 dot 10765 at monopod dot intra dot ispras dot ru> <CAMe9rOqOvjFvstHnCzKs7mShAH=EiftzzdpstiW_i9ou7QMgCA at mail dot gmail dot com> <alpine dot LNX dot 2 dot 20 dot 1508171932010 dot 10765 at monopod dot intra dot ispras dot ru> <CAMe9rOprUnCei8i9X+eLoWCXA_sb5VY9m_x-3uYHpt4Cy+8YjQ at mail dot gmail dot com> <alpine dot LNX dot 2 dot 20 dot 1508171956100 dot 10765 at monopod dot intra dot ispras dot ru> <CAMe9rOr=s41ia=o1Q9bXpw0UvQ5DjW=Wk8r+teuC+05LXxoEpg at mail dot gmail dot com> <alpine dot LNX dot 2 dot 20 dot 1508172051410 dot 21925 at monopod dot intra dot ispras dot ru> <CAMe9rOqKa+U-FSw=E2oyTo_KCPZ_DS=0rFhD-bLFPGT2MVarow at mail dot gmail dot com> <alpine dot LNX dot 2 dot 20 dot 1508172102220 dot 21925 at monopod dot intra dot ispras dot ru> <CAMe9rOpuGM21oBg=00fkK=JXPP3tOwoN_NG1kxuwrX5Gx02WUA at mail dot gmail dot com> <alpine dot LNX dot 2 dot 20 dot 1508172233370 dot 21925 at monopod dot intra dot ispras dot ru> <CAMe9rOr4OaEu0zD5Rdg8uLE80J3ddRXnWYHCVf-31L_CHwhSXw at mail dot gmail dot com> <alpine dot LNX dot 2 dot 20 dot 1508172259190 dot 21925 at monopod dot intra dot ispras dot ru> <CAMe9rOpsABYWEH4YXpJ-4tCsJpX5eumX+qx+5DSfPJHgKwrJ8A at mail dot gmail dot com>
On Mon, 17 Aug 2015, H.J. Lu wrote:
> >> >> > Surely such a counter-argument applies equally to JUMP_SLOT relocations?
> >> >> > Imagine that 'extern int f(void)' in bug 13302 that you've linked turns
> >> >> > out to be an IFUNC symbol at runtime.
> >> >> >
> >> >> > extern int f(void);
> >> >> >
> >> >> > void alt1(void) { }
> >> >> > void alt2(void) { }
> >> >> >
> >> >> > static void (*resolve (void)) (void)
> >> >> > {
> >> >> > return f() ? alt1 : alt2;
> >> >> > }
> >> >> >
> >> >> > void fct(void) __attribute__ ((ifunc ("resolve")));
> >> >> >
> >> >>
> >> >> The difference here is symbol definition for GLOB_DAT is known
> >> >> only at run-time while relocations are known at link-time.
> >> >
> >> > Sorry, I just don't see what point you're trying to make here.
> >> >
> >> > Anyway. Suppose 'resolve()' is compiled with -fno-plt. Then instead of
> >> > JUMP_SLOT relocation to 'f' it'll have a GLOB_DAT relocation to 'f', correct?
> >> > What's going to happen then?
> >> >
> >>
> >> I believe it is OK since GLOB_DAT relocations are performed before
> >> IRELATIVE relocations in .rela.plt / .rel.plt section.
> >
> > OK. Now further suppose that we are
> >
> > a) calling 'fct' with -fno-plt, or
> > b) taking the address of 'fct' (as in Ondrey's original example)
> >
> > In both cases we're going to have a GLOB_DAT relocation to 'fct'.
> >
> > So we have a GLOB_DAT relocation to 'fct', which is an IFUNC symbol with
> > 'resolve' as its resolver, and the resolver invokes 'f', using a GLOB_DAT
> > relocation.
> >
> > Are you saying it's not supposed to work?
>
> They won't work because
>
> void alt1(void) { }
> void alt2(void) { }
>
> which has nothing to do with fct. They work if alt1 and alt2 are internal
> to DSO.
OK. Suppose that alt1 and alt2 are indeed internal. You're saying that it's
supposed to work. But then GLOB_DAT relocation to 'f' should be processed
prior to GLOB_DAT relocation to 'fct', correct? If you do it in the opposite
order, the resolver will not be able to invoke 'f'.
However as observed earlier, BFD ld does not sort relocations that way.
Thanks.
Alexander