summaryrefslogtreecommitdiff
path: root/lld/ELF/SymbolTable.h
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2017-10-31 16:07:41 +0000
committerRui Ueyama <ruiu@google.com>2017-10-31 16:07:41 +0000
commit74a7720a23d8e63dfa11b5196453ba6ae428e526 (patch)
tree872cd90e1a859e7f3eadda0f130376ed03054014 /lld/ELF/SymbolTable.h
parent29096e290a4bc3b7d1bc6fe0c71de8ddb14106df (diff)
Merge SymbolBody and Symbol into one class, SymbolBody.
SymbolBody and Symbol were separated classes due to a historical reason. Symbol used to be a pointer to a SymbolBody, and the relationship between Symbol and SymbolBody was n:1. r2681780 changed that. Since that patch, SymbolBody and Symbol are allocated next to each other to improve memory locality, and they have 1:1 relationship now. So, the separation of Symbol and SymbolBody no longer makes sense. This patch merges them into one class. In order to avoid updating too many places, I chose SymbolBody as a unified name. I'll rename it Symbol in a follow-up patch. Differential Revision: https://reviews.llvm.org/D39406
Diffstat (limited to 'lld/ELF/SymbolTable.h')
-rw-r--r--lld/ELF/SymbolTable.h51
1 files changed, 25 insertions, 26 deletions
diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h
index e2acc4796da..ee48f7015c3 100644
--- a/lld/ELF/SymbolTable.h
+++ b/lld/ELF/SymbolTable.h
@@ -19,8 +19,6 @@
namespace lld {
namespace elf {
-struct Symbol;
-
// SymbolTable is a bucket of all known symbols, including defined,
// undefined, or lazy symbols (the last one is symbols in archive
// files whose archive members are not yet loaded).
@@ -41,22 +39,22 @@ public:
template <class ELFT> void addSymbolWrap(StringRef Name);
void applySymbolRenames();
- ArrayRef<Symbol *> getSymbols() const { return SymVector; }
+ ArrayRef<SymbolBody *> getSymbols() const { return SymVector; }
template <class ELFT>
DefinedRegular *addAbsolute(StringRef Name,
uint8_t Visibility = llvm::ELF::STV_HIDDEN,
uint8_t Binding = llvm::ELF::STB_GLOBAL);
- template <class ELFT> Symbol *addUndefined(StringRef Name);
+ template <class ELFT> SymbolBody *addUndefined(StringRef Name);
template <class ELFT>
- Symbol *addUndefined(StringRef Name, bool IsLocal, uint8_t Binding,
- uint8_t StOther, uint8_t Type, bool CanOmitFromDynSym,
- InputFile *File);
+ SymbolBody *addUndefined(StringRef Name, bool IsLocal, uint8_t Binding,
+ uint8_t StOther, uint8_t Type,
+ bool CanOmitFromDynSym, InputFile *File);
template <class ELFT>
- Symbol *addRegular(StringRef Name, uint8_t StOther, uint8_t Type,
- uint64_t Value, uint64_t Size, uint8_t Binding,
- SectionBase *Section, InputFile *File);
+ SymbolBody *addRegular(StringRef Name, uint8_t StOther, uint8_t Type,
+ uint64_t Value, uint64_t Size, uint8_t Binding,
+ SectionBase *Section, InputFile *File);
template <class ELFT>
void addShared(StringRef Name, SharedFile<ELFT> *F,
@@ -64,22 +62,23 @@ public:
const typename ELFT::Verdef *Verdef);
template <class ELFT>
- Symbol *addLazyArchive(StringRef Name, ArchiveFile *F,
- const llvm::object::Archive::Symbol S);
+ SymbolBody *addLazyArchive(StringRef Name, ArchiveFile *F,
+ const llvm::object::Archive::Symbol S);
template <class ELFT> void addLazyObject(StringRef Name, LazyObjFile &Obj);
- Symbol *addBitcode(StringRef Name, uint8_t Binding, uint8_t StOther,
- uint8_t Type, bool CanOmitFromDynSym, BitcodeFile *File);
+ SymbolBody *addBitcode(StringRef Name, uint8_t Binding, uint8_t StOther,
+ uint8_t Type, bool CanOmitFromDynSym,
+ BitcodeFile *File);
- Symbol *addCommon(StringRef Name, uint64_t Size, uint32_t Alignment,
- uint8_t Binding, uint8_t StOther, uint8_t Type,
- InputFile *File);
+ SymbolBody *addCommon(StringRef Name, uint64_t Size, uint32_t Alignment,
+ uint8_t Binding, uint8_t StOther, uint8_t Type,
+ InputFile *File);
- std::pair<Symbol *, bool> insert(StringRef Name);
- std::pair<Symbol *, bool> insert(StringRef Name, uint8_t Type,
- uint8_t Visibility, bool CanOmitFromDynSym,
- InputFile *File);
+ std::pair<SymbolBody *, bool> insert(StringRef Name);
+ std::pair<SymbolBody *, bool> insert(StringRef Name, uint8_t Type,
+ uint8_t Visibility,
+ bool CanOmitFromDynSym, InputFile *File);
template <class ELFT> void fetchIfLazy(StringRef Name);
template <class ELFT> void scanShlibUndefined();
@@ -94,7 +93,7 @@ public:
private:
std::vector<SymbolBody *> findByVersion(SymbolVersion Ver);
std::vector<SymbolBody *> findAllByVersion(SymbolVersion Ver);
- void defsym(Symbol *Dst, Symbol *Src);
+ void defsym(SymbolBody *Dst, SymbolBody *Src);
llvm::StringMap<std::vector<SymbolBody *>> &getDemangledSyms();
void handleAnonymousVersion();
@@ -116,7 +115,7 @@ private:
// FIXME: Experiment with passing in a custom hashing or sorting the symbols
// once symbol resolution is finished.
llvm::DenseMap<llvm::CachedHashStringRef, SymIndex> Symtab;
- std::vector<Symbol *> SymVector;
+ std::vector<SymbolBody *> SymVector;
// Comdat groups define "link once" sections. If two comdat groups have the
// same name, only one of them is linked, and the other is ignored. This set
@@ -133,8 +132,8 @@ private:
llvm::Optional<llvm::StringMap<std::vector<SymbolBody *>>> DemangledSyms;
struct SymbolRenaming {
- Symbol *Dst;
- Symbol *Src;
+ SymbolBody *Dst;
+ SymbolBody *Src;
uint8_t Binding;
};
@@ -142,7 +141,7 @@ private:
std::vector<SymbolRenaming> Defsyms;
// For -wrap.
- std::vector<std::pair<Symbol *, Symbol *>> WrapSymbols;
+ std::vector<std::pair<SymbolBody *, SymbolBody *>> WrapSymbols;
// For LTO.
std::unique_ptr<BitcodeCompiler> LTO;