[PATCH] D56920: [PPC64] Sort .toc sections accessed with small code model relocs close to the .got

Sean Fertile via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 18 09:56:14 PST 2019


sfertile created this revision.
sfertile added reviewers: ruiu, MaskRay, grimar.
Herald added subscribers: jsji, kbarton, arichardson, nemanjai, emaste.
Herald added a reviewer: espindola.

Small code model global variable access on PPC64 has a very limited range of addressing. The instructions the relocations are used on add an offset in the range  [-0x8000, 0x7FFC] to the toc pointer which points to .got +0x8000, giving an addressable range of [.got, .got + 0xFFFC].  While user code can be recompiled with medium and large code models when the binary grows too large for small code model, there are small code model relocations in the crt files and libgcc.a which are typically shipped with the distros, and the ABI dictates that linkers must allow linking of relocatable object files using different code models.

To minimze the chance of relocation overflow, any file that contains a small code model relocation should have its .toc section placed closer to the .got then any .toc from a file without small code model relocations.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D56920

Files:
  ELF/Arch/PPC64.cpp
  ELF/InputFiles.h
  ELF/Relocations.cpp
  ELF/Target.h
  ELF/Writer.cpp
  test/ELF/Inputs/ppc64-sort-small-cm-relocs-Input1.s
  test/ELF/Inputs/ppc64-sort-small-cm-relocs-Input2.s
  test/ELF/Inputs/ppc64-sort-small-cm-relocs-Input3.s
  test/ELF/Inputs/ppc64-sort-small-cm-relocs-Input4.s
  test/ELF/Inputs/ppc64-sort-small-cm-relocs-shared-defs.s
  test/ELF/ppc64-sort-small-cm-relocs.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56920.182537.patch
Type: text/x-patch
Size: 14894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190118/97806e40/attachment.bin>


More information about the llvm-commits mailing list