This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: Relocations to use when eliding plts


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:

	call foo

the compiler could generate

	call *foo@GOTABS_RELAXABLE

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

or:

	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?

Rich


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