aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfcode.h
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2013-11-05 10:14:57 -0800
committerH.J. Lu <hjl.tools@gmail.com>2017-11-26 09:38:09 -0800
commit0860f6373e0df2b8dcece04dd874f95c3f09e3df (patch)
treebefaa35eef79309344391470ce2ecbe28449d50c /bfd/elfcode.h
parent8e2495f2f75120baae14f9dac9d29b043c539b2b (diff)
downloadgdb-users/hjl/pr12639.zip
gdb-users/hjl/pr12639.tar.gz
gdb-users/hjl/pr12639.tar.bz2
Check corrupted symbol tableusers/hjl/pr12639
bfd/ PR binutils/12639 * elfcode.h (elf_slurp_symbol_table): Check corrupted global symbols. binutils/ PR binutils/12639 * readelf.c (process_symbol_table): Detect corrupted symbol table.
Diffstat (limited to 'bfd/elfcode.h')
-rw-r--r--bfd/elfcode.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index 80b26aa..06fd94e 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -1173,6 +1173,9 @@ elf_slurp_symbol_table (bfd *abfd, asymbol **symptrs, bfd_boolean dynamic)
sym = symbase = NULL;
else
{
+ /* Start of global symbols */
+ Elf_Internal_Sym *start_global;
+
isymbuf = bfd_elf_get_elf_syms (abfd, hdr, symcount, 0,
NULL, NULL, NULL);
if (isymbuf == NULL)
@@ -1218,6 +1221,9 @@ elf_slurp_symbol_table (bfd *abfd, asymbol **symptrs, bfd_boolean dynamic)
if (xver != NULL)
++xver;
isymend = isymbuf + symcount;
+ start_global = isymbuf;
+ if (!elf_bad_symtab (abfd))
+ start_global += hdr->sh_info;
for (isym = isymbuf + 1, sym = symbase; isym < isymend; isym++, sym++)
{
memcpy (&sym->internal_elf_sym, isym, sizeof (Elf_Internal_Sym));
@@ -1275,6 +1281,12 @@ elf_slurp_symbol_table (bfd *abfd, asymbol **symptrs, bfd_boolean dynamic)
if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
sym->symbol.value -= sym->symbol.section->vma;
+ if (isym < start_global
+ && ELF_ST_BIND (isym->st_info) != STB_LOCAL)
+ (*_bfd_error_handler)
+ (_("%s: corrupted global symbol `%s' treated as local"),
+ abfd->filename, sym->symbol.name);
+
switch (ELF_ST_BIND (isym->st_info))
{
case STB_LOCAL: