From 2f37a22f10a1128c695bc469871a9101edce853e Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 8 Jul 2024 09:14:34 -0700 Subject: [llvm-objdump] -r: support CREL Extract the llvm-readelf decoder to `decodeCrel` (#91280) and reuse it for llvm-objdump. Because the section representation of LLVMObject (`SectionRef`) is 64-bit, insufficient to hold all decoder states, `section_rel_begin` is modified to decode CREL eagerly and hold the decoded relocations inside ELFObjectFile. The test is adapted from llvm/test/tools/llvm-readobj/ELF/crel.test. Pull Request: https://github.com/llvm/llvm-project/pull/97382 --- llvm/lib/Object/ELFObjectFile.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'llvm/lib/Object/ELFObjectFile.cpp') diff --git a/llvm/lib/Object/ELFObjectFile.cpp b/llvm/lib/Object/ELFObjectFile.cpp index cbc55a1..53c3de0 100644 --- a/llvm/lib/Object/ELFObjectFile.cpp +++ b/llvm/lib/Object/ELFObjectFile.cpp @@ -1013,3 +1013,14 @@ Expected> ELFObjectFileBase::readBBAddrMap( return readBBAddrMapImpl(cast(this)->getELFFile(), TextSectionIndex, PGOAnalyses); } + +StringRef ELFObjectFileBase::getCrelDecodeProblem(SectionRef Sec) const { + auto Data = Sec.getRawDataRefImpl(); + if (const auto *Obj = dyn_cast(this)) + return Obj->getCrelDecodeProblem(Data); + if (const auto *Obj = dyn_cast(this)) + return Obj->getCrelDecodeProblem(Data); + if (const auto *Obj = dyn_cast(this)) + return Obj->getCrelDecodeProblem(Data); + return cast(this)->getCrelDecodeProblem(Data); +} -- cgit v1.1