summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/Archive.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-10-31 21:03:29 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-10-31 21:03:29 +0000
commit4a782fbfe6698f581e4b5e40658b65b4d7039ac1 (patch)
tree54b807db4c039c16096dd289b97d839fe1c156fb /llvm/lib/Object/Archive.cpp
parent7f253aa63c1d779ac7380337876301c7cd4e5379 (diff)
downloadbcm5719-llvm-4a782fbfe6698f581e4b5e40658b65b4d7039ac1.tar.gz
bcm5719-llvm-4a782fbfe6698f581e4b5e40658b65b4d7039ac1.zip
Simplify handling of archive Symbol tables.
We only need to store a StringRef. llvm-svn: 251748
Diffstat (limited to 'llvm/lib/Object/Archive.cpp')
-rw-r--r--llvm/lib/Object/Archive.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp
index 2e71b8205d4..4bb50a0f757 100644
--- a/llvm/lib/Object/Archive.cpp
+++ b/llvm/lib/Object/Archive.cpp
@@ -233,8 +233,7 @@ ErrorOr<std::unique_ptr<Archive>> Archive::create(MemoryBufferRef Source) {
}
Archive::Archive(MemoryBufferRef Source, std::error_code &ec)
- : Binary(Binary::ID_Archive, Source), SymbolTable(child_end()),
- FirstRegular(child_end()) {
+ : Binary(Binary::ID_Archive, Source), FirstRegular(child_end()) {
StringRef Buffer = Data.getBuffer();
// Check for sufficient magic.
if (Buffer.startswith(ThinMagic)) {
@@ -278,7 +277,9 @@ Archive::Archive(MemoryBufferRef Source, std::error_code &ec)
if (Name == "__.SYMDEF") {
Format = K_BSD;
- SymbolTable = i;
+ // We know that the symbol table is not an external file, so we just assert
+ // there is no error.
+ SymbolTable = *i->getBuffer();
++i;
FirstRegular = i;
ec = std::error_code();
@@ -294,7 +295,9 @@ Archive::Archive(MemoryBufferRef Source, std::error_code &ec)
return;
Name = NameOrErr.get();
if (Name == "__.SYMDEF SORTED" || Name == "__.SYMDEF") {
- SymbolTable = i;
+ // We know that the symbol table is not an external file, so we just
+ // assert there is no error.
+ SymbolTable = *i->getBuffer();
++i;
}
FirstRegular = i;
@@ -308,7 +311,9 @@ Archive::Archive(MemoryBufferRef Source, std::error_code &ec)
bool has64SymTable = false;
if (Name == "/" || Name == "/SYM64/") {
- SymbolTable = i;
+ // We know that the symbol table is not an external file, so we just assert
+ // there is no error.
+ SymbolTable = *i->getBuffer();
if (Name == "/SYM64/")
has64SymTable = true;
@@ -344,7 +349,9 @@ Archive::Archive(MemoryBufferRef Source, std::error_code &ec)
}
Format = K_COFF;
- SymbolTable = i;
+ // We know that the symbol table is not an external file, so we just assert
+ // there is no error.
+ SymbolTable = *i->getBuffer();
++i;
if (i == e) {
@@ -551,6 +558,4 @@ Archive::child_iterator Archive::findSym(StringRef name) const {
return child_end();
}
-bool Archive::hasSymbolTable() const {
- return SymbolTable != child_end();
-}
+bool Archive::hasSymbolTable() const { return !SymbolTable.empty(); }
OpenPOWER on IntegriCloud