This is the mail archive of the
mailing list for the GCC project.
Re: Relocations to use when eliding plts
- From: Rich Felker <dalias at libc dot org>
- To: Richard Henderson <rth at redhat dot com>
- Cc: "H.J. Lu" <hjl dot tools at gmail dot com>, IA32 System V Application Binary Interface <ia32-abi at googlegroups dot com>, "x86-64-abi at googlegroups dot com" <x86-64-abi at googlegroups dot com>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>, Binutils <binutils at sourceware dot org>, libc-alpha <libc-alpha at sourceware dot org>
- Date: Thu, 28 May 2015 13:59:41 -0400
- Subject: Re: Relocations to use when eliding plts
- Authentication-results: sourceware.org; auth=none
- References: <5566232B dot 4080904 at redhat dot com> <CAMe9rOq57A1ksRfn95GTzfc_dFzjPjEzuqswqC8Xu-M62g_Z2g at mail dot gmail dot com> <CAMe9rOpRHqvpJMDSyXk8XrNu04aytCDPnBB03B9A1iSTk=ZhPQ at mail dot gmail dot com> <5567345B dot 5020808 at redhat dot com>
On Thu, May 28, 2015 at 08:29:31AM -0700, Richard Henderson wrote:
> On 05/28/2015 04:27 AM, H.J. Lu wrote:
> > You get consecutive jmpq's because x86 PLT entry is used as the
> > canonical function address. If you compile main with -fno-plt -fPIE, you
> > get:
> Well, duh. If the main executable has no PLTs, they aren't used as the
> canonical function address. Surely you aren't proposing that as a solution?
Why not? Is there a way we could prevent the main program from having
PLT even when it's non-PIE? Instead of:
the compiler could generate
Then the linker would replace this with "call foo" if foo is defined
in the main program. For address loads, instead of:
mov $foo, %eax
lea foo, %eax
you would have:
mov foo@GOTABS_RELAXABLE, %eax
and the linker could likewise relax this to an immediate mov. More
elaborate arithmetic on the function address might be hard to do in an
efficient but relaxable way; however, I don't think the compiler ever
needs to do that, and if it did, there would just be a few odd cases
that still generate PLT thunks.
Am I missing something?