[PATCH] llvm-objdump: don't assert if ELF file has no sections

Ed Maste emaste at freebsd.org
Fri Jun 27 06:48:51 PDT 2014


FreeBSD core files have no sections, and cause llvm-objdump to exit with an assertion failure.

llvm.org/pr20139

http://reviews.llvm.org/D4323

Files:
  include/llvm/Object/ELF.h

Index: include/llvm/Object/ELF.h
===================================================================
--- include/llvm/Object/ELF.h
+++ include/llvm/Object/ELF.h
@@ -602,7 +602,7 @@
 template <class ELFT>
 uint64_t ELFFile<ELFT>::getNumSections() const {
   assert(Header && "Header not initialized!");
-  if (Header->e_shnum == ELF::SHN_UNDEF) {
+  if (Header->e_shnum == ELF::SHN_UNDEF && Header->e_shoff > 0) {
     assert(SectionHeaderTable && "SectionHeaderTable not initialized!");
     return SectionHeaderTable->sh_size;
   }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4323.10931.patch
Type: text/x-patch
Size: 533 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140627/5e3f2edd/attachment.bin>


More information about the llvm-commits mailing list