[PATCH] D17934: [ELF] Implement infrastructure for thunk code creation

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 7 08:44:57 PST 2016


atanasyan created this revision.
atanasyan added reviewers: ruiu, rafael.
atanasyan added a subscriber: llvm-commits.
atanasyan set the repository for this revision to rL LLVM.
atanasyan added a project: lld.

Some targets might require creation of thunks. For example, MIPS targets require stubs to call PIC code from non-PIC one. The patch implements infrastructure for thunk code creation and provides support for MIPS LA25 stubs.

While relocation scanning phase we ask target about thunk code creation by calling `TagetInfo::needsThunk` method. All symbols require thunk creation are saved in the `OutputSection::Thunks` container by calling `OutputSection::addThunk` method. In the `OutputSection::writeTo` method we ask target to write thunk code at the end of the output section by calling `TargetInfo::writeThunk` method.

The patch supports the only type of thunk code for each target. For now, it is enough.

Any MIPS PIC code function is invoked with its address in register $t9. So if we have a branch instruction from non-PIC code to the PIC one we cannot make the jump directly and need to create a small stub to save the target function address. See page 3-38 ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf

Repository:
  rL LLVM

http://reviews.llvm.org/D17934

Files:
  ELF/InputSection.cpp
  ELF/OutputSections.cpp
  ELF/OutputSections.h
  ELF/Symbols.cpp
  ELF/Symbols.h
  ELF/Target.cpp
  ELF/Target.h
  ELF/Writer.cpp
  test/ELF/Inputs/mips-pic.s
  test/ELF/mips-npic-call-pic.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17934.49968.patch
Type: text/x-patch
Size: 14555 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160307/e4a01981/attachment-0001.bin>


More information about the llvm-commits mailing list