powerpc64 oprofile and objdump -d segfaults
Alan Modra
amodra@bigpond.net.au
Thu May 21 13:48:00 GMT 2009
This fixes a segfault found when attempting to use oprofile or
objdump -d on a recent powerpc64 libstdc++.so. libstdc++.so is
compiled with -ffunction-sections and -fdata-sections, and linked
using --gc-sections. One of the removed functions is
libstdc++-v3/libsupc++/eh_globals.cc get_global (which ought not be
emitted by gcc so I think this is a gcc bug). ld correctly removes
the .opd entry for this function, but the function happens to be
local, and ld currently does not remove local function symbols in this
case, instead giving them a value of zero. Zero is outside the
address range of .opd, so we get a segfault on the bfd_get_64 shown
below.
* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Don't segfault on
out of range .opd symbols.
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.293
diff -u -p -r1.293 elf64-ppc.c
--- bfd/elf64-ppc.c 23 Mar 2009 13:35:46 -0000 1.293
+++ bfd/elf64-ppc.c 21 May 2009 08:28:00 -0000
@@ -3033,6 +3033,10 @@ ppc64_elf_get_synthetic_symtab (bfd *abf
{
bfd_vma ent;
+ /* Ignore bogus symbols. */
+ if (syms[i]->value > opd->size - 8)
+ continue;
+
ent = bfd_get_64 (abfd, contents + syms[i]->value);
if (!sym_exists_at (syms, opdsymend, symcount, -1, ent))
{
@@ -3126,6 +3130,9 @@ ppc64_elf_get_synthetic_symtab (bfd *abf
{
bfd_vma ent;
+ if (syms[i]->value > opd->size - 8)
+ continue;
+
ent = bfd_get_64 (abfd, contents + syms[i]->value);
if (!sym_exists_at (syms, opdsymend, symcount, -1, ent))
{
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list