* elf.c (_bfd_elf_get_symtab_upper_bound): Leave space for
authorAlan Modra <amodra@gmail.com>
Wed, 27 Mar 2002 00:16:54 +0000 (00:16 +0000)
committerAlan Modra <amodra@gmail.com>
Wed, 27 Mar 2002 00:16:54 +0000 (00:16 +0000)
terminating NULL if empty symbol table.
(_bfd_elf_get_dynamic_symtab_upper_bound): Likewise.

bfd/ChangeLog
bfd/elf.c

index b28e9780d7eb534efb2b6c42332610c2373cf86f..c32ee17d48fafbfd7727a5c3d217be4176d4dbdd 100644 (file)
@@ -1,3 +1,9 @@
+2002-03-27  Gregory Steuck <greg@nest.cx>
+
+       * 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
index 020771bcbc0cda7f421950f2e1d31ab75858fa69..3cc0dd5f18b7363dde3eb8d51327e107f9c33920 100644 (file)
--- 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;
 }