[lld] r296433 - Move SymbolTableSection::getOutputSection to SymbolBody::getOutputSection.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 27 20:02:42 PST 2017
Author: ruiu
Date: Mon Feb 27 22:02:42 2017
New Revision: 296433
URL: http://llvm.org/viewvc/llvm-project?rev=296433&view=rev
Log:
Move SymbolTableSection::getOutputSection to SymbolBody::getOutputSection.
That function doesn't use any member of SymbolTableSection, so I
couldn't see a reason to make it a member of that class. The function
takes a SymbolBody, so it is more natural to make it a member of
SymbolBody.
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/ELF/Symbols.cpp
lld/trunk/ELF/Symbols.h
lld/trunk/ELF/SyntheticSections.cpp
lld/trunk/ELF/SyntheticSections.h
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=296433&r1=296432&r2=296433&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Mon Feb 27 22:02:42 2017
@@ -983,7 +983,7 @@ template <class ELFT> bool LinkerScript<
template <class ELFT>
const OutputSection *LinkerScript<ELFT>::getSymbolSection(StringRef S) {
if (SymbolBody *Sym = Symtab<ELFT>::X->find(S))
- return SymbolTableSection<ELFT>::getOutputSection(Sym);
+ return Sym->getOutputSection<ELFT>();
return CurOutSec;
}
Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=296433&r1=296432&r2=296433&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Mon Feb 27 22:02:42 2017
@@ -172,6 +172,31 @@ template <class ELFT> typename ELFT::uin
return 0;
}
+template <class ELFT>
+const OutputSection *SymbolBody::getOutputSection() const {
+ if (auto *S = dyn_cast<DefinedRegular<ELFT>>(this)) {
+ if (S->Section)
+ return S->Section->template getOutputSection<ELFT>();
+ return nullptr;
+ }
+
+ if (auto *S = dyn_cast<SharedSymbol>(this)) {
+ if (S->NeedsCopy)
+ return S->Section->OutSec;
+ return nullptr;
+ }
+
+ if (isa<DefinedCommon>(this)) {
+ if (Config->DefineCommon)
+ return In<ELFT>::Common->OutSec;
+ return nullptr;
+ }
+
+ if (auto *S = dyn_cast<DefinedSynthetic>(this))
+ return S->Section;
+ return nullptr;
+}
+
// If a symbol name contains '@', the characters after that is
// a symbol version name. This function parses that.
void SymbolBody::parseSymbolVersion() {
@@ -359,6 +384,15 @@ template uint32_t SymbolBody::template g
template uint64_t SymbolBody::template getSize<ELF64LE>() const;
template uint64_t SymbolBody::template getSize<ELF64BE>() const;
+template const OutputSection *
+ SymbolBody::template getOutputSection<ELF32LE>() const;
+template const OutputSection *
+ SymbolBody::template getOutputSection<ELF32BE>() const;
+template const OutputSection *
+ SymbolBody::template getOutputSection<ELF64LE>() const;
+template const OutputSection *
+ SymbolBody::template getOutputSection<ELF64BE>() const;
+
template class elf::DefinedRegular<ELF32LE>;
template class elf::DefinedRegular<ELF32BE>;
template class elf::DefinedRegular<ELF64LE>;
Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=296433&r1=296432&r2=296433&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Mon Feb 27 22:02:42 2017
@@ -84,6 +84,7 @@ public:
template <class ELFT> typename ELFT::uint getGotPltVA() const;
template <class ELFT> typename ELFT::uint getPltVA() const;
template <class ELFT> typename ELFT::uint getSize() const;
+ template <class ELFT> const OutputSection *getOutputSection() const;
// The file from which this symbol was created.
InputFile *File = nullptr;
Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=296433&r1=296432&r2=296433&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Mon Feb 27 22:02:42 2017
@@ -1387,7 +1387,7 @@ template <class ELFT> void SymbolTableSe
ESym->st_size = Body->getSize<ELFT>();
ESym->st_value = Body->getVA<ELFT>();
- if (const OutputSection *OutSec = getOutputSection(Body)) {
+ if (const OutputSection *OutSec = Body->getOutputSection<ELFT>()) {
ESym->st_shndx = OutSec->SectionIndex;
// This piece of code should go away as it doesn't make sense,
@@ -1428,36 +1428,6 @@ template <class ELFT> void SymbolTableSe
}
template <class ELFT>
-const OutputSection *
-SymbolTableSection<ELFT>::getOutputSection(SymbolBody *Sym) {
- switch (Sym->kind()) {
- case SymbolBody::DefinedSyntheticKind:
- return cast<DefinedSynthetic>(Sym)->Section;
- case SymbolBody::DefinedRegularKind: {
- auto &D = cast<DefinedRegular<ELFT>>(*Sym);
- if (D.Section)
- return D.Section->template getOutputSection<ELFT>();
- break;
- }
- case SymbolBody::DefinedCommonKind:
- if (!Config->DefineCommon)
- return nullptr;
- return In<ELFT>::Common->OutSec;
- case SymbolBody::SharedKind: {
- auto &SS = cast<SharedSymbol>(*Sym);
- if (SS.NeedsCopy)
- return SS.Section->OutSec;
- break;
- }
- case SymbolBody::UndefinedKind:
- case SymbolBody::LazyArchiveKind:
- case SymbolBody::LazyObjectKind:
- break;
- }
- return nullptr;
-}
-
-template <class ELFT>
GnuHashTableSection<ELFT>::GnuHashTableSection()
: SyntheticSection(SHF_ALLOC, SHT_GNU_HASH, sizeof(uintX_t), ".gnu.hash") {
this->Entsize = ELFT::Is64Bits ? 0 : 4;
Modified: lld/trunk/ELF/SyntheticSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=296433&r1=296432&r2=296433&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.h (original)
+++ lld/trunk/ELF/SyntheticSections.h Mon Feb 27 22:02:42 2017
@@ -424,8 +424,6 @@ public:
ArrayRef<SymbolTableEntry> getSymbols() const { return Symbols; }
- static const OutputSection *getOutputSection(SymbolBody *Sym);
-
private:
// A vector of symbols and their string table offsets.
std::vector<SymbolTableEntry> Symbols;
More information about the llvm-commits
mailing list