+2014-12-04 Mark Wielaard <mjw@redhat.com>
+
+ * objdump.c (show_relocs_x): Make sure destshdr exists.
+ (show_relocs_rel): Don't rely on shdr->sh_entsize, use gelf_fsize.
+ (show_relocs_rela): Likewise.
+ (show_relocs): Make sure destshdr, symshdr and symdata exists.
+
2014-11-30 Mark Wielaard <mjw@redhat.com>
* readelf.c (handle_sysv_hash64): Fix overflow check.
? xndx : sym->st_shndx),
&destshdr_mem);
- if (shdr == NULL)
+ if (shdr == NULL || destshdr == NULL)
printf ("<%s %ld>",
gettext ("INVALID SECTION"),
(long int) (sym->st_shndx == SHN_XINDEX
Elf_Data *symdata, Elf_Data *xndxdata, size_t symstrndx,
size_t shstrndx)
{
- int nentries = shdr->sh_size / shdr->sh_entsize;
+ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_REL, 1, EV_CURRENT);
+ int nentries = shdr->sh_size / sh_entsize;
for (int cnt = 0; cnt < nentries; ++cnt)
{
Elf_Data *symdata, Elf_Data *xndxdata, size_t symstrndx,
size_t shstrndx)
{
- int nentries = shdr->sh_size / shdr->sh_entsize;
+ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_RELA, 1, EV_CURRENT);
+ int nentries = shdr->sh_size / sh_entsize;
for (int cnt = 0; cnt < nentries; ++cnt)
{
GElf_Shdr *destshdr = gelf_getshdr (elf_getscn (ebl->elf,
shdr->sh_info),
&destshdr_mem);
+ if (unlikely (destshdr == NULL))
+ continue;
printf (gettext ("\nRELOCATION RECORDS FOR [%s]:\n"
"%-*s TYPE VALUE\n"),
GElf_Shdr symshdr_mem;
GElf_Shdr *symshdr = gelf_getshdr (symscn, &symshdr_mem);
Elf_Data *symdata = elf_getdata (symscn, NULL);
+ if (unlikely (symshdr == NULL || symdata == NULL))
+ continue;
/* Search for the optional extended section index table. */
Elf_Data *xndxdata = NULL;