[PATCH] gelf_getauxv: Use memcpy instead of pointer dereference to avoid alignment problems.
by Kurt Roeckx
---
libelf/ChangeLog | 5 +++++
libelf/gelf_getauxv.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 674a720..46d4731 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,8 @@
+2013-08-25 Kurt Roeckx <kurt(a)roeckx.be>
+
+ * gelf_getauxv.c (gelf_getauxv): Use memcpy instead of pointer
+ dereference to avoid alignment problems.
+
2013-01-07 Roland McGrath <roland(a)hack.frob.com>
* elf_getarsym.c (elf_getarsym): Copy FILE_DATA into stack space if it
diff --git a/libelf/gelf_getauxv.c b/libelf/gelf_getauxv.c
index d87362e..be24667 100644
--- a/libelf/gelf_getauxv.c
+++ b/libelf/gelf_getauxv.c
@@ -97,7 +97,7 @@ gelf_getauxv (data, ndx, dst)
goto out;
}
- *dst = ((GElf_auxv_t *) data_scn->d.d_buf)[ndx];
+ memcpy(dst, &((GElf_auxv_t *) data_scn->d.d_buf)[ndx], sizeof(*dst));
}
result = dst;
--
1.7.10.4
10 years, 3 months
[PATCH] tests: Add run-addrcfi.sh test for libdw cfi dwarf_frame_* functions.
by Mark Wielaard
We require architecture backends to implement the ebl abi_cfi hook
to provide the ABI's default CFI program as used by the libdw dwarf cfi
functions. There is the addrcfi test program that prints the return
address, cfa location expression and register states as returned by
various dwarf_cfi_* and dwarf_frame functions. But that has to be run
by hand. The new run-addrcfi.sh tests hooks addrcfi up to some existing
architecture specific test files and known addresses to more easily
(and automaticly) check that the default CFI program is implemented
correctly and to test the libdw cfi frame info functionality.
Only i386 and x86_64 are tested for now since other backends don't have
the abi_cfi hook yet.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
tests/ChangeLog | 8 ++
tests/Makefile.am | 4 +-
tests/addrcfi.c | 23 ++++-
tests/run-addrcfi.sh | 260 ++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 291 insertions(+), 4 deletions(-)
create mode 100755 tests/run-addrcfi.sh
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 9808ce7..487bd2c 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,11 @@
+2013-08-27 Mark Wielaard <mjw(a)redhat.com>
+
+ * run-addrcfi.sh: New test.
+ * Makefile.am (TESTS): Add run-addrcfi.sh.
+ (EXTRA_DIST): Likewise.
+ * addrcfi.c (op_name): New function.
+ (print_detail): Call and print op_name.
+
2013-08-13 Mark Wielaard <mjw(a)redhat.com>
* run-addr2line-i-test.sh: New test.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9aa06a6..c85b749 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -70,7 +70,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
run-elflint-test.sh run-elflint-self.sh run-ranlib-test.sh \
run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \
run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \
- run-find-prologues.sh run-allregs.sh \
+ run-find-prologues.sh run-allregs.sh run-addrcfi.sh \
run-nm-self.sh run-readelf-self.sh \
run-readelf-test1.sh run-readelf-test2.sh run-readelf-test3.sh \
run-readelf-test4.sh run-readelf-twofiles.sh \
@@ -128,7 +128,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
run-elflint-self.sh run-ranlib-test.sh run-ranlib-test2.sh \
run-ranlib-test3.sh run-ranlib-test4.sh \
run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \
- run-nm-self.sh run-readelf-self.sh \
+ run-nm-self.sh run-readelf-self.sh run-addrcfi.sh \
run-find-prologues.sh run-allregs.sh run-native-test.sh \
run-addrname-test.sh run-dwfl-bug-offline-rel.sh \
run-dwfl-addr-sect.sh run-early-offscn.sh \
diff --git a/tests/addrcfi.c b/tests/addrcfi.c
index bc8bc32..de65f4e 100644
--- a/tests/addrcfi.c
+++ b/tests/addrcfi.c
@@ -1,5 +1,5 @@
/* Test program for CFI handling.
- Copyright (C) 2009-2010 Red Hat, Inc.
+ Copyright (C) 2009-2010, 2013 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -28,6 +28,25 @@
#include <error.h>
#include <string.h>
+#include "../libdw/known-dwarf.h"
+
+static const char *
+op_name (unsigned int code)
+{
+ static const char *const known[] =
+ {
+#define ONE_KNOWN_DW_OP_DESC(NAME, CODE, DESC) ONE_KNOWN_DW_OP (NAME, CODE)
+#define ONE_KNOWN_DW_OP(NAME, CODE) [CODE] = #NAME,
+ ALL_KNOWN_DW_OP
+#undef ONE_KNOWN_DW_OP
+#undef ONE_KNOWN_DW_OP_DESC
+ };
+
+ if (likely (code < sizeof (known) / sizeof (known[0])))
+ return known[code];
+
+ return NULL;
+}
static void
print_detail (int result, const Dwarf_Op *ops, size_t nops, Dwarf_Addr bias)
@@ -41,7 +60,7 @@ print_detail (int result, const Dwarf_Op *ops, size_t nops, Dwarf_Addr bias)
printf ("%s expression:", result == 0 ? "location" : "value");
for (size_t i = 0; i < nops; ++i)
{
- printf (" %#x", ops[i].atom);
+ printf (" %s", op_name(ops[i].atom));
if (ops[i].number2 == 0)
{
if (ops[i].atom == DW_OP_addr)
diff --git a/tests/run-addrcfi.sh b/tests/run-addrcfi.sh
new file mode 100755
index 0000000..1b3b993
--- /dev/null
+++ b/tests/run-addrcfi.sh
@@ -0,0 +1,260 @@
+#! /bin/sh
+# Copyright (C) 2013
+# This file is part of elfutils.
+#
+# This file 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.
+#
+# elfutils 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/>.
+
+. $srcdir/test-subr.sh
+
+# Note some testfiles are also used in run-allregs.sh.
+
+# Shows return address, CFA location expression and register rules
+# from ABI's default CFI program as setup by arch ebl backend hook
+# abi_cfi unless overridden by CIE and FDE program at given address.
+
+# EM_386 (function main 0x080489b8)
+testfiles testfile11
+testrun_compare ${abs_builddir}/addrcfi -e testfile11 0x080489b8 <<\EOF
+.eh_frame has 0x80489b8 => [0x80489b8, 0x80489b9):
+ return address in reg8
+ CFA location expression: bregx(4,4)
+ integer reg0 (%eax): same_value
+ integer reg1 (%ecx): same_value
+ integer reg2 (%edx): same_value
+ integer reg3 (%ebx): same_value
+ integer reg4 (%esp): location expression: call_frame_cfa stack_value
+ integer reg5 (%ebp): same_value
+ integer reg6 (%esi): same_value
+ integer reg7 (%edi): same_value
+ integer reg8 (%eip): location expression: call_frame_cfa plus_uconst(-4)
+ integer reg9 (%eflags): same_value
+ integer reg10 (%trapno): same_value
+ x87 reg11 (%st0): same_value
+ x87 reg12 (%st1): same_value
+ x87 reg13 (%st2): same_value
+ x87 reg14 (%st3): same_value
+ x87 reg15 (%st4): same_value
+ x87 reg16 (%st5): same_value
+ x87 reg17 (%st6): same_value
+ x87 reg18 (%st7): same_value
+ SSE reg21 (%xmm0): same_value
+ SSE reg22 (%xmm1): same_value
+ SSE reg23 (%xmm2): same_value
+ SSE reg24 (%xmm3): same_value
+ SSE reg25 (%xmm4): same_value
+ SSE reg26 (%xmm5): same_value
+ SSE reg27 (%xmm6): same_value
+ SSE reg28 (%xmm7): same_value
+ MMX reg29 (%mm0): same_value
+ MMX reg30 (%mm1): same_value
+ MMX reg31 (%mm2): same_value
+ MMX reg32 (%mm3): same_value
+ MMX reg33 (%mm4): same_value
+ MMX reg34 (%mm5): same_value
+ MMX reg35 (%mm6): same_value
+ MMX reg36 (%mm7): same_value
+ FPU-control reg37 (%fctrl): same_value
+ FPU-control reg38 (%fstat): same_value
+ FPU-control reg39 (%mxcsr): same_value
+ segment reg40 (%es): same_value
+ segment reg41 (%cs): same_value
+ segment reg42 (%ss): same_value
+ segment reg43 (%ds): same_value
+ segment reg44 (%fs): same_value
+ segment reg45 (%gs): same_value
+.debug_frame has 0x80489b8 => [0x80489b8, 0x80489b9):
+ return address in reg8
+ CFA location expression: bregx(4,4)
+ integer reg0 (%eax): same_value
+ integer reg1 (%ecx): same_value
+ integer reg2 (%edx): same_value
+ integer reg3 (%ebx): same_value
+ integer reg4 (%esp): location expression: call_frame_cfa stack_value
+ integer reg5 (%ebp): same_value
+ integer reg6 (%esi): same_value
+ integer reg7 (%edi): same_value
+ integer reg8 (%eip): location expression: call_frame_cfa plus_uconst(-4)
+ integer reg9 (%eflags): same_value
+ integer reg10 (%trapno): same_value
+ x87 reg11 (%st0): same_value
+ x87 reg12 (%st1): same_value
+ x87 reg13 (%st2): same_value
+ x87 reg14 (%st3): same_value
+ x87 reg15 (%st4): same_value
+ x87 reg16 (%st5): same_value
+ x87 reg17 (%st6): same_value
+ x87 reg18 (%st7): same_value
+ SSE reg21 (%xmm0): same_value
+ SSE reg22 (%xmm1): same_value
+ SSE reg23 (%xmm2): same_value
+ SSE reg24 (%xmm3): same_value
+ SSE reg25 (%xmm4): same_value
+ SSE reg26 (%xmm5): same_value
+ SSE reg27 (%xmm6): same_value
+ SSE reg28 (%xmm7): same_value
+ MMX reg29 (%mm0): same_value
+ MMX reg30 (%mm1): same_value
+ MMX reg31 (%mm2): same_value
+ MMX reg32 (%mm3): same_value
+ MMX reg33 (%mm4): same_value
+ MMX reg34 (%mm5): same_value
+ MMX reg35 (%mm6): same_value
+ MMX reg36 (%mm7): same_value
+ FPU-control reg37 (%fctrl): same_value
+ FPU-control reg38 (%fstat): same_value
+ FPU-control reg39 (%mxcsr): same_value
+ segment reg40 (%es): same_value
+ segment reg41 (%cs): same_value
+ segment reg42 (%ss): same_value
+ segment reg43 (%ds): same_value
+ segment reg44 (%fs): same_value
+ segment reg45 (%gs): same_value
+EOF
+
+# EM_X86_64 (function foo 0x00000000000009d0)
+testfiles testfile12
+testrun_compare ${abs_builddir}/addrcfi -e testfile12 0x00000000000009d0 <<\EOF
+.eh_frame has 0x9d0 => [0x9d0, 0x9d1):
+ return address in reg16
+ CFA location expression: bregx(7,8)
+ integer reg0 (%rax): same_value
+ integer reg1 (%rdx): same_value
+ integer reg2 (%rcx): same_value
+ integer reg3 (%rbx): same_value
+ integer reg4 (%rsi): same_value
+ integer reg5 (%rdi): same_value
+ integer reg6 (%rbp): same_value
+ integer reg7 (%rsp): location expression: call_frame_cfa stack_value
+ integer reg8 (%r8): same_value
+ integer reg9 (%r9): same_value
+ integer reg10 (%r10): same_value
+ integer reg11 (%r11): same_value
+ integer reg12 (%r12): same_value
+ integer reg13 (%r13): same_value
+ integer reg14 (%r14): same_value
+ integer reg15 (%r15): same_value
+ integer reg16 (%rip): location expression: call_frame_cfa plus_uconst(-8)
+ SSE reg17 (%xmm0): same_value
+ SSE reg18 (%xmm1): same_value
+ SSE reg19 (%xmm2): same_value
+ SSE reg20 (%xmm3): same_value
+ SSE reg21 (%xmm4): same_value
+ SSE reg22 (%xmm5): same_value
+ SSE reg23 (%xmm6): same_value
+ SSE reg24 (%xmm7): same_value
+ SSE reg25 (%xmm8): same_value
+ SSE reg26 (%xmm9): same_value
+ SSE reg27 (%xmm10): same_value
+ SSE reg28 (%xmm11): same_value
+ SSE reg29 (%xmm12): same_value
+ SSE reg30 (%xmm13): same_value
+ SSE reg31 (%xmm14): same_value
+ SSE reg32 (%xmm15): same_value
+ x87 reg33 (%st0): same_value
+ x87 reg34 (%st1): same_value
+ x87 reg35 (%st2): same_value
+ x87 reg36 (%st3): same_value
+ x87 reg37 (%st4): same_value
+ x87 reg38 (%st5): same_value
+ x87 reg39 (%st6): same_value
+ x87 reg40 (%st7): same_value
+ MMX reg41 (%mm0): same_value
+ MMX reg42 (%mm1): same_value
+ MMX reg43 (%mm2): same_value
+ MMX reg44 (%mm3): same_value
+ MMX reg45 (%mm4): same_value
+ MMX reg46 (%mm5): same_value
+ MMX reg47 (%mm6): same_value
+ MMX reg48 (%mm7): same_value
+ integer reg49 (%rflags): same_value
+ segment reg50 (%es): same_value
+ segment reg51 (%cs): same_value
+ segment reg52 (%ss): same_value
+ segment reg53 (%ds): same_value
+ segment reg54 (%fs): same_value
+ segment reg55 (%gs): same_value
+ segment reg58 (%fs.base): same_value
+ segment reg59 (%gs.base): same_value
+ control reg62 (%tr): same_value
+ control reg63 (%ldtr): same_value
+ control reg64 (%mxcsr): same_value
+ control reg65 (%fcw): same_value
+ control reg66 (%fsw): same_value
+.debug_frame has 0x9d0 => [0x9d0, 0x9d1):
+ return address in reg16
+ CFA location expression: bregx(7,8)
+ integer reg0 (%rax): same_value
+ integer reg1 (%rdx): same_value
+ integer reg2 (%rcx): same_value
+ integer reg3 (%rbx): same_value
+ integer reg4 (%rsi): same_value
+ integer reg5 (%rdi): same_value
+ integer reg6 (%rbp): same_value
+ integer reg7 (%rsp): location expression: call_frame_cfa stack_value
+ integer reg8 (%r8): same_value
+ integer reg9 (%r9): same_value
+ integer reg10 (%r10): same_value
+ integer reg11 (%r11): same_value
+ integer reg12 (%r12): same_value
+ integer reg13 (%r13): same_value
+ integer reg14 (%r14): same_value
+ integer reg15 (%r15): same_value
+ integer reg16 (%rip): location expression: call_frame_cfa plus_uconst(-8)
+ SSE reg17 (%xmm0): same_value
+ SSE reg18 (%xmm1): same_value
+ SSE reg19 (%xmm2): same_value
+ SSE reg20 (%xmm3): same_value
+ SSE reg21 (%xmm4): same_value
+ SSE reg22 (%xmm5): same_value
+ SSE reg23 (%xmm6): same_value
+ SSE reg24 (%xmm7): same_value
+ SSE reg25 (%xmm8): same_value
+ SSE reg26 (%xmm9): same_value
+ SSE reg27 (%xmm10): same_value
+ SSE reg28 (%xmm11): same_value
+ SSE reg29 (%xmm12): same_value
+ SSE reg30 (%xmm13): same_value
+ SSE reg31 (%xmm14): same_value
+ SSE reg32 (%xmm15): same_value
+ x87 reg33 (%st0): same_value
+ x87 reg34 (%st1): same_value
+ x87 reg35 (%st2): same_value
+ x87 reg36 (%st3): same_value
+ x87 reg37 (%st4): same_value
+ x87 reg38 (%st5): same_value
+ x87 reg39 (%st6): same_value
+ x87 reg40 (%st7): same_value
+ MMX reg41 (%mm0): same_value
+ MMX reg42 (%mm1): same_value
+ MMX reg43 (%mm2): same_value
+ MMX reg44 (%mm3): same_value
+ MMX reg45 (%mm4): same_value
+ MMX reg46 (%mm5): same_value
+ MMX reg47 (%mm6): same_value
+ MMX reg48 (%mm7): same_value
+ integer reg49 (%rflags): same_value
+ segment reg50 (%es): same_value
+ segment reg51 (%cs): same_value
+ segment reg52 (%ss): same_value
+ segment reg53 (%ds): same_value
+ segment reg54 (%fs): same_value
+ segment reg55 (%gs): same_value
+ segment reg58 (%fs.base): same_value
+ segment reg59 (%gs.base): same_value
+ control reg62 (%tr): same_value
+ control reg63 (%ldtr): same_value
+ control reg64 (%mxcsr): same_value
+ control reg65 (%fcw): same_value
+ control reg66 (%fsw): same_value
+EOF
--
1.7.1
10 years, 3 months
[PATCH] libdwfl/linux-kernel-modules.c (report_kernel): Pass add_p_vaddr as true.
by Mark Wielaard
On some architectures (e.g. x86_64) the vmlinux is ET_EXEC, while on
others (e.g. ppc64) it is ET_DYN. In both cases the phdr p_vaddr will
be non-zero. We want the image to be placed as if it was ET_DYN, so
pass true for add_p_vaddr which will do the right thing (in combination
with a zero base) in either case.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
libdwfl/ChangeLog | 5 +++++
libdwfl/linux-kernel-modules.c | 8 +++++++-
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 88bdfc6..90ba686 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2013-08-25 Mark Wielaard <mjw(a)redhat.com>
+
+ * linux-kernel-modules.c (report_kernel): Pass add_p_vaddr as true
+ to dwfl_report_elf.
+
2013-07-25 Jan Kratochvil <jan.kratochvil(a)redhat.com>
* dwfl_segment_report_module.c (dwfl_segment_report_module): Check for
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
index dec1a59..fe01028 100644
--- a/libdwfl/linux-kernel-modules.c
+++ b/libdwfl/linux-kernel-modules.c
@@ -216,8 +216,14 @@ report_kernel (Dwfl *dwfl, const char **release,
if (report)
{
+ /* Note that on some architectures (e.g. x86_64) the vmlinux
+ is ET_EXEC, while on others (e.g. ppc64) it is ET_DYN.
+ In both cases the phdr p_vaddr load address will be non-zero.
+ We want the image to be placed as if it was ET_DYN, so
+ pass true for add_p_vaddr which will do the right thing
+ (in combination with a zero base) in either case. */
Dwfl_Module *mod = INTUSE(dwfl_report_elf) (dwfl, KERNEL_MODNAME,
- fname, fd, 0, false);
+ fname, fd, 0, true);
if (mod == NULL)
result = -1;
else
--
1.7.1
10 years, 3 months
[Committed] CONTRIBUTING: Fix typo.
by Mark Wielaard
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
CONTRIBUTING | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/CONTRIBUTING b/CONTRIBUTING
index 2a3859a..3f5e5aa 100644
--- a/CONTRIBUTING
+++ b/CONTRIBUTING
@@ -44,5 +44,5 @@ Signed-off-by: Random J Developer <random(a)developer.example.org>
using your real name (sorry, no pseudonyms or anonymous contributions.)
-git commit --signoff will add such a Signed-off-by line by at the end of
+git commit --signoff will add such a Signed-off-by line at the end of
the commit log message for you.
--
1.7.1
10 years, 3 months
[PATCH] addr2line: Support -i, --inlines output option.
by Mark Wielaard
Show all source locations that caused inline expansion of subroutines
at the given address. This can easily be supported by using libdw
dwarf_getscopes_die which will give all nested inlined subroutines.
When -f, --functions is given also show the function names where the
subroutines were inlines.
The output matches that of binutils addr2line --inlines.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
src/ChangeLog | 9 +++
src/addr2line.c | 140 ++++++++++++++++++++++++++++++++++------
tests/ChangeLog | 8 ++
tests/Makefile.am | 6 +-
tests/run-addr2line-i-test.sh | 145 +++++++++++++++++++++++++++++++++++++++++
tests/testfile-inlines.bz2 | Bin 0 -> 2815 bytes
6 files changed, 286 insertions(+), 22 deletions(-)
create mode 100755 tests/run-addr2line-i-test.sh
create mode 100755 tests/testfile-inlines.bz2
diff --git a/src/ChangeLog b/src/ChangeLog
index eacadbc..6788087 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
+2013-08-13 Mark Wielaard <mjw(a)redhat.com>
+
+ * addr2line.c (options): Add "inlines", 'i'.
+ (show_inlines): New bool.
+ (parse_opt): Handle 'i'.
+ (print_diesym): New static function.
+ (print_src): New function taking code from...
+ (handle_address): here. Call print_src. Print inlines.
+
2013-08-12 Mark Wielaard <mjw(a)redhat.com>
* addr2line.c (main): If there is a newline char at end of buf,
diff --git a/src/addr2line.c b/src/addr2line.c
index f2bc325..82e80b1 100644
--- a/src/addr2line.c
+++ b/src/addr2line.c
@@ -1,5 +1,5 @@
/* Locate source files and line information for given addresses
- Copyright (C) 2005-2010, 2012 Red Hat, Inc.
+ Copyright (C) 2005-2010, 2012, 2013 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper(a)redhat.com>, 2005.
@@ -64,6 +64,9 @@ static const struct argp_option options[] =
{ "flags", 'F', NULL, 0, N_("Also show line table flags"), 0 },
{ "section", 'j', "NAME", 0,
N_("Treat addresses as offsets relative to NAME section."), 0 },
+ { "inlines", 'i', NULL, 0,
+ N_("Show all source locations that caused inline expansion of subroutines at the address."),
+ 0 },
{ NULL, 0, NULL, 0, N_("Miscellaneous:"), 0 },
/* Unsupported options. */
@@ -114,6 +117,9 @@ static bool show_symbols;
/* If non-null, take address parameters as relative to named section. */
static const char *just_section;
+/* True if all inlined subroutines of the current address should be shown. */
+static bool show_inlines;
+
int
main (int argc, char *argv[])
@@ -232,6 +238,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
just_section = arg;
break;
+ case 'i':
+ show_inlines = true;
+ break;
+
default:
return ARGP_ERR_UNKNOWN;
}
@@ -351,6 +361,23 @@ print_addrsym (Dwfl_Module *mod, GElf_Addr addr)
printf ("%s+%#" PRIx64 "\n", name, addr - s.st_value);
}
+static void
+print_diesym (Dwarf_Die *die)
+{
+ Dwarf_Attribute attr;
+ const char *name;
+
+ name = dwarf_formstring (dwarf_attr_integrate (die, DW_AT_MIPS_linkage_name,
+ &attr)
+ ?: dwarf_attr_integrate (die, DW_AT_linkage_name,
+ &attr));
+
+ if (name == NULL)
+ name = dwarf_diename (die) ?: "??";
+
+ puts (name);
+}
+
static int
see_one_module (Dwfl_Module *mod,
void **userdata __attribute__ ((unused)),
@@ -442,6 +469,30 @@ adjust_to_section (const char *name, uintmax_t *addr, Dwfl *dwfl)
return false;
}
+static void
+print_src (const char *src, int lineno, int linecol, Dwarf_Die *cu)
+{
+ const char *comp_dir = "";
+ const char *comp_dir_sep = "";
+
+ if (only_basenames)
+ src = basename (src);
+ else if (use_comp_dir && src[0] != '/')
+ {
+ Dwarf_Attribute attr;
+ comp_dir = dwarf_formstring (dwarf_attr (cu, DW_AT_comp_dir, &attr));
+ if (comp_dir != NULL)
+ comp_dir_sep = "/";
+ }
+
+ if (linecol != 0)
+ printf ("%s%s%s:%d:%d",
+ comp_dir, comp_dir_sep, src, lineno, linecol);
+ else
+ printf ("%s%s%s:%d",
+ comp_dir, comp_dir_sep, src, lineno);
+}
+
static int
handle_address (const char *string, Dwfl *dwfl)
{
@@ -510,28 +561,11 @@ handle_address (const char *string, Dwfl *dwfl)
const char *src;
int lineno, linecol;
+
if (line != NULL && (src = dwfl_lineinfo (line, &addr, &lineno, &linecol,
NULL, NULL)) != NULL)
{
- const char *comp_dir = "";
- const char *comp_dir_sep = "";
-
- if (only_basenames)
- src = basename (src);
- else if (use_comp_dir && src[0] != '/')
- {
- comp_dir = dwfl_line_comp_dir (line);
- if (comp_dir != NULL)
- comp_dir_sep = "/";
- }
-
- if (linecol != 0)
- printf ("%s%s%s:%d:%d",
- comp_dir, comp_dir_sep, src, lineno, linecol);
- else
- printf ("%s%s%s:%d",
- comp_dir, comp_dir_sep, src, lineno);
-
+ print_src (src, lineno, linecol, dwfl_linecu (line));
if (show_flags)
{
Dwarf_Addr bias;
@@ -565,6 +599,72 @@ handle_address (const char *string, Dwfl *dwfl)
else
puts ("??:0");
+ if (show_inlines)
+ {
+ Dwarf_Addr bias = 0;
+ Dwarf_Die *cudie = dwfl_module_addrdie (mod, addr, &bias);
+
+ Dwarf_Die *scopes;
+ int nscopes = dwarf_getscopes (cudie, addr - bias, &scopes);
+ if (nscopes < 0)
+ return 1;
+
+ if (nscopes > 0)
+ {
+ Dwarf_Die subroutine;
+ Dwarf_Off dieoff = dwarf_dieoffset (&scopes[0]);
+ dwarf_offdie (dwfl_module_getdwarf (mod, &bias),
+ dieoff, &subroutine);
+ free (scopes);
+
+ nscopes = dwarf_getscopes_die (&subroutine, &scopes);
+ if (nscopes > 1)
+ {
+ Dwarf_Die cu;
+ Dwarf_Files *files;
+ if (dwarf_diecu (&scopes[0], &cu, NULL, NULL) != NULL
+ && dwarf_getsrcfiles (cudie, &files, NULL) == 0)
+ {
+ for (int i = 0; i < nscopes - 1; i++)
+ {
+ Dwarf_Word val;
+ Dwarf_Attribute attr;
+ Dwarf_Die *die = &scopes[i];
+ if (dwarf_tag (die) != DW_TAG_inlined_subroutine)
+ continue;
+
+ if (show_functions)
+ print_diesym (&scopes[i + 1]);
+
+ src = NULL;
+ lineno = 0;
+ linecol = 0;
+ if (dwarf_formudata (dwarf_attr (die, DW_AT_call_file,
+ &attr), &val) == 0)
+ src = dwarf_filesrc (files, val, NULL, NULL);
+
+ if (dwarf_formudata (dwarf_attr (die, DW_AT_call_line,
+ &attr), &val) == 0)
+ lineno = val;
+
+ if (dwarf_formudata (dwarf_attr (die, DW_AT_call_column,
+ &attr), &val) == 0)
+ linecol = val;
+
+ if (src != NULL)
+ {
+ print_src (src, lineno, linecol, &cu);
+ putchar ('\n');
+ }
+ else
+ puts ("??:0");
+ }
+ }
+ }
+ }
+ free (scopes);
+ }
+
return 0;
}
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 3475d7b..9808ce7 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,11 @@
+2013-08-13 Mark Wielaard <mjw(a)redhat.com>
+
+ * run-addr2line-i-test.sh: New test.
+ * testfile-inlines.bz2: New testfile.
+ * Makefile.am (EXTRA_DIST): Add run-addr2line-i-test.sh and
+ testfile-inlines.bz2.
+ (TESTS): Add run-addr2line-i-test.sh.
+
2013-08-12 Mark Wielaard <mjw(a)redhat.com>
* run-addr2line-test.sh: New test.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ac99e3e..9aa06a6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -88,7 +88,8 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
run-low_high_pc.sh run-macro-test.sh run-elf_cntl_gelf_getshdr.sh \
run-test-archive64.sh run-readelf-vmcoreinfo.sh \
run-readelf-mixed-corenote.sh run-dwfllines.sh \
- run-dwfl-report-elf-align.sh run-addr2line-test.sh
+ run-dwfl-report-elf-align.sh run-addr2line-test.sh \
+ run-addr2line-i-test.sh
if !STANDALONE
check_PROGRAMS += msg_tst md5-sha1-test
@@ -200,7 +201,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
run-dwfllines.sh run-dwfl-report-elf-align.sh \
testfile-dwfl-report-elf-align-shlib.so.bz2 \
testfilenolines.bz2 test-core-lib.so.bz2 test-core.core.bz2 \
- test-core.exec.bz2 run-addr2line-test.sh
+ test-core.exec.bz2 run-addr2line-test.sh \
+ run-addr2line-i-test.sh testfile-inlines.bz2
if USE_VALGRIND
valgrind_cmd='valgrind -q --trace-children=yes --error-exitcode=1 --run-libc-freeres=no'
diff --git a/tests/run-addr2line-i-test.sh b/tests/run-addr2line-i-test.sh
new file mode 100755
index 0000000..e98adda
--- /dev/null
+++ b/tests/run-addr2line-i-test.sh
@@ -0,0 +1,145 @@
+#! /bin/sh
+# Copyright (C) 2013 Red Hat, Inc.
+# This file is part of elfutils.
+#
+# This file 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.
+#
+# elfutils 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/>.
+
+. $srcdir/test-subr.sh
+
+# // g++ x.cpp -g -fPIC -olibx.so -shared -O3 -fvisibility=hidden
+#
+# void foobar()
+# {
+# __asm__ ( "nop" ::: );
+# }
+#
+# void fubar()
+# {
+# __asm__ ( "nop" ::: );
+# }
+#
+# void bar()
+# {
+# foobar();
+# }
+#
+# void baz()
+# {
+# fubar();
+# }
+#
+# void foo()
+# {
+# bar();
+# baz();
+# }
+#
+# void fu()
+# {
+# __asm__ ( "nop" ::: );
+# fubar();
+# foobar();
+# }
+
+testfiles testfile-inlines
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005a0 <<\EOF
+/tmp/x.cpp:5
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005a1 <<\EOF
+/tmp/x.cpp:6
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005b0 <<\EOF
+/tmp/x.cpp:10
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005b1 <<\EOF
+/tmp/x.cpp:11
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005c0 <<\EOF
+/tmp/x.cpp:5
+/tmp/x.cpp:15
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005d0 <<\EOF
+/tmp/x.cpp:10
+/tmp/x.cpp:20
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005e0 <<\EOF
+/tmp/x.cpp:5
+/tmp/x.cpp:15
+/tmp/x.cpp:25
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005e1 <<\EOF
+/tmp/x.cpp:10
+/tmp/x.cpp:20
+/tmp/x.cpp:26
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005f1 <<\EOF
+/tmp/x.cpp:10
+/tmp/x.cpp:32
+EOF
+
+testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005f2 <<\EOF
+/tmp/x.cpp:5
+/tmp/x.cpp:33
+EOF
+
+# All together now (plus function names).
+testrun_compare ${abs_top_builddir}/src/addr2line -f -i -e testfile-inlines 0x00000000000005a0 0x00000000000005a1 0x00000000000005b0 0x00000000000005b1 0x00000000000005c0 0x00000000000005d0 0x00000000000005e0 0x00000000000005e1 0x00000000000005f1 0x00000000000005f2 <<\EOF
+foobar
+/tmp/x.cpp:5
+foobar
+/tmp/x.cpp:6
+fubar
+/tmp/x.cpp:10
+fubar
+/tmp/x.cpp:11
+foobar inlined at /tmp/x.cpp:15 in _Z3barv
+/tmp/x.cpp:5
+bar
+/tmp/x.cpp:15
+fubar inlined at /tmp/x.cpp:20 in _Z3bazv
+/tmp/x.cpp:10
+baz
+/tmp/x.cpp:20
+foobar inlined at /tmp/x.cpp:15 in _Z3foov
+/tmp/x.cpp:5
+bar
+/tmp/x.cpp:15
+_Z3foov
+/tmp/x.cpp:25
+fubar inlined at /tmp/x.cpp:20 in _Z3foov
+/tmp/x.cpp:10
+baz
+/tmp/x.cpp:20
+_Z3foov
+/tmp/x.cpp:26
+fubar inlined at /tmp/x.cpp:32 in _Z2fuv
+/tmp/x.cpp:10
+_Z2fuv
+/tmp/x.cpp:32
+foobar inlined at /tmp/x.cpp:33 in _Z2fuv
+/tmp/x.cpp:5
+_Z2fuv
+/tmp/x.cpp:33
+EOF
+
+exit 0
diff --git a/tests/testfile-inlines.bz2 b/tests/testfile-inlines.bz2
new file mode 100755
index 0000000000000000000000000000000000000000..6a0c7c5749b94cc9bbdba8c5f0b49082fdca29ca
GIT binary patch
literal 2815
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
R&HDTNUC9*TLPO*m5k%+r@sj`m
literal 0
HcmV?d00001
--
1.7.1
10 years, 3 months
[PATCH] addr2line: Remove newline from strings returned by getline.
by Mark Wielaard
getline can return strings with a newline as last character when reading
from stdin. This could cause confusing symbol lookup failures like:
addr2line: cannot find symbol 'foo
'
So if the last character of the buf returned by getline is a newline just
null-terminate it right there. Also add a new testcase run-addr2line-test.sh.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
src/ChangeLog | 5 +++
src/addr2line.c | 6 +++-
tests/ChangeLog | 6 +++
tests/Makefile.am | 4 +-
tests/run-addr2line-test.sh | 74 +++++++++++++++++++++++++++++++++++++++++++
5 files changed, 92 insertions(+), 3 deletions(-)
create mode 100755 tests/run-addr2line-test.sh
diff --git a/src/ChangeLog b/src/ChangeLog
index 051f964..eacadbc 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2013-08-12 Mark Wielaard <mjw(a)redhat.com>
+
+ * addr2line.c (main): If there is a newline char at end of buf,
+ then remove it.
+
2013-07-05 Mark Wielaard <mjw(a)redhat.com>
* readelf.c (print_ops): Take CU as argument, use it to print
diff --git a/src/addr2line.c b/src/addr2line.c
index c7e4629..f2bc325 100644
--- a/src/addr2line.c
+++ b/src/addr2line.c
@@ -152,11 +152,15 @@ main (int argc, char *argv[])
char *buf = NULL;
size_t len = 0;
+ ssize_t chars;
while (!feof_unlocked (stdin))
{
- if (getline (&buf, &len, stdin) < 0)
+ if ((chars = getline (&buf, &len, stdin)) < 0)
break;
+ if (buf[chars - 1] == '\n')
+ buf[chars - 1] = '\0';
+
result = handle_address (buf, dwfl);
}
diff --git a/tests/ChangeLog b/tests/ChangeLog
index ea1f2de..3475d7b 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2013-08-12 Mark Wielaard <mjw(a)redhat.com>
+
+ * run-addr2line-test.sh: New test.
+ * Makefile.am (EXTRA_DIST): Add run-addr2line-test.sh.
+ (TESTS): Likewise.
+
2013-07-23 Jan Kratochvil <jan.kratochvil(a)redhat.com>
* run-unstrip-n.sh (test-core.*): Ignore libc.so.6 entry and order of
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4fe0022..ac99e3e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -88,7 +88,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
run-low_high_pc.sh run-macro-test.sh run-elf_cntl_gelf_getshdr.sh \
run-test-archive64.sh run-readelf-vmcoreinfo.sh \
run-readelf-mixed-corenote.sh run-dwfllines.sh \
- run-dwfl-report-elf-align.sh
+ run-dwfl-report-elf-align.sh run-addr2line-test.sh
if !STANDALONE
check_PROGRAMS += msg_tst md5-sha1-test
@@ -200,7 +200,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
run-dwfllines.sh run-dwfl-report-elf-align.sh \
testfile-dwfl-report-elf-align-shlib.so.bz2 \
testfilenolines.bz2 test-core-lib.so.bz2 test-core.core.bz2 \
- test-core.exec.bz2
+ test-core.exec.bz2 run-addr2line-test.sh
if USE_VALGRIND
valgrind_cmd='valgrind -q --trace-children=yes --error-exitcode=1 --run-libc-freeres=no'
diff --git a/tests/run-addr2line-test.sh b/tests/run-addr2line-test.sh
new file mode 100755
index 0000000..768006b
--- /dev/null
+++ b/tests/run-addr2line-test.sh
@@ -0,0 +1,74 @@
+#! /bin/sh
+# Copyright (C) 2013 Red Hat, Inc.
+# This file is part of elfutils.
+#
+# This file 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.
+#
+# elfutils 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/>.
+
+. $srcdir/test-subr.sh
+
+testfiles testfile
+tempfiles good.out stdin.nl stdin.nl.out stdin.nonl stdin.nonl.out foo.out
+tempfiles addr2line.out
+
+cat > good.out <<\EOF
+foo
+/home/drepper/gnu/new-bu/build/ttt/f.c:3
+bar
+/home/drepper/gnu/new-bu/build/ttt/b.c:4
+foo
+/home/drepper/gnu/new-bu/build/ttt/f.c:3
+bar
+/home/drepper/gnu/new-bu/build/ttt/b.c:4
+foo
+/home/drepper/gnu/new-bu/build/ttt/f.c:3
+bar
+/home/drepper/gnu/new-bu/build/ttt/b.c:4
+foo
+/home/drepper/gnu/new-bu/build/ttt/f.c:3
+bar
+/home/drepper/gnu/new-bu/build/ttt/b.c:4
+EOF
+
+echo "# Everything on the command line"
+cat good.out | testrun_compare ${abs_top_builddir}/src/addr2line -f -e testfile 0x08048468 0x0804845c foo bar foo+0x0 bar+0x0 foo-0x0 bar-0x0
+
+cat > stdin.nl <<\EOF
+0x08048468
+0x0804845c
+foo
+bar
+foo+0x0
+bar+0x0
+foo-0x0
+bar-0x0
+EOF
+
+echo "# Everything from stdin (with newlines)."
+cat stdin.nl | testrun ${abs_top_builddir}/src/addr2line -f -e testfile > stdin.nl.out || exit 1
+cmp good.out stdin.nl.out || exit 1
+
+cat > foo.out <<\EOF
+foo
+/home/drepper/gnu/new-bu/build/ttt/f.c:3
+EOF
+
+echo "# stdin without newline address, just EOF."
+echo -n "0x08048468" | testrun ${abs_top_builddir}/src/addr2line -f -e testfile > stdin.nonl.out || exit 1
+cmp foo.out stdin.nonl.out || exit 1
+
+echo "# stdin without newline symbol, just EOF."
+echo -n "foo" | testrun ${abs_top_builddir}/src/addr2line -f -e testfile > stdin.nl.out || exit 1
+cmp foo.out stdin.nonl.out || exit 1
+
+exit 0
--
1.7.1
10 years, 3 months
elfutils 0.156 released
by Jan Kratochvil
A new release of elfutils is available now at:
https://fedorahosted.org/releases/e/l/elfutils/0.156/
* NEWS *
Version 0.156
lib: New macro COMPAT_VERSION_NEWPROTO.
libdw: Handle GNU extension opcodes in dwarf_getlocation.
libdwfl: Fix STB_GLOBAL over STB_WEAK preference in dwfl_module_addrsym.
Add minisymtab support.
Add parameter add_p_vaddr to dwfl_report_elf.
Use DT_DEBUG library search first.
libebl: Handle new core note types in EBL.
backends: Interpret NT_ARM_VFP.
Implement core file registers parsing for s390/s390x.
readelf: Add --elf-section input option to inspect an embedded ELF file.
Add -U, --unresolved-address-offsets output control.
Add --debug-dump=decodedline support.
Accept version 8 .gdb_index section format.
Adjust output formatting width.
When highpc is in constant form print it also as address.
Display raw .debug_aranges. Use libdw only for decodedaranges.
elflint: Add __bss_start__ to the list of allowed symbols.
tests: Add configure --enable-valgrind option to run all tests under valgrind.
Enable automake parallel-tests for make check.
translations: Updated Polish translation.
Updates for Automake 1.13.
* GIT SHORTLOG *
Adam Markey (1):
Handle partial read or write.
David Abdurachmanov (1):
ar.c (do_oper_delete): Fix num passed to memset.
Jan Kratochvil (30):
Code cleanup: Simplify binary_search_fde.
Fix DW_CFA_expression & co. CFA initial push.
Fix error code from __libdw_find_fde.
Fix uninitialized Dwarf_Frame->regs.
Improve ELF symbols preference (global > weak).
Fix bias for vDSOs from core files.
readelf bitmap display fix.
readelf.c: Use real output width.
Fix ebl_abi_cfi error return value.
Add __nonnull_attribute__ to dwfl_module_getelf.
Fix bias for DSOs loaded from core file with build-id.
Fix missing tests/ EXTRA_DIST for files by me.
Code cleanup: Simplify __libdwfl_report_elf.
Fix for PIE with both -e and --core in use.
backends/arm_corenote.c Code cleanup.
Implement reglocs for s390/s390x - readelf.
Implement reglocs for s390/s390x.
Fix 64-bit->32-bit vDSO reporting.
Fix dwfl_report_elf BASE alignment.
Unify {BE,LE}{32,64} in lib/system.h.
New macro COMPAT_VERSION_NEWPROTO.
Add parameter add_p_vaddr to dwfl_report_elf.
Use DT_DEBUG library search first.
NEWS: Add entries for Version 0.156.
__libdwfl_find_elf_build_id: Add missing internal_function keyword.
NEWS: Remove bugfix only entries from Version 0.156.
Fix false match of non-build-id disk library to build-id memory library.
__libdwfl_elf_address_range: Add missing internal_function keyword.
Fix run-unstrip-n.sh regression on CentOS-5 ppc.
Prepare 0.156 release.
Mark Wielaard (49):
derelocate.c (find_section): Check next section exists before accessing it.
cu.c (cudie_offset): Don't use type_sig8, it might not be initialized.
Add configure --enable-valgrind option to run all tests under valgrind.
readelf.c (print_ops): Ajust DW_OP_skip and DW_OP_bra targets calculation.
Run valgrind tests with --run-libc-freeres=no.
Add missing semicolon in show_symbols_sysv
Fix two failure condition checks in libdwfl/linux-kernel-modules.c.
Fix sig8_hash memory leak in libdw/dwarf_begin_elf.c on error.
addr2line: Cleanup Dwfl when done.
readelf: Adjust initial FDE address if pcrel before printing.
readelf: Add --elf-section input option to inspect an embedded ELF file.
libdwfl: Add minisymtab support.
tests: readelf --elf-section, dwfl_module_addrsym and dwfl_module_getsym.
libdwfl: Support auxiliary symbol table only for getsym and addrsym.
readelf: Add base to offsets in format_dwarf_addr for debug_loc/ranges.
readelf: Add -U, --unresolved-address-offsets output control.
Add readelf test for --debug-dump=loc --debug-dump=ranges, -N and -U.
backends: Check type DIE exists before calling dwarf_tag ().
elflint: Add two more symbols to gnuld list of allowed bad values.
libdwfl: Use actual file names in parse_opt failure cases.
libdw: Handle FORM_GNU_strp_alt for files with string data only in dwz file.
libdwfl: Try opening files all installed compression libraries.
elflint.c (check_symtab): Add __bss_start__ to the list of allowed symbols.
Fix two memory leaks in findtextrel and strip.
libdw and libdwfl srcfiles and srclines fixes for partial_units.
readelf: Accept version 8 .gdb_index section format.
readelf: print_gdb_index_section fix memory leak.
readelf: When highpc is in constant form also print as address.
libdw: dwarf_getsrclines mark highest address as end_sequence.
readelf: Display raw .debug_aranges. Use libdw only for decodedaranges.
readelf: Add --debug-dump=decodedline support.
libdw: DW_FORM_GNU_ref_alt is always offset_size.
Updates for Automake 1.13.
Enable automake parallel-tests for make check.
libdwfl/link_map.c: #include system.h.
tests: Add various files to tempfiles so they are always cleaned up.
tests: All update tests should use unique temporary file names and cleanup.
tests: Tests that override EXIT (0) trap need to cleanup themselves.
tests: Don't use pushd or popd, just use cd to change working directory.
libdw: dwarf_getsrclines don't set end_sequence when there are no lines.
readelf: Format first DW_OP_GNU_implicit_pointer argument as DIE offset.
libdwfl: link_map.c (report_r_debug) always release memory_callback buffer.
tests EXTRA_DIST typo, forgot extension in testfilenolines.bz2.
libdw_visit_scopes: Don't recurse into imported unit children.
getcfi_scn_eh_frame: Don't crash and burn when .eh_frame bits aren't there.
Don't assert on mod->e_type in __libdwfl_relocate_value.
libdw. Don't blow up stack in dwarf_getsrclines with lots of lines.
readelf: print actual DW_OP_GNU_parameter_ref DIE offset.
readelf: print actual DIE offsets of DW_OP_GNU_<type> ops.
Petr Machata (9):
Update elf.h from glibc.
Handle new core note types in EBL
Add allregs test for ARM back end
Change FPREGSET_SIZE in ARM backend to 116 to match sizeof struct user_fp
Test elfutils output of VMCOREINFO note.
Add back end code for interpreting NT_ARM_VFP core note.
In mixed core notes, don't let handle_core_item repeat.
Test elfutils output of a mixed core note.
Handle GNU extension opcodes in dwarf_getlocation
Piotr Drąg (1):
Updated Polish translation.
Roland McGrath (8):
Merge branch 'jankratochvil/vdso-bias'
Robustify makefile redirection use.
Missing ChangeLog entry from last commit.
nm: Fix size passed to snprintf for invalid sh_name case.
elf_getarsym: Use memcpy instead of pointer dereference so as not to assume the field is naturally aligned.
elf_getarsym: Handle unaligned data in archive index.
dwfl_link_map_report: Handle unaligned auxv data.
Make run-prelink-addr-test.sh robust in its use of ln.
10 years, 3 months
Dump of alternate .debuginfo
by Andrey Ponomarenko
Hi,
I created a dump of a library debug-info by the "eu-readelf
--debug-dump=info" command. The formal_parameter of a subprogram has
type "(GNU_ref_alt) [ N]", but N is not described anywhere in the dump.
I have take a look at the source code of elfutils and found, that
DW_FORM_GNU_ref_alt is an offset in the "alternate debuginfo":
DW_FORM_GNU_ref_alt = 0x1f20, /* offset in alternate .debuginfo. */
DW_FORM_GNU_strp_alt = 0x1f21 /* offset in alternate .debug_str. */
How can I read/dump this "alternate debuginfo"?
Thanks.
--
Andrey Ponomarenko, ROSA Lab.
10 years, 4 months