summaryrefslogtreecommitdiffstats
path: root/lld/ELF
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF')
-rw-r--r--lld/ELF/SymbolTable.h14
-rw-r--r--lld/ELF/Writer.cpp10
2 files changed, 10 insertions, 14 deletions
diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h
index 7c4ac815aa7..be7c32483b6 100644
--- a/lld/ELF/SymbolTable.h
+++ b/lld/ELF/SymbolTable.h
@@ -11,8 +11,7 @@
#define LLD_ELF_SYMBOL_TABLE_H
#include "InputFiles.h"
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/ADT/MapVector.h"
namespace lld {
namespace elf2 {
@@ -44,7 +43,7 @@ public:
bool shouldUseRela() const;
- const llvm::DenseMap<StringRef, Symbol *> &getSymbols() const {
+ const llvm::MapVector<StringRef, Symbol *> &getSymbols() const {
return Symtab;
}
@@ -74,7 +73,14 @@ private:
std::vector<std::unique_ptr<ArchiveFile>> ArchiveFiles;
- llvm::DenseMap<StringRef, Symbol *> Symtab;
+ // The order the global symbols are in is not defined. We can use an arbitrary
+ // order, but it has to be reproducible. That is true even when cross linking.
+ // The default hashing of StringRef produces different results on 32 and 64
+ // bit systems so we use a MapVector. That is arbitrary, deterministic but
+ // a bit inefficient.
+ // FIXME: Experiment with passing in a custom hashing or sorting the symbols
+ // once symbol resolution is finished.
+ llvm::MapVector<StringRef, Symbol *> Symtab;
llvm::BumpPtrAllocator Alloc;
// The writer needs to infer the machine type from the object files.
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 7c9e7cf7a40..460c1a2ea24 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -699,8 +699,6 @@ template <class ELFT> void SymbolTableSection<ELFT>::writeTo(uint8_t *Buf) {
}
}
- uint8_t *GlobalStart = Buf;
-
for (auto &P : Table.getSymbols()) {
StringRef Name = P.first;
Symbol *Sym = P.second;
@@ -755,14 +753,6 @@ template <class ELFT> void SymbolTableSection<ELFT>::writeTo(uint8_t *Buf) {
Buf += sizeof(Elf_Sym);
}
-
- // The order the global symbols are in is not defined. We can use an arbitrary
- // order, but it has to be reproducible. That is true even when cross linking.
- // The default hashing of StringRef produces different results on 32 and 64
- // bit systems so we sort by st_name. That is arbitrary but deterministic.
- // FIXME: Experiment with passing in a custom hashing instead.
- auto *Syms = reinterpret_cast<Elf_Sym *>(GlobalStart);
- array_pod_sort(Syms, Syms + NumVisible - NumLocals, compareSym<ELFT>);
}
template <bool Is64Bits>
OpenPOWER on IntegriCloud