summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/lib/ReaderWriter/ELF/OutputELFWriter.h27
-rw-r--r--lld/test/elf/DT_NEEDED-order.test14
-rw-r--r--lld/test/elf/Inputs/use-shared.c3
-rw-r--r--lld/test/elf/Inputs/use-shared2.x86-64bin1536 -> 0 bytes
4 files changed, 6 insertions, 38 deletions
diff --git a/lld/lib/ReaderWriter/ELF/OutputELFWriter.h b/lld/lib/ReaderWriter/ELF/OutputELFWriter.h
index 8f116c8f1be..1d734808a30 100644
--- a/lld/lib/ReaderWriter/ELF/OutputELFWriter.h
+++ b/lld/lib/ReaderWriter/ELF/OutputELFWriter.h
@@ -18,7 +18,7 @@
#include "lld/ReaderWriter/ELFLinkingContext.h"
#include "lld/ReaderWriter/Writer.h"
-#include <unordered_set>
+#include "llvm/ADT/StringSet.h"
namespace lld {
namespace elf {
@@ -129,6 +129,7 @@ protected:
LLD_UNIQUE_BUMP_PTR(DynamicSymbolTable<ELFT>) _dynamicSymbolTable;
LLD_UNIQUE_BUMP_PTR(StringTable<ELFT>) _dynamicStringTable;
LLD_UNIQUE_BUMP_PTR(HashSection<ELFT>) _hashTable;
+ llvm::StringSet<> _soNeeded;
/// @}
};
@@ -164,12 +165,6 @@ void OutputELFWriter<ELFT>::buildStaticSymbolTable(const File &file) {
_symtab->addSymbol(a, ELF::SHN_UNDEF);
}
-struct StringRefFilePairHash {
- std::size_t operator()(const std::pair<StringRef, const File *> &v) const {
- return llvm::hash_combine(v.first, v.second);
- }
-};
-
template <class ELFT>
void OutputELFWriter<ELFT>::buildDynamicSymbolTable(const File &file) {
ScopedTask task(getDefaultDomain(), "buildDynamicSymbolTable");
@@ -181,26 +176,14 @@ void OutputELFWriter<ELFT>::buildDynamicSymbolTable(const File &file) {
_dynamicSymbolTable->addSymbol(atom->_atom, section->ordinal(),
atom->_virtualAddr, atom);
}
- std::unordered_set<std::pair<StringRef, const File *>, StringRefFilePairHash>
- soNeeded;
for (const auto sla : file.sharedLibrary()) {
_dynamicSymbolTable->addSymbol(sla, ELF::SHN_UNDEF);
- soNeeded.insert(std::make_pair(sla->loadName(), &sla->file()));
+ _soNeeded.insert(sla->loadName());
}
- // Sort needed entries by command line order. This is needed so the correct
- // dynamic symbol is loaded in cases where multiple dynamic libraries define
- // the same symbol.
- std::vector<std::pair<StringRef, const File *>> sortedSoNeeded(
- soNeeded.begin(), soNeeded.end());
- std::sort(sortedSoNeeded.begin(), sortedSoNeeded.end(),
- [](const std::pair<StringRef, const File *> &a,
- const std::pair<StringRef, const File *> &b) {
- return a.second->ordinal() < b.second->ordinal();
- });
- for (auto const &lib : sortedSoNeeded) {
+ for (const auto &loadName : _soNeeded) {
Elf_Dyn dyn;
dyn.d_tag = DT_NEEDED;
- dyn.d_un.d_val = _dynamicStringTable->addString(lib.first);
+ dyn.d_un.d_val = _dynamicStringTable->addString(loadName.getKey());
_dynamicTable->addEntry(dyn);
}
const auto &rpathList = _context.getRpathList();
diff --git a/lld/test/elf/DT_NEEDED-order.test b/lld/test/elf/DT_NEEDED-order.test
deleted file mode 100644
index 631bfc0ea0c..00000000000
--- a/lld/test/elf/DT_NEEDED-order.test
+++ /dev/null
@@ -1,14 +0,0 @@
-RUN: lld -flavor gnu -target x86_64-linux %p/Inputs/use-shared2.x86-64 \
-RUN: %p/Inputs/shared.so-x86-64 %p/Inputs/libundef.so -o %t -e main \
-RUN: --noinhibit-exec
-RUN: lld -flavor gnu -target x86_64-linux %p/Inputs/use-shared2.x86-64 \
-RUN: %p/Inputs/libundef.so %p/Inputs/shared.so-x86-64 -o %t2 -e main \
-RUN: --noinhibit-exec
-RUN: llvm-readobj -dynamic-table %t | FileCheck --check-prefix=ORDER1 %s
-RUN: llvm-readobj -dynamic-table %t2 | FileCheck --check-prefix=ORDER2 %s
-
-ORDER1: NEEDED SharedLibrary (shared.so
-ORDER1: NEEDED SharedLibrary (libundef.so
-
-ORDER2: NEEDED SharedLibrary (libundef.so
-ORDER2: NEEDED SharedLibrary (shared.so
diff --git a/lld/test/elf/Inputs/use-shared.c b/lld/test/elf/Inputs/use-shared.c
index cac8a19bcf9..b370eaa4fac 100644
--- a/lld/test/elf/Inputs/use-shared.c
+++ b/lld/test/elf/Inputs/use-shared.c
@@ -1,8 +1,7 @@
extern int i;
-extern long long x __attribute__((weak));
void foo();
int main() {
foo();
- return i + x;
+ return i;
}
diff --git a/lld/test/elf/Inputs/use-shared2.x86-64 b/lld/test/elf/Inputs/use-shared2.x86-64
deleted file mode 100644
index 0c9c62b1db1..00000000000
--- a/lld/test/elf/Inputs/use-shared2.x86-64
+++ /dev/null
Binary files differ
OpenPOWER on IntegriCloud