child_iterator findSym(StringRef name) const;
bool hasSymbolTable() const;
- child_iterator getSymbolTableChild() const { return SymbolTable; }
- StringRef getSymbolTable() const {
- // We know that the symbol table is not an external file,
- // so we just assert there is no error.
- return *SymbolTable->getBuffer();
- }
+ StringRef getSymbolTable() const { return SymbolTable; }
uint32_t getNumberOfSymbols() const;
private:
- child_iterator SymbolTable;
+ StringRef SymbolTable;
StringRef StringTable;
child_iterator FirstRegular;
unsigned Format : 2;
}
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)) {
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();
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;
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;
}
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) {
return child_end();
}
-bool Archive::hasSymbolTable() const {
- return SymbolTable != child_end();
-}
+bool Archive::hasSymbolTable() const { return !SymbolTable.empty(); }
}
static void printArchiveHeaders(Archive *A, bool verbose, bool print_offset) {
- if (A->hasSymbolTable()) {
- Archive::child_iterator S = A->getSymbolTableChild();
- Archive::Child C = *S;
- printArchiveChild(C, verbose, print_offset);
- }
- for (Archive::child_iterator I = A->child_begin(), E = A->child_end(); I != E;
- ++I) {
+ for (Archive::child_iterator I = A->child_begin(false), E = A->child_end();
+ I != E; ++I) {
Archive::Child C = *I;
printArchiveChild(C, verbose, print_offset);
}