diff options
author | Fangrui Song <i@maskray.me> | 2024-07-08 09:14:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-08 09:14:34 -0700 |
commit | 2f37a22f10a1128c695bc469871a9101edce853e (patch) | |
tree | 7c135f7f5d61bd4f632dbaa1d3f4938543032725 /llvm/tools/llvm-objdump/llvm-objdump.cpp | |
parent | 12e47aabd4e4c6cec15092183b91ec279a0a7ab4 (diff) | |
download | llvm-2f37a22f10a1128c695bc469871a9101edce853e.zip llvm-2f37a22f10a1128c695bc469871a9101edce853e.tar.gz llvm-2f37a22f10a1128c695bc469871a9101edce853e.tar.bz2 |
[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<ELFT>.
The test is adapted from llvm/test/tools/llvm-readobj/ELF/crel.test.
Pull Request: https://github.com/llvm/llvm-project/pull/97382
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r-- | llvm/tools/llvm-objdump/llvm-objdump.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 6249be4..d124002 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -2687,6 +2687,16 @@ void Dumper::printRelocations() { << "VALUE\n"; for (SectionRef Section : P.second) { + // CREL sections require decoding, each section may have its own specific + // decode problems. + if (O.isELF() && ELFSectionRef(Section).getType() == ELF::SHT_CREL) { + StringRef Err = + cast<const ELFObjectFileBase>(O).getCrelDecodeProblem(Section); + if (!Err.empty()) { + reportUniqueWarning(Err); + continue; + } + } for (const RelocationRef &Reloc : Section.relocations()) { uint64_t Address = Reloc.getOffset(); SmallString<32> RelocName; |