+2022-05-09 Mark Wielaard <mark@klomp.org>
+
+ * strip.c (remove_debug_relocations): Check gelf_getshdr, gelf_getrela,
+ gelf_getrel and gelf_getsymshndx don't return NULL.
+
2022-05-10 Mark Wielaard <mark@klomp.org>
* elfcompress.c (process_file): Sanity check shstrtab_name,
might want to change the size. */
GElf_Shdr shdr_mem;
GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
- if (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA)
+ if (shdr != NULL
+ && (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA))
{
/* Make sure that this relocation section points to a
section to relocate with contents, that isn't
Elf_Scn *tscn = elf_getscn (elf, shdr->sh_info);
GElf_Shdr tshdr_mem;
GElf_Shdr *tshdr = gelf_getshdr (tscn, &tshdr_mem);
- if (tshdr->sh_type == SHT_NOBITS
+ if (tshdr == NULL
+ || tshdr->sh_type == SHT_NOBITS
|| tshdr->sh_size == 0
|| (tshdr->sh_flags & SHF_ALLOC) != 0)
continue;
if (is_rela)
{
GElf_Rela *r = gelf_getrela (reldata, relidx, &mem.rela);
+ if (r == NULL)
+ INTERNAL_ERROR (fname);
offset = r->r_offset;
addend = r->r_addend;
rtype = GELF_R_TYPE (r->r_info);
else
{
GElf_Rel *r = gelf_getrel (reldata, relidx, &mem.rel);
+ if (r == NULL)
+ INTERNAL_ERROR (fname);
offset = r->r_offset;
addend = 0;
rtype = GELF_R_TYPE (r->r_info);
GElf_Sym *sym = gelf_getsymshndx (symdata, xndxdata,
symndx, &sym_mem,
&xndx);
+ if (sym == NULL)
+ INTERNAL_ERROR (fname);
Elf32_Word sec = (sym->st_shndx == SHN_XINDEX
? xndx : sym->st_shndx);