mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-22 14:05:03 +00:00
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:
parent
a6cd815994
commit
1c8dfa5e90
@ -63,6 +63,11 @@ input. Otherwise, it will read from the specified ``filenames``.
|
|||||||
|
|
||||||
Display unwind information.
|
Display unwind information.
|
||||||
|
|
||||||
|
.. option:: -expand-relocs
|
||||||
|
|
||||||
|
When used with ``-relocations``, display each relocation in an expanded
|
||||||
|
multi-line format.
|
||||||
|
|
||||||
.. option:: -dynamic-table
|
.. option:: -dynamic-table
|
||||||
|
|
||||||
Display the ELF .dynamic section table (only for ELF object files).
|
Display the ELF .dynamic section table (only for ELF object files).
|
||||||
|
@ -680,11 +680,18 @@ void COFFDumper::printRelocation(section_iterator SecI,
|
|||||||
if (error(Symbol.getName(SymbolName))) return;
|
if (error(Symbol.getName(SymbolName))) return;
|
||||||
if (error(SecI->getContents(Contents))) return;
|
if (error(SecI->getContents(Contents))) return;
|
||||||
|
|
||||||
raw_ostream& OS = W.startLine();
|
if (opts::ExpandRelocs) {
|
||||||
OS << W.hex(Offset)
|
DictScope Group(W, "Relocation");
|
||||||
<< " " << RelocName
|
W.printHex("Offset", Offset);
|
||||||
<< " " << (SymbolName.size() > 0 ? SymbolName : "-")
|
W.printNumber("Type", RelocName, RelocType);
|
||||||
<< "\n";
|
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() {
|
void COFFDumper::printSymbols() {
|
||||||
|
@ -549,22 +549,32 @@ template<class ELFT>
|
|||||||
void ELFDumper<ELFT>::printRelocation(section_iterator Sec,
|
void ELFDumper<ELFT>::printRelocation(section_iterator Sec,
|
||||||
relocation_iterator RelI) {
|
relocation_iterator RelI) {
|
||||||
uint64_t Offset;
|
uint64_t Offset;
|
||||||
|
uint64_t RelocType;
|
||||||
SmallString<32> RelocName;
|
SmallString<32> RelocName;
|
||||||
int64_t Info;
|
int64_t Info;
|
||||||
StringRef SymbolName;
|
StringRef SymbolName;
|
||||||
SymbolRef Symbol;
|
SymbolRef Symbol;
|
||||||
if (error(RelI->getOffset(Offset))) return;
|
if (error(RelI->getOffset(Offset))) return;
|
||||||
|
if (error(RelI->getType(RelocType))) return;
|
||||||
if (error(RelI->getTypeName(RelocName))) return;
|
if (error(RelI->getTypeName(RelocName))) return;
|
||||||
if (error(RelI->getAdditionalInfo(Info))) return;
|
if (error(RelI->getAdditionalInfo(Info))) return;
|
||||||
if (error(RelI->getSymbol(Symbol))) return;
|
if (error(RelI->getSymbol(Symbol))) return;
|
||||||
if (error(Symbol.getName(SymbolName))) return;
|
if (error(Symbol.getName(SymbolName))) return;
|
||||||
|
|
||||||
raw_ostream& OS = W.startLine();
|
if (opts::ExpandRelocs) {
|
||||||
OS << W.hex(Offset)
|
DictScope Group(W, "Relocation");
|
||||||
<< " " << RelocName
|
W.printHex("Offset", Offset);
|
||||||
<< " " << (SymbolName.size() > 0 ? SymbolName : "-")
|
W.printNumber("Type", RelocName, RelocType);
|
||||||
<< " " << W.hex(Info)
|
W.printString("Symbol", SymbolName.size() > 0 ? SymbolName : "-");
|
||||||
<< "\n";
|
W.printHex("Info", Info);
|
||||||
|
} else {
|
||||||
|
raw_ostream& OS = W.startLine();
|
||||||
|
OS << W.hex(Offset)
|
||||||
|
<< " " << RelocName
|
||||||
|
<< " " << (SymbolName.size() > 0 ? SymbolName : "-")
|
||||||
|
<< " " << W.hex(Info)
|
||||||
|
<< "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class ELFT>
|
template<class ELFT>
|
||||||
|
@ -341,18 +341,32 @@ void MachODumper::printRelocation(section_iterator SecI,
|
|||||||
const MachOObjectFileBase::RelocationEntry *RE = Obj->getRelocation(DR);
|
const MachOObjectFileBase::RelocationEntry *RE = Obj->getRelocation(DR);
|
||||||
bool IsScattered = Obj->isScattered(RE);
|
bool IsScattered = Obj->isScattered(RE);
|
||||||
|
|
||||||
raw_ostream& OS = W.startLine();
|
if (opts::ExpandRelocs) {
|
||||||
OS << W.hex(Offset)
|
DictScope Group(W, "Relocation");
|
||||||
<< " " << Obj->isPCRel(RE)
|
W.printHex("Offset", Offset);
|
||||||
<< " " << Obj->getLength(RE);
|
W.printNumber("PCRel", Obj->isPCRel(RE));
|
||||||
if (IsScattered)
|
W.printNumber("Length", Obj->getLength(RE));
|
||||||
OS << " n/a";
|
if (IsScattered)
|
||||||
else
|
W.printString("Extern", StringRef("N/A"));
|
||||||
OS << " " << RE->getExternal();
|
else
|
||||||
OS << " " << RelocName
|
W.printNumber("Extern", RE->getExternal());
|
||||||
<< " " << IsScattered
|
W.printNumber("Type", RelocName, RE->getType());
|
||||||
<< " " << (SymbolName.size() > 0 ? SymbolName : "-")
|
W.printString("Symbol", SymbolName.size() > 0 ? SymbolName : "-");
|
||||||
<< "\n";
|
W.printNumber("Scattered", IsScattered);
|
||||||
|
} else {
|
||||||
|
raw_ostream& OS = W.startLine();
|
||||||
|
OS << W.hex(Offset)
|
||||||
|
<< " " << Obj->isPCRel(RE)
|
||||||
|
<< " " << Obj->getLength(RE);
|
||||||
|
if (IsScattered)
|
||||||
|
OS << " n/a";
|
||||||
|
else
|
||||||
|
OS << " " << RE->getExternal();
|
||||||
|
OS << " " << RelocName
|
||||||
|
<< " " << IsScattered
|
||||||
|
<< " " << (SymbolName.size() > 0 ? SymbolName : "-")
|
||||||
|
<< "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MachODumper::printSymbols() {
|
void MachODumper::printSymbols() {
|
||||||
|
@ -120,6 +120,10 @@ namespace opts {
|
|||||||
// -needed-libs
|
// -needed-libs
|
||||||
cl::opt<bool> NeededLibraries("needed-libs",
|
cl::opt<bool> NeededLibraries("needed-libs",
|
||||||
cl::desc("Display the needed libraries"));
|
cl::desc("Display the needed libraries"));
|
||||||
|
|
||||||
|
// -expand-relocs
|
||||||
|
cl::opt<bool> ExpandRelocs("expand-relocs",
|
||||||
|
cl::desc("Expand each shown relocation to multiple lines"));
|
||||||
} // namespace opts
|
} // namespace opts
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
@ -37,6 +37,7 @@ namespace opts {
|
|||||||
extern llvm::cl::opt<bool> Symbols;
|
extern llvm::cl::opt<bool> Symbols;
|
||||||
extern llvm::cl::opt<bool> DynamicSymbols;
|
extern llvm::cl::opt<bool> DynamicSymbols;
|
||||||
extern llvm::cl::opt<bool> UnwindInfo;
|
extern llvm::cl::opt<bool> UnwindInfo;
|
||||||
|
extern llvm::cl::opt<bool> ExpandRelocs;
|
||||||
} // namespace opts
|
} // namespace opts
|
||||||
|
|
||||||
#define LLVM_READOBJ_ENUM_ENT(ns, enum) \
|
#define LLVM_READOBJ_ENUM_ENT(ns, enum) \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user