Adding changes to support GNU style archive library reading

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167853 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Shankar Easwaran
2012-11-13 18:38:42 +00:00
parent f741482387
commit 206252cc9f
9 changed files with 431 additions and 26 deletions

View File

@@ -113,6 +113,10 @@ namespace {
cl::opt<bool> WithoutAliases("without-aliases", cl::Hidden,
cl::desc("Exclude aliases from output"));
cl::opt<bool> ArchiveMap("print-armap",
cl::desc("Print the archive map"));
cl::alias ArchiveMaps("s", cl::desc("Alias for --print-armap"),
cl::aliasopt(ArchiveMap));
bool PrintAddress = true;
bool MultipleFiles = false;
@@ -346,6 +350,24 @@ static void DumpSymbolNamesFromFile(std::string &Filename) {
return;
if (object::Archive *a = dyn_cast<object::Archive>(arch.get())) {
if (ArchiveMap) {
outs() << "Archive map" << "\n";
for (object::Archive::symbol_iterator i = a->begin_symbols(),
e = a->end_symbols(); i != e; ++i) {
object::Archive::child_iterator c;
StringRef symname;
StringRef filename;
if (error(i->getMember(c)))
return;
if (error(i->getName(symname)))
return;
if (error(c->getName(filename)))
return;
outs() << symname << " in " << filename << "\n";
}
outs() << "\n";
}
for (object::Archive::child_iterator i = a->begin_children(),
e = a->end_children(); i != e; ++i) {
OwningPtr<Binary> child;