Fix some double printing of filenames for archives in llvm-nm when

the tool is given multiple files.  Also fix the same issue with Mach-O
universal files. And fix the newline spacing to separate the output
in these cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211405 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Kevin Enderby 2014-06-20 21:29:27 +00:00
parent 85fdfe8efc
commit efc447827d
2 changed files with 17 additions and 12 deletions

View File

@ -12,7 +12,8 @@ CHECK: trivial-object-test.elf-x86-64:
CHECK-NEXT: U SomeOtherFunction
CHECK-NEXT: 0000000000000000 T main
CHECK-NEXT: U puts
CHECK-NEXT: trivial-object-test2.elf-x86-64:
CHECK: trivial-object-test2.elf-x86-64:
CHECK-NEXT: 0000000000000000 t bar
CHECK-NEXT: 0000000000000006 T foo
CHECK-NEXT: 0000000000000016 T main
@ -40,7 +41,8 @@ CORRUPT: trivial-object-test.elf-x86-64:
CORRUPT-NEXT: U SomeOtherFunction
CORRUPT-NEXT: 0000000000000000 T main
CORRUPT-NEXT: U puts
CORRUPT-NEXT: trivial-object-test2.elf-x86-64:
CORRUPT: trivial-object-test2.elf-x86-64:
CORRUPT-NEXT: 0000000000000000 t bar
CORRUPT-NEXT: 0000000000000006 T foo
CORRUPT-NEXT: 0000000000000016 T main

View File

@ -370,7 +370,7 @@ static void darwinPrintSymbol(MachOObjectFile *MachO, SymbolListT::iterator I,
outs() << "\n";
}
static void sortAndPrintSymbolList(SymbolicFile *Obj) {
static void sortAndPrintSymbolList(SymbolicFile *Obj, bool printName) {
if (!NoSort) {
if (NumericSort)
std::sort(SymbolList.begin(), SymbolList.end(), compareSymbolAddress);
@ -380,9 +380,9 @@ static void sortAndPrintSymbolList(SymbolicFile *Obj) {
std::sort(SymbolList.begin(), SymbolList.end(), compareSymbolName);
}
if (OutputFormat == posix && MultipleFiles) {
if (OutputFormat == posix && MultipleFiles && printName) {
outs() << '\n' << CurrentFilename << ":\n";
} else if (OutputFormat == bsd && MultipleFiles) {
} else if (OutputFormat == bsd && MultipleFiles && printName) {
outs() << "\n" << CurrentFilename << ":\n";
} else if (OutputFormat == sysv) {
outs() << "\n\nSymbols from " << CurrentFilename << ":\n\n"
@ -664,7 +664,7 @@ static char getNMTypeChar(SymbolicFile *Obj, basic_symbol_iterator I) {
return Ret;
}
static void dumpSymbolNamesFromObject(SymbolicFile *Obj) {
static void dumpSymbolNamesFromObject(SymbolicFile *Obj, bool printName) {
basic_symbol_iterator IBegin = Obj->symbol_begin();
basic_symbol_iterator IEnd = Obj->symbol_end();
if (DynamicSyms) {
@ -717,7 +717,7 @@ static void dumpSymbolNamesFromObject(SymbolicFile *Obj) {
}
CurrentFilename = Obj->getFileName();
sortAndPrintSymbolList(Obj);
sortAndPrintSymbolList(Obj, printName);
}
static void dumpSymbolNamesFromFile(std::string &Filename) {
@ -757,12 +757,13 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
if (ChildOrErr.getError())
continue;
if (SymbolicFile *O = dyn_cast<SymbolicFile>(&*ChildOrErr.get())) {
outs() << "\n";
if (isa<MachOObjectFile>(O)) {
outs() << Filename << "(" << O->getFileName() << ")";
} else
outs() << O->getFileName();
outs() << ":\n";
dumpSymbolNamesFromObject(O);
dumpSymbolNamesFromObject(O, false);
}
}
return;
@ -775,11 +776,13 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
std::unique_ptr<ObjectFile> Obj;
std::unique_ptr<Archive> A;
if (!I->getAsObjectFile(Obj)) {
if (moreThanOneArch)
outs() << "\n";
outs() << Obj->getFileName();
if (isa<MachOObjectFile>(Obj.get()) && moreThanOneArch)
outs() << " (for architecture " << I->getArchTypeName() << ")";
outs() << ":\n";
dumpSymbolNamesFromObject(Obj.get());
dumpSymbolNamesFromObject(Obj.get(), false);
}
else if (!I->getAsArchive(A)) {
for (Archive::child_iterator AI = A->child_begin(), AE = A->child_end();
@ -789,7 +792,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
if (ChildOrErr.getError())
continue;
if (SymbolicFile *O = dyn_cast<SymbolicFile>(&*ChildOrErr.get())) {
outs() << A->getFileName();
outs() << "\n" << A->getFileName();
if (isa<MachOObjectFile>(O)) {
outs() << "(" << O->getFileName() << ")";
if (moreThanOneArch)
@ -797,7 +800,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
} else
outs() << ":" << O->getFileName();
outs() << ":\n";
dumpSymbolNamesFromObject(O);
dumpSymbolNamesFromObject(O, false);
}
}
}
@ -805,7 +808,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
return;
}
if (SymbolicFile *O = dyn_cast<SymbolicFile>(Bin.get())) {
dumpSymbolNamesFromObject(O);
dumpSymbolNamesFromObject(O, true);
return;
}
error("unrecognizable file type", Filename);