From 9a847e148b6aa52aae172b9bbf354ae89df8e0d3 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 22 Jan 2009 19:55:00 -0800 Subject: [PATCH] readelf -l: Don't print section mapping when no sections. --- src/ChangeLog | 2 ++ src/readelf.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index 4bd36618b..da35a6687 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 2009-01-22 Roland McGrath + * 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 fc2abfc3d..d5a3b8d45 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)) -- 2.47.3