--- bfd/elf.c 2004-09-27 21:46:06.000000000 +0100 +++ bfd/elf.c 2005-05-09 15:23:43.000000000 +0100 @@ -796,7 +796,8 @@ /* Look through the phdrs to see if we need to adjust the lma. If all the p_paddr fields are zero, we ignore them, since some ELF linkers produce such output. */ - phdr = elf_tdata (abfd)->phdr; + if ((phdr = elf_tdata (abfd)->phdr) == NULL) + return FALSE; for (i = 0; i < elf_elfheader (abfd)->e_phnum; i++, phdr++) { if (phdr->p_paddr != 0) @@ -1724,6 +1725,9 @@ const struct elf_backend_data *bed = get_elf_backend_data (abfd); const char *name; + if (hdr == NULL) + return FALSE; + name = elf_string_from_elf_strtab (abfd, hdr->sh_name); switch (hdr->sh_type) @@ -1744,6 +1748,9 @@ case SHT_DYNAMIC: /* Dynamic linking information. */ if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name)) return FALSE; + if (hdr->sh_link > elf_numsections (abfd) || + elf_elfsections (abfd)[hdr->sh_link] == NULL) + return FALSE; if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB) { Elf_Internal_Shdr *dynsymhdr;