mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-23 19:50:13 +08:00
Don't treat .opd section specially when ELFv2
Fixes a gdb segfault if a section named .opd is found in ELFv2 binaries. * elf64-ppc.c (synthetic_opd): New static var. (compare_symbols): Don't treat symbols in .opd specially for ELFv2. (ppc64_elf_get_synthetic_symtab): Likewise. Comment.
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2016-09-01 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* elf64-ppc.c (synthetic_opd): New static var.
|
||||||
|
(compare_symbols): Don't treat symbols in .opd specially for ELFv2.
|
||||||
|
(ppc64_elf_get_synthetic_symtab): Likewise. Comment.
|
||||||
|
|
||||||
2016-08-31 Alan Modra <amodra@gmail.com>
|
2016-08-31 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* elf64-ppc.c (group_sections): Delete stub14_group_size. Instead,
|
* elf64-ppc.c (group_sections): Delete stub14_group_size. Instead,
|
||||||
|
@ -3085,6 +3085,7 @@ get_opd_info (asection * sec)
|
|||||||
|
|
||||||
/* Parameters for the qsort hook. */
|
/* Parameters for the qsort hook. */
|
||||||
static bfd_boolean synthetic_relocatable;
|
static bfd_boolean synthetic_relocatable;
|
||||||
|
static asection *synthetic_opd;
|
||||||
|
|
||||||
/* qsort comparison function for ppc64_elf_get_synthetic_symtab. */
|
/* qsort comparison function for ppc64_elf_get_synthetic_symtab. */
|
||||||
|
|
||||||
@ -3101,12 +3102,15 @@ compare_symbols (const void *ap, const void *bp)
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* then .opd symbols. */
|
/* then .opd symbols. */
|
||||||
if (strcmp (a->section->name, ".opd") == 0
|
if (synthetic_opd != NULL)
|
||||||
&& strcmp (b->section->name, ".opd") != 0)
|
{
|
||||||
return -1;
|
if (strcmp (a->section->name, ".opd") == 0
|
||||||
if (strcmp (a->section->name, ".opd") != 0
|
&& strcmp (b->section->name, ".opd") != 0)
|
||||||
&& strcmp (b->section->name, ".opd") == 0)
|
return -1;
|
||||||
return 1;
|
if (strcmp (a->section->name, ".opd") != 0
|
||||||
|
&& strcmp (b->section->name, ".opd") == 0)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* then other code symbols. */
|
/* then other code symbols. */
|
||||||
if ((a->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL))
|
if ((a->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL))
|
||||||
@ -3265,6 +3269,7 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
|
|||||||
memcpy (syms, static_syms, (symcount + 1) * sizeof (*syms));
|
memcpy (syms, static_syms, (symcount + 1) * sizeof (*syms));
|
||||||
|
|
||||||
synthetic_relocatable = relocatable;
|
synthetic_relocatable = relocatable;
|
||||||
|
synthetic_opd = opd;
|
||||||
qsort (syms, symcount, sizeof (*syms), compare_symbols);
|
qsort (syms, symcount, sizeof (*syms), compare_symbols);
|
||||||
|
|
||||||
if (!relocatable && symcount > 1)
|
if (!relocatable && symcount > 1)
|
||||||
@ -3281,7 +3286,11 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
if (strcmp (syms[i]->section->name, ".opd") == 0)
|
/* Note that here and in compare_symbols we can't compare opd and
|
||||||
|
sym->section directly. With separate debug info files, the
|
||||||
|
symbols will be extracted from the debug file while abfd passed
|
||||||
|
to this function is the real binary. */
|
||||||
|
if (opd != NULL && strcmp (syms[i]->section->name, ".opd") == 0)
|
||||||
++i;
|
++i;
|
||||||
codesecsym = i;
|
codesecsym = i;
|
||||||
|
|
||||||
@ -3297,9 +3306,10 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
|
|||||||
break;
|
break;
|
||||||
secsymend = i;
|
secsymend = i;
|
||||||
|
|
||||||
for (; i < symcount; ++i)
|
if (opd != NULL)
|
||||||
if (strcmp (syms[i]->section->name, ".opd") != 0)
|
for (; i < symcount; ++i)
|
||||||
break;
|
if (strcmp (syms[i]->section->name, ".opd") != 0)
|
||||||
|
break;
|
||||||
opdsymend = i;
|
opdsymend = i;
|
||||||
|
|
||||||
for (; i < symcount; ++i)
|
for (; i < symcount; ++i)
|
||||||
|
Reference in New Issue
Block a user