Add -expand-relocs to llvm-readobj

This option expands shown relocations from single line to a dictionary
format:

  Relocation {
    Offset: 0x4
    Type: R_386_32 (1)
    Symbol: sym
    Info: 0x0
  }

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179359 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nico Rieck
2013-04-12 04:01:52 +00:00
parent a6cd815994
commit 1c8dfa5e90
6 changed files with 64 additions and 23 deletions

View File

@ -680,11 +680,18 @@ void COFFDumper::printRelocation(section_iterator SecI,
if (error(Symbol.getName(SymbolName))) return;
if (error(SecI->getContents(Contents))) return;
raw_ostream& OS = W.startLine();
OS << W.hex(Offset)
<< " " << RelocName
<< " " << (SymbolName.size() > 0 ? SymbolName : "-")
<< "\n";
if (opts::ExpandRelocs) {
DictScope Group(W, "Relocation");
W.printHex("Offset", Offset);
W.printNumber("Type", RelocName, RelocType);
W.printString("Symbol", SymbolName.size() > 0 ? SymbolName : "-");
} else {
raw_ostream& OS = W.startLine();
OS << W.hex(Offset)
<< " " << RelocName
<< " " << (SymbolName.size() > 0 ? SymbolName : "-")
<< "\n";
}
}
void COFFDumper::printSymbols() {