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 @@ -731,6 +731,8 @@ void printRelRelaReloc(const Relocation &R, const RelSymbol &RelSym) override; + void printRelocations() override; + private: std::unique_ptr FileScope; }; @@ -7610,3 +7612,18 @@ } return SymOtherFlags; } + +template void JSONELFDumper::printRelocations() { + ListScope D(this->W, "Relocations"); + + for (const Elf_Shdr &Sec : cantFail(this->Obj.sections())) { + if (!isRelocationSec(Sec)) + continue; + + StringRef Name = this->getPrintableSectionName(Sec); + unsigned SecNdx = &Sec - &cantFail(this->Obj.sections()).front(); + DictScope Group(this->W); + this->W.printNumber("SectionIdx", SecNdx); + this->printRelocationsHelper(Sec); + } +}