diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -729,6 +729,9 @@ Optional StrTable, bool IsDynamic, bool /*NonVisibilityBitsUsed*/) const override; + void printRelRelaReloc(const Relocation &R, + const RelSymbol &RelSym) override; + private: std::unique_ptr FileScope; }; @@ -7590,3 +7593,19 @@ W.printFlags("Other", Symbol.st_other, makeArrayRef(SymOtherFlags), 0x3u); this->printSymbolSection(Symbol, SymIndex, ShndxTable); } + +template +void JSONELFDumper::printRelRelaReloc(const Relocation &R, + const RelSymbol &RelSym) { + StringRef SymbolName = RelSym.Name; + SmallString<32> RelocName; + this->Obj.getRelocationTypeName(R.Type, RelocName); + ScopedPrinter &W = this->W; + + DictScope Group(W, "Relocation"); + W.printHex("Offset", R.Offset); + W.printNumber("Type", RelocName, R.Type); + W.printNumber("Symbol", SymbolName, R.Symbol); + if (R.Addend) + W.printHex("Addend", (uintX_t)*R.Addend); +}