diff options
author | Fangrui Song <i@maskray.me> | 2022-07-01 09:08:42 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2022-07-01 09:08:42 -0700 |
commit | f80a4321ef1bafcd8041884bcb85d9ba24335adb (patch) | |
tree | c8a0e6b0e61883684a67acd03de5913637d1eeb6 /llvm/tools/llvm-objdump/llvm-objdump.cpp | |
parent | 38bcd483dd461e1e00d039700d16991a166183e6 (diff) | |
download | llvm-f80a4321ef1bafcd8041884bcb85d9ba24335adb.zip llvm-f80a4321ef1bafcd8041884bcb85d9ba24335adb.tar.gz llvm-f80a4321ef1bafcd8041884bcb85d9ba24335adb.tar.bz2 |
[llvm-objdump] -r: print non-SHF_ALLOC relocations for non-ET_REL files
ET_EXEC and ET_DYN files may contain non-SHF_ALLOC relocation sections
(e.g. ld --emit-relocs). Match GNU objdump by dumping them.
* Remove Object/dynamic-reloc.test. Replace it with a -r RUN line in dynamic-relocs.test
* Update relocations-in-nonreloc.test to set sh_link/sh_info. GNU
objdump seems to ignore a SHT_REL/SHT_RELA section not linking to SHT_SYMTAB.
The test did not test what it intended to test.
Fix https://github.com/llvm/llvm-project/issues/41246
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D128959
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r-- | llvm/tools/llvm-objdump/llvm-objdump.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 132320a..dc7083b 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -1780,10 +1780,6 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) { void objdump::printRelocations(const ObjectFile *Obj) { StringRef Fmt = Obj->getBytesInAddress() > 4 ? "%016" PRIx64 : "%08" PRIx64; - // Regular objdump doesn't print relocations in non-relocatable object - // files. - if (!Obj->isRelocatableObject()) - return; // Build a mapping from relocation target to a vector of relocation // sections. Usually, there is an only one relocation section for @@ -1791,6 +1787,8 @@ void objdump::printRelocations(const ObjectFile *Obj) { MapVector<SectionRef, std::vector<SectionRef>> SecToRelSec; uint64_t Ndx; for (const SectionRef &Section : ToolSectionFilter(*Obj, &Ndx)) { + if (Obj->isELF() && (ELFSectionRef(Section).getFlags() & ELF::SHF_ALLOC)) + continue; if (Section.relocation_begin() == Section.relocation_end()) continue; Expected<section_iterator> SecOrErr = Section.getRelocatedSection(); |