summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/ELF/DynamicFile.h
diff options
context:
space:
mode:
authorShankar Easwaran <shankare@codeaurora.org>2013-04-11 02:56:30 +0000
committerShankar Easwaran <shankare@codeaurora.org>2013-04-11 02:56:30 +0000
commiteeee23e60a0d576660bfce5820d0d34614f0ae40 (patch)
tree1f96e4756f0911aadcf96e333a114c489b0631b9 /lld/lib/ReaderWriter/ELF/DynamicFile.h
parent1d532a30831f3fac353b8e676858356f17b50a79 (diff)
downloadbcm5719-llvm-eeee23e60a0d576660bfce5820d0d34614f0ae40.tar.gz
bcm5719-llvm-eeee23e60a0d576660bfce5820d0d34614f0ae40.zip
This adds functionality for undefined atoms from dynamic libraries to be added
to the list of undefined atoms. The processing of undefined atoms from dynamic libraries is controlled by use-shlib-undefines command line option. This patch also adds additional command line arguments to allow/disallow unresolved symbols from shared libraries and mimics GNU ld behavior. llvm-svn: 179257
Diffstat (limited to 'lld/lib/ReaderWriter/ELF/DynamicFile.h')
-rw-r--r--lld/lib/ReaderWriter/ELF/DynamicFile.h29
1 files changed, 20 insertions, 9 deletions
diff --git a/lld/lib/ReaderWriter/ELF/DynamicFile.h b/lld/lib/ReaderWriter/ELF/DynamicFile.h
index 2e9a9389499..0e45949c725 100644
--- a/lld/lib/ReaderWriter/ELF/DynamicFile.h
+++ b/lld/lib/ReaderWriter/ELF/DynamicFile.h
@@ -10,6 +10,8 @@
#ifndef LLD_READER_WRITER_ELF_DYNAMIC_FILE_H
#define LLD_READER_WRITER_ELF_DYNAMIC_FILE_H
+#include "Atoms.h"
+
#include "lld/Core/SharedLibraryFile.h"
#include "lld/ReaderWriter/ELFTargetInfo.h"
@@ -27,6 +29,8 @@ public:
std::unique_ptr<DynamicFile> file(
new DynamicFile(ti, mb->getBufferIdentifier()));
llvm::OwningPtr<llvm::object::Binary> binaryFile;
+ bool useShlibUndefines = ti.useShlibUndefines();
+
if (error_code ec = createBinary(mb.release(), binaryFile))
return ec;
@@ -51,18 +55,25 @@ public:
for (auto i = obj.begin_elf_dynamic_symbols(),
e = obj.end_elf_dynamic_symbols();
i != e; ++i) {
- // Don't expose undefined or absolute symbols to export.
- if (i->st_shndx == llvm::ELF::SHN_ABS ||
- i->st_shndx == llvm::ELF::SHN_UNDEF)
- continue;
StringRef name;
- if (error_code ec =
- obj.getSymbolName(obj.getDynamicSymbolTableSectionHeader(), &*i,
- name))
+ if (error_code ec = obj.getSymbolName(
+ obj.getDynamicSymbolTableSectionHeader(), &*i, name))
return ec;
- file->_nameToSym[name]._symbol = &*i;
- // TODO: Read undefined dynamic symbols into _undefinedAtoms.
+ // TODO: Add absolute symbols
+ if (i->st_shndx == llvm::ELF::SHN_ABS)
+ continue;
+
+ if (useShlibUndefines && (i->st_shndx == llvm::ELF::SHN_UNDEF)) {
+ // Create an undefined atom.
+ if (!name.empty()) {
+ auto *newAtom =
+ new (file->_alloc) ELFUndefinedAtom<ELFT>(*file.get(), name, &*i);
+ file->_undefinedAtoms._atoms.push_back(newAtom);
+ }
+ continue;
+ }
+ file->_nameToSym[name]._symbol = &*i;
}
return std::move(file);
OpenPOWER on IntegriCloud