aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2002-03-27 00:16:54 +0000
committerAlan Modra <amodra@gmail.com>2002-03-27 00:16:54 +0000
commitb99d18333dd47aa5750a26999e683480f16fb1d4 (patch)
tree46790f34e0c420d5e49b87dd69ce6aa5dbcc65e4 /bfd/elf.c
parentcfed07154c9448b8dd40c8994fc2a03a3f7df090 (diff)
downloadgdb-b99d18333dd47aa5750a26999e683480f16fb1d4.zip
gdb-b99d18333dd47aa5750a26999e683480f16fb1d4.tar.gz
gdb-b99d18333dd47aa5750a26999e683480f16fb1d4.tar.bz2
* 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.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 020771b..3cc0dd5 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;
}