From: Alan Modra Date: Wed, 27 Mar 2002 00:16:54 +0000 (+0000) Subject: * elf.c (_bfd_elf_get_symtab_upper_bound): Leave space for X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b99d18333dd47aa5750a26999e683480f16fb1d4;p=binutils-gdb.git * elf.c (_bfd_elf_get_symtab_upper_bound): Leave space for terminating NULL if empty symbol table. (_bfd_elf_get_dynamic_symtab_upper_bound): Likewise. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index b28e9780d7e..c32ee17d48f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2002-03-27 Gregory Steuck + + * elf.c (_bfd_elf_get_symtab_upper_bound): Leave space for + terminating NULL if empty symbol table. + (_bfd_elf_get_dynamic_symtab_upper_bound): Likewise. + 2002-03-26 H.J. Lu (hjl@gnu.org) * elflink.h (elf_link_input_bfd): Revert the last change since diff --git a/bfd/elf.c b/bfd/elf.c index 020771bcbc0..3cc0dd5f18b 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -5113,7 +5113,9 @@ _bfd_elf_get_symtab_upper_bound (abfd) Elf_Internal_Shdr *hdr = &elf_tdata (abfd)->symtab_hdr; symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym; - symtab_size = (symcount - 1 + 1) * (sizeof (asymbol *)); + symtab_size = (symcount + 1) * (sizeof (asymbol *)); + if (symcount > 0) + symtab_size -= sizeof (asymbol *); return symtab_size; } @@ -5133,7 +5135,9 @@ _bfd_elf_get_dynamic_symtab_upper_bound (abfd) } symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym; - symtab_size = (symcount - 1 + 1) * (sizeof (asymbol *)); + symtab_size = (symcount + 1) * (sizeof (asymbol *)); + if (symcount > 0) + symtab_size -= sizeof (asymbol *); return symtab_size; }