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: [x86-64-psABI] RFC: Add R_X86_64_RELAX_PC32 and R_X86_64_RELAX_PLT32


On Tue, May 12, 2015 at 11:42 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, May 11, 2015 at 8:52 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>
>> I will clarify in the spec language.  Yes, that is the intention for both
>> R_X86_64_RELAX_PC32 and R_X86_64_RELAX_PLT32.  That is what
>> is implemented on users/hjl/relax branch.
>>
>
> Here is the updated proposal.  I changed nop prefix from 0x48
> to 0x67 and clarified how foo@GOTPCREL(%rip) should be
> resolved.
>

Another update.  I replaced R_X86_64_RELAX_PLT32 with
R_X86_64_RELAX_GOTPCREL so that I can apply the
same relaxation to i386.


H.J.
----
To remove one direct branch to PLT for external function calls:

https://gcc.gnu.org/ml/gcc-patches/2015-05/msg00001.html

I am proposing to add 2 new relocations, R_X86_64_RELAX_PC32 and
R_X86_64_RELAX_GOTPCREL:

1. R_X86_64_RELAX_PC32 can only be used on 32-bit direct call/jmp
instructions with a relax prefix, 0x67, which is the address size
prefix and is ignored by 32-bit direct call/jmp instructions in both
32-bit and 64-bit modes.
2. Compiler may generate
   a.
call/jmp *foo@GOTRELAX(%rip)
   which generates R_X86_64_RELAX_GOTPCREL relocaton, instead of
call/jmp foo@PLT
   when branching to an external function, foo, in PIC mode.
   b.
relax call/jmp foo
   which generates R_X86_64_RELAX_PC32 relocaton, instead of
call/jmp foo
   when branching to an external function, foo, in non-PIC mode.
3. Linker may treat them as R_X86_64_PC32 and R_X86_64_GOTPCREL
respectively.
4. Optionally,
   a. For
0x67 call/jmp foo
   linker may convert it to
call/jmp *foo@GOTRELAX(%rip)
   when function foo is externally defined.
   b. For
call/jmp *foo@GOTRELAX(%rip)
   linker may convert it to
0x67 call/jmp foo
   when function foo is locally defined.
   This relaxation effectively turns off lazy binding on function, foo.

R_X86_64_RELAX_PC32 is defined as 39, which was the deprecated
R_X86_64_PC32_BND for

bnd call/jmp  foo

R_X86_64_RELAX_GOTPCREL is defined as 41.  Since the current linkers treat
R_X86_64_PC32_BND as R_X86_64_PC32, they can handle R_X86_64_RELAX_PC32,
correctly, but not R_X86_64_RELAX_GOTPCREL.


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