[PATCH] D30699: [ELF] - Stop producing broken output for R_386_GOT32X relocation.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 7 08:51:08 PST 2017


grimar created this revision.

Previously we silently produced broken output for R_386_GOT32X relocation if
it was used to compute the address of the symbol’s global offset table entry without
base register when position-independent code is disabled.

That reproducable for example if following code compiled using GNU as 2.27:
movl ifunc at GOT, %eax

In that case GNU as produces R_386_GOT32X relocation (llvm-mc does not do that,
though it corresponds the ABI I believe).

Problem is that we always calculated this relocation as G + A - GOT (offset from end of GOT),
but for case when PIC is disabled, according to i386 ABI it should be calculated as G + A,
what should produce just an address in GOT finally.

ABI: https://github.com/hjl-tools/x86-psABI/wiki/intel386-psABI-1.1.pdf (p36, p60).


https://reviews.llvm.org/D30699

Files:
  ELF/InputSection.cpp
  ELF/Relocations.cpp
  ELF/Target.cpp
  ELF/Target.h
  test/ELF/Inputs/i386-got32x-baseless.elf
  test/ELF/got32x-i386.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30699.90863.patch
Type: text/x-patch
Size: 11545 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170307/7cb5c97d/attachment.bin>


More information about the llvm-commits mailing list