diff options
Diffstat (limited to 'lld/ELF/Thunks.h')
-rw-r--r-- | lld/ELF/Thunks.h | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/lld/ELF/Thunks.h b/lld/ELF/Thunks.h index b49f5ae393a..b937d791849 100644 --- a/lld/ELF/Thunks.h +++ b/lld/ELF/Thunks.h @@ -15,8 +15,8 @@ namespace lld { namespace elf { class SymbolBody; -template <class ELFT> class ThunkSection; -class OutputSectionBase; +template <class ELFT> class InputSection; + // Class to describe an instance of a Thunk. // A Thunk is a code-sequence inserted by the linker in between a caller and // the callee. The relocation to the callee is redirected to the Thunk, which @@ -24,35 +24,31 @@ class OutputSectionBase; // include transferring control from non-pi to pi and changing state on // targets like ARM. // -// Thunks can be created for DefinedRegular, Shared and Undefined Symbols. -// Thunks are assigned to synthetic ThunkSections +// Thunks can be created for DefinedRegular and Shared Symbols. The Thunk +// is stored in a field of the Symbol Destination. +// Thunks to be written to an InputSection are recorded by the InputSection. template <class ELFT> class Thunk { + typedef typename ELFT::uint uintX_t; + public: - Thunk(const SymbolBody &Destination); + Thunk(const SymbolBody &Destination, const InputSection<ELFT> &Owner); virtual ~Thunk(); virtual uint32_t size() const { return 0; } - virtual void writeTo(uint8_t *Buf, ThunkSection<ELFT> &IS) const {} - - // All Thunks must define at least one symbol ThunkSym so that we can - // redirect relocations to it. - virtual void addSymbols(ThunkSection<ELFT> &IS) {} - - // Some Thunks must be placed immediately before their Target as they elide - // a branch and fall through to the first Symbol in the Target. - virtual InputSection<ELFT> *getTargetInputSection() const { return nullptr; } + virtual void writeTo(uint8_t *Buf) const {} + uintX_t getVA() const; - // The alignment requirement for this Thunk, defaults to the size of the - // typical code section alignment. +protected: const SymbolBody &Destination; - SymbolBody *ThunkSym; + const InputSection<ELFT> &Owner; uint64_t Offset; - uint32_t alignment = 4; }; -// For a Relocation to symbol S create a Thunk to be added to a synthetic -// ThunkSection. At present there are implementations for ARM and Mips Thunks. -template <class ELFT> Thunk<ELFT> *addThunk(uint32_t RelocType, SymbolBody &S); +// For a Relocation to symbol S from InputSection Src, create a Thunk and +// update the fields of S and the InputSection that the Thunk body will be +// written to. At present there are implementations for ARM and Mips Thunks. +template <class ELFT> +void addThunk(uint32_t RelocType, SymbolBody &S, InputSection<ELFT> &Src); } // namespace elf } // namespace lld |