From: Jakub Jelinek Date: Fri, 10 Dec 2004 13:08:03 +0000 (+0000) Subject: * elf.c (bfd_elf_local_sym_name): Avoid crashes with invalid X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=138f35cc73eff0f822352241172678de82934d86;p=binutils-gdb.git * elf.c (bfd_elf_local_sym_name): Avoid crashes with invalid st_shndx on STT_SECTION sections. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index d488fbb30b7..415356ddf5f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2004-12-10 Jakub Jelinek + + * elf.c (bfd_elf_local_sym_name): Avoid crashes with invalid + st_shndx on STT_SECTION sections. + 2004-12-09 Daniel Jacobowitz * elfcode.h (elf_slurp_reloc_table_from_section): Don't canonicalize diff --git a/bfd/elf.c b/bfd/elf.c index c14b91a53c1..2eef4baeecf 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -409,7 +409,10 @@ bfd_elf_local_sym_name (bfd *abfd, Elf_Internal_Sym *isym) { unsigned int iname = isym->st_name; unsigned int shindex = elf_tdata (abfd)->symtab_hdr.sh_link; - if (iname == 0 && ELF_ST_TYPE (isym->st_info) == STT_SECTION) + if (iname == 0 && ELF_ST_TYPE (isym->st_info) == STT_SECTION + /* Check for a bogus st_shndx to avoid crashing. */ + && isym->st_shndx < elf_numsections (abfd) + && !(isym->st_shndx >= SHN_LORESERVE && isym->st_shndx <= SHN_HIRESERVE)) { iname = elf_elfsections (abfd)[isym->st_shndx]->sh_name; shindex = elf_elfheader (abfd)->e_shstrndx;