[PATCH] D13565: [ELF2] Allow PPC64 to add the TOC-restore after .plt-based relocations

hfinkel@anl.gov via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 8 10:21:07 PDT 2015


hfinkel created this revision.
hfinkel added reviewers: ruiu, rafael.
hfinkel added a subscriber: llvm-commits.
hfinkel added a project: lld.

Under the PPC64 ELF ABI, functions that might call into other modules (and, thus, need to load a different TOC base value into %r2), need to restore the old value after the call. The old value is saved by the .plt code, and the caller only need to include a nop instruction after the call, which the linker will transform into a TOC restore if necessary.

In order to do this the relocation handler needs two things:

 1. It needs to know whether the call instruction it is modifying is targeting a .plt stub that will load a new TOC base value (necessitating a restore after the call).

 2. It needs to know where the buffer ends, so that it does not accidentally run off the end of the buffer when looking for the 'nop' instruction after the call.

Given these two pieces of information, we can insert the restore instruction in place of the following nop when necessary.

Test cases are needed; feedback is otherwise appreciated!


http://reviews.llvm.org/D13565

Files:
  ELF/InputSection.cpp
  ELF/InputSection.h
  ELF/Target.cpp
  ELF/Target.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13565.36874.patch
Type: text/x-patch
Size: 12901 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151008/fafab7c7/attachment.bin>


More information about the llvm-commits mailing list