This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [x86-64-psABI] RFC: Add R_X86_64_RELAX_PC32 and R_X86_64_RELAX_PLT32
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Michael Matz <matz at suse dot de>
- Cc: "x86-64-abi at googlegroups dot com" <x86-64-abi at googlegroups dot com>, GCC Development <gcc at gcc dot gnu dot org>
- Date: Sun, 17 May 2015 08:16:21 -0700
- Subject: Re: [x86-64-psABI] RFC: Add R_X86_64_RELAX_PC32 and R_X86_64_RELAX_PLT32
- Authentication-results: sourceware.org; auth=none
- References: <CAMe9rOp9tv1bnUPJ6s=NR7=5srs48Vqn5-L0Te9agSNSUTyrkw at mail dot gmail dot com> <alpine dot LSU dot 2 dot 20 dot 1505111744400 dot 4883 at wotan dot suse dot de> <CAMe9rOqcLsgDsqFU5mOnA6fQ+wRsNwCpJLiRYDKS1mhcdqfyoA at mail dot gmail dot com> <CAMe9rOokKUoQ=W+oKmFfCHiAeTCAqtYAykOdq2muR+qe-Og6vQ at mail dot gmail dot com>
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.