[PATCH] D44259: [LLD][ELF] Use start of .got.plt as the location for _GLOBAL_OFFSET_TABLE_

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 8 10:07:32 PST 2018


peter.smith created this revision.
peter.smith added reviewers: ruiu, rafael, atanasyan.
Herald added subscribers: kbarton, kristof.beyls, arichardson, javed.absar, nemanjai, sdardis, emaste.

For most Targets the _GLOBAL_OFFSET_TABLE_ symbol is expected to be at the start of the .got.plt section so that _GLOBAL_OFFSET_TABLE_[0] = reserved value that is by convention the address of the dynamic section. Previously we had defined _GLOBAL_OFFSET_TABLE_ as either the start or end of the .got section with the intention that the .got.plt section would follow the .got. However this does not always hold with the current default section ordering so _GLOBAL_OFFSET_TABLE_[0] may not be consistent with the reserved first entry of the .got.plt.

In the patch, for X86, X86_64, Mips, Arm and AArch64 I've altered the location of the _GLOBAL_OFFSET_TABLE_ to be the start of the .got.plt section. For Power I've kept it as the ABI defined .got + 0x8000. For all except AArch64 this is consistent with Gold and BFD. They have chosen to use the start of the .got section for _GLOBAL_OFFSET_TABLE_, but I don't know of any software that depends on this, for example glibc/dl-machine.h reserves the same number of entries in the .got.plt as other targets and never directly accesses .got.plt[0] to use it for some other purpose.

Majority of the changes are to the tests as we now have to generate a .got.plt section if the _GLOBAL_OFFSET_TABLE_ symbol is defined rather than the .got.

fixes PR36555 (https://bugs.llvm.org/show_bug.cgi?id=36555)

Fixes PR36555.


https://reviews.llvm.org/D44259

Files:
  ELF/Arch/PPC.cpp
  ELF/Arch/X86.cpp
  ELF/Arch/X86_64.cpp
  ELF/SyntheticSections.cpp
  ELF/SyntheticSections.h
  ELF/Target.h
  ELF/Writer.cpp
  test/ELF/arm-got-relative.s
  test/ELF/dynamic-got.s
  test/ELF/global-offset-table-position-aarch64.s
  test/ELF/global-offset-table-position-arm.s
  test/ELF/global-offset-table-position-i386.s
  test/ELF/global-offset-table-position-mips.s
  test/ELF/global-offset-table-position.s
  test/ELF/global_offset_table_shared.s
  test/ELF/got32x-i386.s
  test/ELF/i386-gotpc.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44259.137597.patch
Type: text/x-patch
Size: 14193 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180308/ae81420b/attachment.bin>


More information about the llvm-commits mailing list