[PATCH] D34355: [LLD][ELF] Define _GLOBAL_OFFSET_TABLE_ to base of .got for ARM

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 21 08:27:13 PDT 2017


peter.smith updated this revision to Diff 103381.
peter.smith added a comment.
Herald added a subscriber: nemanjai.

I've updated the patch to support the general case of _GLOBAL_OFFSET_TABLE_ across the supported architectures.

Based on binutils the x86 and x86_64 architectures traditionally have the _GLOBAL_OFFSET_TABLE_ set to the base of the .got.plt which by default in gold and bfd puts .got immediately before .got.plt. In lld .got may be separate to .got.plt so I've used the end of .got in the same way as the _FROM_END relocations in x86 and x86_64. All other architectures use the base of the .got. Of the supported architectures only ARM and X86 seem to make a lot of use of _GLOBAL_OFFSET_TABLE_.
In addition:

- Defining _GLOBAL_OFFSET_TABLE_ as a symbol reveals that R_GOTONLY_PC is missing from isRelExprOneOf in isStaticLinkTimeConstant
- _GLOBAL_OFFSET_TABLE_ can't be used absolutely in tests with --shared (this is the same with gold and bfd)
- I've added tests for all the architectures that use _GLOBAL_OFFSET_TABLE_

I've not added a test for PPC32 as I don't think the port is complete enough for GOT generation anyway. PPC64 uses .TOC. instead of _GLOBAL_OFFSET_TABLE_.

Although I've not done so in this patch, adding the target specific GotBaseSymOff would allow us to merge the RelExpr GOT_ONLYPC and GOT_ONLYPC_FROM_END and the other _FROM_END relocations.

This should make lld able to handle older objects including those from the current version of clang better. If this is not considered worthwhile let me know and I'll abandon the revision.


https://reviews.llvm.org/D34355

Files:
  ELF/Arch/PPC.cpp
  ELF/Arch/X86.cpp
  ELF/Arch/X86_64.cpp
  ELF/Relocations.cpp
  ELF/Target.h
  ELF/Writer.cpp
  test/ELF/arm-got-relative.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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34355.103381.patch
Type: text/x-patch
Size: 12082 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170621/ac2b5246/attachment.bin>


More information about the llvm-commits mailing list