[PATCH] x86-64: Treat PC32 relocation with branch as PLT32

H.J. Lu hjl.tools@gmail.com
Thu Feb 8 15:57:00 GMT 2018


On Tue, Feb 6, 2018 at 6:55 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 02/06/2018 02:35 PM, H.J. Lu wrote:
>>
>> +/* Is the instruction before OFFSET in CONTENTS a 32bit relative
>> +   branch?  */
>> +
>> +static bfd_boolean
>> +is_32bit_relative_branch (bfd_byte *contents, bfd_vma offset)
>> +{
>> +  /* Opcode            Instruction
>> +     0xe8              call
>> +     0xe9              jump
>> +     0x0f 0x8x         conditional jump */
>> +  return ((offset > 0
>> +          && (contents [offset - 1] == 0xe8
>> +              || contents [offset - 1] == 0xe9))
>> +         || (offset > 1
>> +             && contents [offset - 2] == 0x0f
>> +             && (contents [offset - 1] & 0xf0) == 0x80));
>> +}
>
>
> How is this safe, considering that R_X86_64_PC32 is also used for jump
> tables and the like?
>

You are right.  This function should be removed.  Instead, we should generate
R_X86_64_PLT32 for 32-bit PC-relative branches:

https://groups.google.com/forum/#!topic/x86-64-abi/oJq_dXT9on8

I will check in this patch next week.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-x86-64-Generate-branch-with-PLT32-relocation.patch
Type: text/x-patch
Size: 22365 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20180208/cc352e3a/attachment.bin>


More information about the Binutils mailing list