[3/3, ppc64, bfd patch] eu-strip vs. func addresses for GDB inferior calls
by Jan Kratochvil
Hi,
the bfd part.
The patch has been regression tested on:
powerpc-eabisim powerpc-eabispe powerpc-elf powerpc-ibm-aix4.3.3.0
powerpc-linux-gnu powerpc-nto powerpc-wrs-vxworks powerpc64-linux-gnu
ppc-linux rs6000-aix4.3.3
Thanks,
Jan
bfd/
2011-03-23 Jan Kratochvil <jan.kratochvil(a)redhat.com>
* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Do not check for
SEC_LOAD.
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -3317,8 +3317,9 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
{
if (sec->vma > ent)
break;
- if ((sec->flags & SEC_ALLOC) == 0
- || (sec->flags & SEC_LOAD) == 0)
+ /* SEC_LOAD may not be set if ABFD is a separate debug info
+ file. */
+ if ((sec->flags & SEC_ALLOC) == 0)
break;
if ((sec->flags & SEC_CODE) != 0)
s->section = sec;
13 years, 1 month
[1/3, ppc64, gdb FYI testcase] eu-strip vs. func addresses for GDB inferior calls
by Jan Kratochvil
Hi,
this is IMO an elfutils + bfd bug affecting GDB but not a GDB bug.
Contrary to binutils --strip-debug/--only-keep-debug the strip command from
elfutils (eu-strip) moves even the .symtab section into the .debug file.
If you pass address of an inferior function to a different inferior function it
will fail if the inferior has separate debug info file from current eu-strip.
That is GDB convert_code_addr_to_desc_addr will fail on these, passing the code
address instead of the function descriptor, jumping to a garbage address.
(gdb) ptype callfunc
type = int (int (*)(void))
(gdb) ptype func
type = int (void)
before the fix:
(gdb) p callfunc (func)
Program received signal SIGSEGV, Segmentation fault.
0xfbe1fff8f821ffc0 in ?? ()
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on".
Evaluation of the expression containing the function
(callfunc) will be abandoned.
When the function is done executing, GDB will silently stop.
(gdb) FAIL: gdb.base/eu-strip-infcall.exp: infcall
after the fix:
(gdb) p callfunc (func)
$1 = 2
(gdb) PASS: gdb.base/eu-strip-infcall.exp: infcall
The elfutils patch reason:
The bfd/elf64-ppc.c line
ent = bfd_get_64 (abfd, contents + syms[i]->value);
fails to read the real address from .opd while it reads the .symtab section in
the .debug file as the .opd section is SHT_NOBITS there. Therefore proposing
to keep an .opd copy both in the main and in the .debug file. While BFD reads
the .debug file it has no real link to the binary file (only GDB has such
link).
The bfd patch reason:
BFD will assign the wrong (.opd instead of expected .text) section for the
code artificial symbol as the .text section is SHT_NOBITS in the .debug file.
GDB will then fail to find the minimal symbol due to the non-matchin section.
Providing a GDB testcase but only FYI as it depends on elfutils so I will keep
it only in the Fedora testsuite.
Thanks,
Jan
gdb/testsuite/
2011-03-23 Jan Kratochvil <jan.kratochvil(a)redhat.com>
* gdb.base/eu-strip-infcall.c: New file.
* gdb.base/eu-strip-infcall.exp: New file.
--- /dev/null
+++ b/gdb/testsuite/gdb.base/eu-strip-infcall.c
@@ -0,0 +1,34 @@
+/* Copyright 2011 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+func (void)
+{
+ return 1;
+}
+
+int
+callfunc (int (*funcp) (void))
+{
+ return funcp () * 2;
+}
+
+int
+main (void)
+{
+ return callfunc (func);
+}
--- /dev/null
+++ b/gdb/testsuite/gdb.base/eu-strip-infcall.exp
@@ -0,0 +1,36 @@
+# Copyright (C) 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set testfile eu-strip-infcall
+set binfile ${objdir}/${subdir}/${testfile}
+
+if {[build_executable ${testfile}.exp $testfile] == -1} {
+ return -1
+}
+
+set test "eu-strip"
+set status [remote_exec build "eu-strip -f ${binfile}.debug $binfile"]
+if {[lindex $status 0] != 0} {
+ untested ${testfile}.exp
+ return 0
+}
+
+clean_restart $testfile
+
+if ![runto_main] {
+ return -1
+}
+
+gdb_test "p callfunc (func)" " = 2" "infcall"
13 years, 1 month
Add support for call_site and entry_value to dwarf.h and readelf
by Mark Wielaard
Hi,
This adds support for the new GNU dwarf extensions call_site
tags and attributes, and entry_value operator. It adds the new
constants to dwarf.h and makes readelf print them out. I haven't
yet thought about how to extend dwarf_getlocation for it.
Patch attached and on the mjw/callsite branch.
After I push this to master I would like to merge master to
the dwarf branch again so known-dwarf.h picks it up and
dwarflint can start recognizing them.
Comments?
Cheers,
Mark
13 years, 1 month
[PATCH] readelf: prevent segfault
by Marek Polacek
Sometimes, e.g. when malformed ELF file, the ebl_dynamic_tag_name()
returns NULL which causes puts() to segfault immediately without
ceremony. Fixed thusly. Tested on x86_64. Ok for trunk?
Signed-off-by: Marek Polacek <mpolacek(a)redhat.com>
---
src/ChangeLog | 4 ++++
src/readelf.c | 6 ++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 6ba890f..66cca15 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2011-03-22 Marek Polacek <mpolacek(a)redhat.com>
+
+ * readelf.c (handle_dynamic): Don't segfault at DT_PLTREL case.
+
2011-03-10 Mark Wielaard <mjw(a)redhat.com>
* elflint.c (check_symtab): Use ebl_check_st_other_bits.
diff --git a/src/readelf.c b/src/readelf.c
index 956d8bd..2e149b2 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -1445,8 +1445,10 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr)
printf ("%" PRId64 "\n", dyn->d_un.d_val);
break;
- case DT_PLTREL:
- puts (ebl_dynamic_tag_name (ebl, dyn->d_un.d_val, NULL, 0));
+ case DT_PLTREL:;
+ const char *tagname = ebl_dynamic_tag_name (ebl, dyn->d_un.d_val,
+ NULL, 0);
+ puts (tagname ?: "???");
break;
case DT_FLAGS:
--
1.7.3.4
13 years, 1 month
[PATCH] ebldynamictagname: fix typo
by Marek Polacek
In libebl/ebldynamictagname.c there should probably be "TLSDESC_GOT" instead of
"TLSDESC_DOT". In elf.h we have #defined DT_TLSDESC_GOT. Patch is available in
branch mpolacek/tlsdesc. Tested on x86_64, ok for trunk?
Marek
13 years, 1 month
Build issues on Freescale P4080
by Kumar Ranjit-B04060
I am facing many build problems while building elfutils-devel. I need this package to build the performance tool "perf".
Please help.
The details about my setup are
Linux p4080 2.6.34.6 #11 SMP Fri Mar 11 14:44:38 IST 2011 ppc unknown
gcc (GCC) 4.5.1
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Regards
Ranjit Kumar
System Performance Analysis Group
Freescale Semiconductors
India
13 years, 1 month
Merged "sane" commits from mjw/dwarf_output to dwarf branch
by Mark Wielaard
Hi,
I merged (or rather cherry-picked) the "sane" commits from my
mjw/dwarf_output branch to the main dwarf branch. The only really weird
bit it the the *info () hack in dwarf_output that should be done in a
simpler/normal way. I intend to put future dwarf_output/compress work
directly on the dwarf branch from now on, unless it clearly is something
larger/experimental.
Cheers,
Mark
13 years, 1 month
Rerequesting dwarf_tag on a die with invalid abbrev code
by Petr Machata
Hi,
this is similar to the fix that I did recently for rerequesting
dwarf_tag for DIE with zero abbrev code, except this time the DIE has
non-zero invalid code. On such a DIE, the following SEGVs libdw:
die = dwarf_offdie (dw, 11, &die_mem);
dwarf_tag (die);
die = dwarf_offdie (dw, 11, &die_mem)
dwarf_tag (die);
The fix and a test case are on pmachata/rerequest-tag.
Thanks,
PM
13 years, 1 month