Index: include/llvm/Object/ELFObjectFile.h =================================================================== --- include/llvm/Object/ELFObjectFile.h +++ include/llvm/Object/ELFObjectFile.h @@ -683,8 +683,6 @@ template uint64_t ELFObjectFile::getRelocationOffset(DataRefImpl Rel) const { - assert(EF.getHeader()->e_type == ELF::ET_REL && - "Only relocatable object files have relocation offsets"); const Elf_Shdr *sec = getRelSection(Rel); if (sec->sh_type == ELF::SHT_REL) return getRel(Rel)->r_offset; Index: test/tools/llvm-objdump/relocations-in-nonrelocatable.test =================================================================== --- test/tools/llvm-objdump/relocations-in-nonrelocatable.test +++ test/tools/llvm-objdump/relocations-in-nonrelocatable.test @@ -0,0 +1,4 @@ +// This test checks that relocation in nonrelocatable files are printed +// RUN: llvm-objdump -r %p/Inputs/relocations-in-nonrelocatable.elf-hexagon | FileCheck %s + +CHECK: 00000080 R_HEX_HI16 hexagon_pre_main Index: tools/llvm-objdump/llvm-objdump.cpp =================================================================== --- tools/llvm-objdump/llvm-objdump.cpp +++ tools/llvm-objdump/llvm-objdump.cpp @@ -1154,11 +1154,6 @@ void llvm::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; - for (const SectionRef &Section : ToolSectionFilter(*Obj)) { if (Section.relocation_begin() == Section.relocation_end()) continue;