[PATCH] D30699: [ELF] - Stop producing broken output for R_386_GOT32X relocation.
H.J. Lu via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 30 14:24:20 PDT 2017
On Thu, Mar 30, 2017 at 1:49 PM, Rafael EspĂndola
<rafael.espindola at gmail.com> wrote:
>> "name at GOT" is a memory operand. It is usually computed as "G + A" to
>> get the GOT address. If it is computed as G + A - GOT,
>>
>> op name at GOT, %reg
>>
>> will lead to random result since G + A - GOT is the GOT index, not address.
>> LEA is an exception, relocation in
>
> I can't reproduce this behavior with gnu tools.
>
> Given non-pic.s with just
>
> mov _start at GOT, %eax
>
> gas will produce a R_386_GOT32X even with --mrelax-relocations=no, so
> I used llvm-mc instead to get a R_386_GOT32.
>
> Then linking as
>
> ld.bfd -m elf_i386 start.o non-pic.o -o non-pic
>
> will produce
>
> 08048094 <_start>:
> 8048094: a1 fc ff ff ff mov 0xfffffffc,%eax
>
> So looks like it is computing G + A - GOT.
>
Relocate
mov _start at GOT, %eax
as G + A - GOT leads to random results. Since compiler never generates
such sequence before, it never caused the real problem. The updated
i386 psABI changes it to G + A so that it can be used to access GOT
without base register when PIC is off. Ld in binutils 2.28 generates:
08048074 <_start>:
8048074: c7 c0 74 80 04 08 mov $0x8048074,%eax
as the GOT entry for _start contains the address of _start.
--
H.J.
More information about the llvm-commits
mailing list