aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2012-09-04 12:35:35 +0000
committerH.J. Lu <hjl.tools@gmail.com>2012-09-04 12:35:35 +0000
commitc6d8cab4ac5c906937dcd4f884e65fb4d1052381 (patch)
treed74d960050a0d09e810be75ea778383f3b00c622 /bfd/elf.c
parent957564c93015991eee194ef0769a3b64b16a2237 (diff)
downloadgdb-c6d8cab4ac5c906937dcd4f884e65fb4d1052381.zip
gdb-c6d8cab4ac5c906937dcd4f884e65fb4d1052381.tar.gz
gdb-c6d8cab4ac5c906937dcd4f884e65fb4d1052381.tar.bz2
Ignore section symbols without a BFD section
bfd/ PR binutils/14493 * elf.c (ignore_section_sym): Also ignore section symbols without a BFD section. binutils/ PR binutils/14493 * readelf.c (get_symbol_index_type): Check bad section index.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 0208e05..b4043b1 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3264,13 +3264,21 @@ sym_is_global (bfd *abfd, asymbol *sym)
}
/* Don't output section symbols for sections that are not going to be
- output, or that are duplicates. */
+ output, that are duplicates or there is no BFD section. */
static bfd_boolean
ignore_section_sym (bfd *abfd, asymbol *sym)
{
- return ((sym->flags & BSF_SECTION_SYM) != 0
- && !(sym->section->owner == abfd
+ elf_symbol_type *type_ptr;
+
+ if ((sym->flags & BSF_SECTION_SYM) == 0)
+ return FALSE;
+
+ type_ptr = elf_symbol_from (abfd, sym);
+ return ((type_ptr != NULL
+ && type_ptr->internal_elf_sym.st_shndx != 0
+ && bfd_is_abs_section (sym->section))
+ || !(sym->section->owner == abfd
|| (sym->section->output_section->owner == abfd
&& sym->section->output_offset == 0)
|| bfd_is_abs_section (sym->section)));