diff options
-rw-r--r-- | lld/ELF/InputSection.cpp | 13 | ||||
-rw-r--r-- | lld/ELF/InputSection.h | 4 | ||||
-rw-r--r-- | lld/ELF/LinkerScript.h | 2 | ||||
-rw-r--r-- | lld/ELF/SymbolTable.cpp | 16 | ||||
-rw-r--r-- | lld/ELF/Symbols.cpp | 15 | ||||
-rw-r--r-- | lld/ELF/Symbols.h | 11 | ||||
-rw-r--r-- | lld/ELF/Writer.cpp | 7 |
7 files changed, 28 insertions, 40 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index a6990443919..774d3f0f2dd 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -698,8 +698,7 @@ bool MipsAbiFlagsInputSection<ELFT>::classof(const InputSectionBase<ELFT> *S) { } template <class ELFT> -CommonInputSection<ELFT>::CommonInputSection( - std::vector<DefinedCommon<ELFT> *> Syms) +CommonInputSection<ELFT>::CommonInputSection(std::vector<DefinedCommon *> Syms) : InputSection<ELFT>(nullptr, &Hdr) { Hdr.sh_size = 0; Hdr.sh_type = SHT_NOBITS; @@ -707,12 +706,12 @@ CommonInputSection<ELFT>::CommonInputSection( this->Live = true; // Sort the common symbols by alignment as an heuristic to pack them better. - std::stable_sort(Syms.begin(), Syms.end(), [](const DefinedCommon<ELFT> *A, - const DefinedCommon<ELFT> *B) { - return A->Alignment > B->Alignment; - }); + std::stable_sort(Syms.begin(), Syms.end(), + [](const DefinedCommon *A, const DefinedCommon *B) { + return A->Alignment > B->Alignment; + }); - for (DefinedCommon<ELFT> *Sym : Syms) { + for (DefinedCommon *Sym : Syms) { this->Alignment = std::max<uintX_t>(this->Alignment, Sym->Alignment); Hdr.sh_size = alignTo(Hdr.sh_size, Sym->Alignment); diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index 28c621b1609..a12b5919b6e 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -21,11 +21,11 @@ namespace lld { namespace elf { +class DefinedCommon; class SymbolBody; template <class ELFT> class ICF; template <class ELFT> class DefinedRegular; -template <class ELFT> class DefinedCommon; template <class ELFT> class ObjectFile; template <class ELFT> class OutputSection; template <class ELFT> class OutputSectionBase; @@ -287,7 +287,7 @@ template <class ELFT> class CommonInputSection : public InputSection<ELFT> { typedef typename ELFT::uint uintX_t; public: - CommonInputSection(std::vector<DefinedCommon<ELFT> *> Syms); + CommonInputSection(std::vector<DefinedCommon *> Syms); // The singleton instance of this class. static CommonInputSection<ELFT> *X; diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index b31616c9c26..f08bd0762b5 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -20,12 +20,12 @@ namespace lld { namespace elf { +class DefinedCommon; class ScriptParser; class SymbolBody; template <class ELFT> class InputSectionBase; template <class ELFT> class OutputSectionBase; template <class ELFT> class OutputSectionFactory; -template <class ELFT> class DefinedCommon; template <class ELFT> class LayoutInputSection; typedef std::function<uint64_t(uint64_t)> Expr; diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index 0aacb04aa95..e99e5077d7e 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -326,7 +326,6 @@ static int compareDefined(Symbol *S, bool WasInserted, uint8_t Binding) { // We have a new non-common defined symbol with the specified binding. Return 1 // if the new symbol should win, -1 if the new symbol should lose, or 0 if there // is a conflict. If the new symbol wins, also update the binding. -template <class ELFT> static int compareDefinedNonCommon(Symbol *S, bool WasInserted, uint8_t Binding) { if (int Cmp = compareDefined(S, WasInserted, Binding)) { @@ -334,7 +333,7 @@ static int compareDefinedNonCommon(Symbol *S, bool WasInserted, S->Binding = Binding; return Cmp; } - if (isa<DefinedCommon<ELFT>>(S->body())) { + if (isa<DefinedCommon>(S->body())) { // Non-common symbols take precedence over common symbols. if (Config->WarnCommon) warning("common " + S->body()->getName() + " is overridden"); @@ -356,10 +355,9 @@ Symbol *SymbolTable<ELFT>::addCommon(StringRef N, uint64_t Size, int Cmp = compareDefined(S, WasInserted, Binding); if (Cmp > 0) { S->Binding = Binding; - replaceBody<DefinedCommon<ELFT>>(S, N, Size, Alignment, StOther, Type, - File); + replaceBody<DefinedCommon>(S, N, Size, Alignment, StOther, Type, File); } else if (Cmp == 0) { - auto *C = dyn_cast<DefinedCommon<ELFT>>(S->body()); + auto *C = dyn_cast<DefinedCommon>(S->body()); if (!C) { // Non-common symbols take precedence over common symbols. if (Config->WarnCommon) @@ -395,7 +393,7 @@ Symbol *SymbolTable<ELFT>::addRegular(StringRef Name, const Elf_Sym &Sym, Name, Sym.getType(), Sym.getVisibility(), /*CanOmitFromDynSym*/ false, /*HasUnnamedAddr*/ false, /*IsUsedInRegularObj*/ true, Section ? Section->getFile() : nullptr); - int Cmp = compareDefinedNonCommon<ELFT>(S, WasInserted, Sym.getBinding()); + int Cmp = compareDefinedNonCommon(S, WasInserted, Sym.getBinding()); if (Cmp > 0) replaceBody<DefinedRegular<ELFT>>(S, Name, Sym, Section); else if (Cmp == 0) @@ -411,7 +409,7 @@ Symbol *SymbolTable<ELFT>::addRegular(StringRef Name, uint8_t Binding, std::tie(S, WasInserted) = insert(Name, STT_NOTYPE, StOther & 3, /*CanOmitFromDynSym*/ false, /*HasUnnamedAddr*/ false, /*IsUsedInRegularObj*/ true, nullptr); - int Cmp = compareDefinedNonCommon<ELFT>(S, WasInserted, Binding); + int Cmp = compareDefinedNonCommon(S, WasInserted, Binding); if (Cmp > 0) replaceBody<DefinedRegular<ELFT>>(S, Name, StOther); else if (Cmp == 0) @@ -429,7 +427,7 @@ Symbol *SymbolTable<ELFT>::addSynthetic(StringRef N, /*CanOmitFromDynSym*/ false, /*HasUnnamedAddr*/ false, /*IsUsedInRegularObj*/ true, nullptr); - int Cmp = compareDefinedNonCommon<ELFT>(S, WasInserted, STB_GLOBAL); + int Cmp = compareDefinedNonCommon(S, WasInserted, STB_GLOBAL); if (Cmp > 0) replaceBody<DefinedSynthetic<ELFT>>(S, N, Value, Section); else if (Cmp == 0) @@ -469,7 +467,7 @@ Symbol *SymbolTable<ELFT>::addBitcode(StringRef Name, uint8_t Binding, std::tie(S, WasInserted) = insert(Name, Type, StOther & 3, CanOmitFromDynSym, HasUnnamedAddr, /*IsUsedInRegularObj*/ false, F); - int Cmp = compareDefinedNonCommon<ELFT>(S, WasInserted, Binding); + int Cmp = compareDefinedNonCommon(S, WasInserted, Binding); if (Cmp > 0) replaceBody<DefinedRegular<ELFT>>(S, Name, StOther, Type, F); else if (Cmp == 0) diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp index 7699cb2b520..88d3620613f 100644 --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -66,7 +66,7 @@ static typename ELFT::uint getSymVA(const SymbolBody &Body, case SymbolBody::DefinedCommonKind: return CommonInputSection<ELFT>::X->OutSec->getVA() + CommonInputSection<ELFT>::X->OutSecOff + - cast<DefinedCommon<ELFT>>(Body).Offset; + cast<DefinedCommon>(Body).Offset; case SymbolBody::SharedKind: { auto &SS = cast<SharedSymbol<ELFT>>(Body); if (!SS.NeedsCopyOrPltAddr) @@ -175,7 +175,7 @@ template <class ELFT> typename ELFT::uint SymbolBody::getThunkVA() const { } template <class ELFT> typename ELFT::uint SymbolBody::getSize() const { - if (const auto *C = dyn_cast<DefinedCommon<ELFT>>(this)) + if (const auto *C = dyn_cast<DefinedCommon>(this)) return C->Size; if (const auto *DR = dyn_cast<DefinedRegular<ELFT>>(this)) return DR->Size; @@ -208,10 +208,8 @@ DefinedSynthetic<ELFT>::DefinedSynthetic(StringRef N, uintX_t Value, : Defined(SymbolBody::DefinedSyntheticKind, N, STV_HIDDEN, 0 /* Type */), Value(Value), Section(Section) {} -template <class ELFT> -DefinedCommon<ELFT>::DefinedCommon(StringRef N, uint64_t Size, - uint64_t Alignment, uint8_t StOther, - uint8_t Type, InputFile *File) +DefinedCommon::DefinedCommon(StringRef N, uint64_t Size, uint64_t Alignment, + uint8_t StOther, uint8_t Type, InputFile *File) : Defined(SymbolBody::DefinedCommonKind, N, StOther, Type), Alignment(Alignment), Size(Size) { this->File = File; @@ -321,8 +319,3 @@ template class elf::DefinedSynthetic<ELF32LE>; template class elf::DefinedSynthetic<ELF32BE>; template class elf::DefinedSynthetic<ELF64LE>; template class elf::DefinedSynthetic<ELF64BE>; - -template class elf::DefinedCommon<ELF32LE>; -template class elf::DefinedCommon<ELF32BE>; -template class elf::DefinedCommon<ELF64LE>; -template class elf::DefinedCommon<ELF64BE>; diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h index abbfa26cc13..0526865a00c 100644 --- a/lld/ELF/Symbols.h +++ b/lld/ELF/Symbols.h @@ -158,7 +158,7 @@ public: static bool classof(const SymbolBody *S) { return S->isDefined(); } }; -template <class ELFT> class DefinedCommon : public Defined { +class DefinedCommon : public Defined { public: DefinedCommon(StringRef N, uint64_t Size, uint64_t Alignment, uint8_t StOther, uint8_t Type, InputFile *File); @@ -436,11 +436,10 @@ struct Symbol { // large and aligned enough to store any derived class of SymbolBody. We // assume that the size and alignment of ELF64LE symbols is sufficient for any // ELFT, and we verify this with the static_asserts in replaceBody. - llvm::AlignedCharArrayUnion<DefinedCommon<llvm::object::ELF64LE>, - DefinedRegular<llvm::object::ELF64LE>, - DefinedSynthetic<llvm::object::ELF64LE>, - Undefined, SharedSymbol<llvm::object::ELF64LE>, - LazyArchive, LazyObject> + llvm::AlignedCharArrayUnion< + DefinedCommon, DefinedRegular<llvm::object::ELF64LE>, + DefinedSynthetic<llvm::object::ELF64LE>, Undefined, + SharedSymbol<llvm::object::ELF64LE>, LazyArchive, LazyObject> Body; SymbolBody *body() { return reinterpret_cast<SymbolBody *>(Body.buffer); } diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 11c15a3990f..a3c59d45261 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -229,11 +229,10 @@ template <class ELFT> void elf::writeResult() { Out<ELFT>::Pool.clear(); } -template <class ELFT> -static std::vector<DefinedCommon<ELFT> *> getCommonSymbols() { - std::vector<DefinedCommon<ELFT> *> V; +template <class ELFT> static std::vector<DefinedCommon *> getCommonSymbols() { + std::vector<DefinedCommon *> V; for (Symbol *S : Symtab<ELFT>::X->getSymbols()) - if (auto *B = dyn_cast<DefinedCommon<ELFT>>(S->body())) + if (auto *B = dyn_cast<DefinedCommon>(S->body())) V.push_back(B); return V; } |