2014-12-26 Mark Wielaard <mjw@redhat.com>
+ * nm.c (show_symbols): Guard against divide by zero in error check.
+ Add section index number in error message.
+
+2014-12-26 Mark Wielaard <mjw@redhat.com>
+
* nm.c (handle_ar): Skip over /SYM64/ entries.
2014-12-26 Mark Wielaard <mjw@redhat.com>
size_t entsize = shdr->sh_entsize;
/* Consistency checks. */
- if (entsize != gelf_fsize (ebl->elf, ELF_T_SYM, 1, ehdr->e_version))
+ if (entsize == 0
+ || entsize != gelf_fsize (ebl->elf, ELF_T_SYM, 1, ehdr->e_version))
error (0, 0,
- gettext ("%s: entry size in section `%s' is not what we expect"),
- fullname, elf_strptr (ebl->elf, shstrndx, shdr->sh_name));
+ gettext ("%s: entry size in section %zd `%s' is not what we expect"),
+ fullname, elf_ndxscn (scn),
+ elf_strptr (ebl->elf, shstrndx, shdr->sh_name));
else if (size % entsize != 0)
error (0, 0,
- gettext ("%s: size of section `%s' is not multiple of entry size"),
- fullname, elf_strptr (ebl->elf, shstrndx, shdr->sh_name));
+ gettext ("%s: size of section %zd `%s' is not multiple of entry size"),
+ fullname, elf_ndxscn (scn),
+ elf_strptr (ebl->elf, shstrndx, shdr->sh_name));
/* Compute number of entries. Handle buggy entsize values. */
size_t nentries = size / (entsize ?: 1);