summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland McGrath <[email protected]>2009-01-22 19:55:00 -0800
committerRoland McGrath <[email protected]>2009-01-22 19:55:00 -0800
commit9a847e148b6aa52aae172b9bbf354ae89df8e0d3 (patch)
tree7225cdb6410aa4fde71dabebb1dcc504f6ddab2f
parentd759aa6df852e7776ab94eeee71a27989a11688b (diff)
readelf -l: Don't print section mapping when no sections.
-rw-r--r--src/ChangeLog2
-rw-r--r--src/readelf.c4
2 files changed, 6 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 4bd36618..da35a668 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,7 @@
2009-01-22 Roland McGrath <[email protected]>
+ * readelf.c (print_phdr): Don't print section mapping when no sections.
+
* Makefile.am (AM_CFLAGS): Pass -Wno-format for *_no_Wformat.
* readelf.c (print_debug_frame_section): Initialize IS_SIGNED to false
diff --git a/src/readelf.c b/src/readelf.c
index fc2abfc3..d5a3b8d4 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -976,6 +976,10 @@ print_phdr (Ebl *ebl, GElf_Ehdr *ehdr)
}
}
+ if (ehdr->e_shnum == 0)
+ /* No sections in the file. Punt. */
+ return;
+
/* Get the section header string table index. */
size_t shstrndx;
if (unlikely (elf_getshstrndx (ebl->elf, &shstrndx) < 0))