diff options
Diffstat (limited to 'lld/ELF/SyntheticSections.h')
| -rw-r--r-- | lld/ELF/SyntheticSections.h | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h index f420f9bf460..0a3774e61f9 100644 --- a/lld/ELF/SyntheticSections.h +++ b/lld/ELF/SyntheticSections.h @@ -147,13 +147,39 @@ public: size_t getSize() const override { return Size; } void finalize() override; void addEntry(SymbolBody &Sym); - void addMipsEntry(SymbolBody &Sym, uintX_t Addend, RelExpr Expr); + bool addDynTlsEntry(SymbolBody &Sym); + bool addTlsIndex(); + bool empty() const { return Entries.empty(); } + uintX_t getGlobalDynAddr(const SymbolBody &B) const; + uintX_t getGlobalDynOffset(const SymbolBody &B) const; + + uintX_t getTlsIndexVA() { return this->getVA() + TlsIndexOff; } + uint32_t getTlsIndexOff() const { return TlsIndexOff; } + + // Flag to force GOT to be in output if we have relocations + // that relies on its address. + bool HasGotOffRel = false; + +private: + std::vector<const SymbolBody *> Entries; + uint32_t TlsIndexOff = -1; + uintX_t Size = 0; +}; + +template <class ELFT> class MipsGotSection final : public SyntheticSection<ELFT> { + typedef typename ELFT::uint uintX_t; + +public: + MipsGotSection(); + void writeTo(uint8_t *Buf) override; + size_t getSize() const override { return Size; } + void finalize() override; + void addEntry(SymbolBody &Sym, uintX_t Addend, RelExpr Expr); bool addDynTlsEntry(SymbolBody &Sym); bool addTlsIndex(); bool empty() const { return MipsPageEntries == 0 && Entries.empty(); } uintX_t getMipsLocalPageOffset(uintX_t Addr); uintX_t getMipsGotOffset(const SymbolBody &B, uintX_t Addend) const; - uintX_t getGlobalDynAddr(const SymbolBody &B) const; uintX_t getGlobalDynOffset(const SymbolBody &B) const; // Returns the symbol which corresponds to the first entry of the global part @@ -170,13 +196,8 @@ public: // after 'local' and 'global' entries. uintX_t getMipsTlsOffset() const; - uintX_t getTlsIndexVA() { return this->getVA() + TlsIndexOff; } uint32_t getTlsIndexOff() const { return TlsIndexOff; } - // Flag to force GOT to be in output if we have relocations - // that relies on its address. - bool HasGotOffRel = false; - private: std::vector<const SymbolBody *> Entries; uint32_t TlsIndexOff = -1; @@ -199,9 +220,6 @@ private: MipsGotEntries MipsLocal; MipsGotEntries MipsLocal32; MipsGotEntries MipsGlobal; - - // Write MIPS-specific parts of the GOT. - void writeMipsGot(uint8_t *Buf); }; template <class ELFT> @@ -353,6 +371,7 @@ template <class ELFT> struct In { static DynamicSection<ELFT> *Dynamic; static StringTableSection<ELFT> *DynStrTab; static GotSection<ELFT> *Got; + static MipsGotSection<ELFT> *MipsGot; static GotPltSection<ELFT> *GotPlt; static InputSection<ELFT> *Interp; static MipsAbiFlagsSection<ELFT> *MipsAbiFlags; @@ -369,6 +388,7 @@ template <class ELFT> InputSection<ELFT> *In<ELFT>::Common; template <class ELFT> DynamicSection<ELFT> *In<ELFT>::Dynamic; template <class ELFT> StringTableSection<ELFT> *In<ELFT>::DynStrTab; template <class ELFT> GotSection<ELFT> *In<ELFT>::Got; +template <class ELFT> MipsGotSection<ELFT> *In<ELFT>::MipsGot; template <class ELFT> GotPltSection<ELFT> *In<ELFT>::GotPlt; template <class ELFT> InputSection<ELFT> *In<ELFT>::Interp; template <class ELFT> MipsAbiFlagsSection<ELFT> *In<ELFT>::MipsAbiFlags; |

