diff options
| author | Mark Wielaard <[email protected]> | 2012-03-28 11:20:36 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2012-03-28 19:56:02 +0200 |
| commit | 61651c110e4271cdea4ae153813898684bf9f0f8 (patch) | |
| tree | a292432de59e774ad66332bcfb42b13b69c25923 /src/readelf.c | |
| parent | 210c2f03efbbaacc51f2641baa0947d9c316de12 (diff) | |
readelf.c: Check debug section data before trying to print abbrev or str.
* readelf.c (print_debug_abbrev_section): Check there is Dwarf
section data.
(print_debug_str_section): Likewise.
Diffstat (limited to 'src/readelf.c')
| -rw-r--r-- | src/readelf.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/readelf.c b/src/readelf.c index f9f56aad..b70779dd 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -4566,13 +4566,16 @@ print_debug_abbrev_section (Dwfl_Module *dwflmod __attribute__ ((unused)), Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg) { + const size_t sh_size = (dbg->sectiondata[IDX_debug_abbrev] ? + dbg->sectiondata[IDX_debug_abbrev]->d_size : 0); + printf (gettext ("\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n" " [ Code]\n"), elf_ndxscn (scn), section_name (ebl, ehdr, shdr), (uint64_t) shdr->sh_offset); Dwarf_Off offset = 0; - while (offset < dbg->sectiondata[IDX_debug_abbrev]->d_size) + while (offset < sh_size) { printf (gettext ("\nAbbreviation section at offset %" PRIu64 ":\n"), offset); @@ -6781,7 +6784,8 @@ print_debug_str_section (Dwfl_Module *dwflmod __attribute__ ((unused)), Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg) { - const size_t sh_size = dbg->sectiondata[IDX_debug_str]->d_size; + const size_t sh_size = (dbg->sectiondata[IDX_debug_str] ? + dbg->sectiondata[IDX_debug_str]->d_size : 0); /* Compute floor(log16(shdr->sh_size)). */ GElf_Addr tmp = sh_size; |
