[llvm-objump] Simplify the code. NFCI.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281844 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Davide Italiano 2016-09-18 04:39:15 +00:00
parent a64fbcff2d
commit 4b868ad9b9

View File

@ -1877,27 +1877,18 @@ static void printFaultMaps(const ObjectFile *Obj) {
outs() << FMP;
}
static void printPrivateFileHeaders(const ObjectFile *o) {
static void printPrivateFileHeaders(const ObjectFile *o, bool onlyFirst) {
if (o->isELF())
printELFFileHeader(o);
else if (o->isCOFF())
printCOFFFileHeader(o);
else if (o->isMachO()) {
return printELFFileHeader(o);
if (o->isCOFF())
return printCOFFFileHeader(o);
if (o->isMachO()) {
printMachOFileHeader(o);
printMachOLoadCommands(o);
} else
report_fatal_error("Invalid/Unsupported object file format");
}
static void printFirstPrivateFileHeader(const ObjectFile *o) {
if (o->isELF())
printELFFileHeader(o);
else if (o->isCOFF())
printCOFFFileHeader(o);
else if (o->isMachO())
printMachOFileHeader(o);
else
report_fatal_error("Invalid/Unsupported object file format");
if (!onlyFirst)
printMachOLoadCommands(o);
return;
}
report_fatal_error("Invalid/Unsupported object file format");
}
static void DumpObject(const ObjectFile *o, const Archive *a = nullptr) {
@ -1924,10 +1915,8 @@ static void DumpObject(const ObjectFile *o, const Archive *a = nullptr) {
PrintSymbolTable(o, ArchiveName);
if (UnwindInfo)
PrintUnwindInfo(o);
if (PrivateHeaders)
printPrivateFileHeaders(o);
if (FirstPrivateHeader)
printFirstPrivateFileHeader(o);
if (PrivateHeaders || FirstPrivateHeader)
printPrivateFileHeaders(o, FirstPrivateHeader);
if (ExportsTrie)
printExportsTrie(o);
if (Rebase)