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 @@ -725,6 +725,9 @@ Optional StrTable, bool IsDynamic, bool /*NonVisibilityBitsUsed*/) const override; + void printRelRelaReloc(const Relocation &R, + const RelSymbol &RelSym) override; + private: std::unique_ptr FileScope; }; @@ -7547,6 +7550,7 @@ std::string(formatv("{0}bit", 8 * Obj.getBytesInAddress()))); this->printLoadName(); } + template void JSONELFDumper::printSymbol(const Elf_Sym &Symbol, unsigned SymIndex, DataRegion ShndxTable, @@ -7600,3 +7604,19 @@ } 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); +}