[obv] Add __nonnull_attribute__ to dwfl_module_getelf
by Jan Kratochvil
Hi Roland,
I have checked in this patch, it seems obvious enough to me.
Thanks,
Jan
commit 50f413ee377f3e3987b89f9726ba493a2038e9a2
Author: Jan Kratochvil <jan.kratochvil(a)redhat.com>
Date: Wed Oct 17 22:04:24 2012 +0200
libdwfl/
2012-10-17 Jan Kratochvil <jan.kratochvil(a)redhat.com>
* libdwfl.h (dwfl_module_getelf): Add __nonnull_attribute__.
Signed-off-by: Jan Kratochvil <jan.kratochvil(a)redhat.com>
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 189d3b7..638a096 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,7 @@
+2012-10-17 Jan Kratochvil <jan.kratochvil(a)redhat.com>
+
+ * libdwfl.h (dwfl_module_getelf): Add __nonnull_attribute__.
+
2012-10-10 Jan Kratochvil <jan.kratochvil(a)redhat.com>
* dwfl_segment_report_module.c (dwfl_segment_report_module):
diff --git a/libdwfl/libdwfl.h b/libdwfl/libdwfl.h
index 506a2a0..000d582 100644
--- a/libdwfl/libdwfl.h
+++ b/libdwfl/libdwfl.h
@@ -403,7 +403,8 @@ extern int dwfl_validate_address (Dwfl *dwfl,
are found) for use with libelf. If successful, fills in *BIAS
with the difference between addresses within the loaded module
and those in symbol tables or Dwarf information referring to it. */
-extern Elf *dwfl_module_getelf (Dwfl_Module *, GElf_Addr *bias);
+extern Elf *dwfl_module_getelf (Dwfl_Module *, GElf_Addr *bias)
+ __nonnull_attribute__ (1, 2);
/* Return the number of symbols in the module's symbol table,
or -1 for errors. */
11 years, 6 months
[patch] Implement reglocs for s390/s390x
by Jan Kratochvil
Hi,
readelf -n will work now.
TBH I do not know what S390_HIGH_GPRS are for. From what I read they are not
present on s390 iron, they are also not present for s390x processes, they are
present only for s390 processes on s390x iron/kernel. But gcc -m31 still does
not use the upper halves of r0-r15 there. I could ask at IBM but so far
I ignore S390_HIGH_GPRS in this and further patches. They are now just
printed by readelf, nothing more.
I also do not understand much what is there the exception <nitems == 1> in
readelf.c but it crashes without the fix for s390 core file S390_LAST_BREAK.
Thanks,
Jan
backends/
2012-10-09 Jan Kratochvil <jan.kratochvil(a)redhat.com>
* Makefile.am (s390_SRCS): Add s390_corenote.c and s390x_corenote.c.
* s390_corenote.c: new file.
* s390_init.c (s390_init): Install s390x_core_note and s390_core_note.
* s390x_corenote.c: new file.
src/
2012-10-09 Jan Kratochvil <jan.kratochvil(a)redhat.com>
* readelf.c (handle_core_items) <nitems == 1>: Fix non-zero OFFSET.
tests/
2012-10-09 Jan Kratochvil <jan.kratochvil(a)redhat.com>
* run-readelf-mixed-corenote.sh: New testcase for readelf -n of s390
and s390x core notes.
* testfile67.bz2: New file.
* testfile68.bz2: New file.
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 982ff2a..283bbfc 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -94,7 +94,8 @@ ppc64_SRCS = ppc64_init.c ppc64_symbol.c ppc64_retval.c \
libebl_ppc64_pic_a_SOURCES = $(ppc64_SRCS)
am_libebl_ppc64_pic_a_OBJECTS = $(ppc64_SRCS:.c=.os)
-s390_SRCS = s390_init.c s390_symbol.c s390_regs.c s390_retval.c
+s390_SRCS = s390_init.c s390_symbol.c s390_regs.c s390_retval.c \
+ s390_corenote.c s390x_corenote.c
libebl_s390_pic_a_SOURCES = $(s390_SRCS)
am_libebl_s390_pic_a_OBJECTS = $(s390_SRCS:.c=.os)
diff --git a/backends/s390_corenote.c b/backends/s390_corenote.c
new file mode 100644
index 0000000..4312537
--- /dev/null
+++ b/backends/s390_corenote.c
@@ -0,0 +1,173 @@
+/* S390 specific core note handling.
+ Copyright (C) 2012 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 either
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ 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 copies of the GNU General Public License and
+ the GNU Lesser General Public License along with this program. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <elf.h>
+#include <inttypes.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <sys/time.h>
+
+#ifndef BITS
+# define BITS 32
+# define BACKEND s390_
+#else
+# define BITS 64
+# define BACKEND s390x_
+#endif
+#include "libebl_CPU.h"
+
+static const Ebl_Register_Location prstatus_regs[] =
+ {
+#define GR(at, n, dwreg) \
+ { .offset = at * BITS/8, .regno = dwreg, .count = n, .bits = BITS }
+
+ GR (0, 1, 64), /* pswm */
+ GR (1, 1, 65), /* pswa */
+ GR (2, 16, 0), /* r0-r15 */
+ /* ar0-r15 */
+ { .offset = 18 * BITS/8, .regno = 48, .count = 16, .bits = 32 }
+ /* ar15 end is at "offset" (BITS == 32 ? 18 + 16 == 34 : 18 + 16 / 2 == 26).
+ orig_r2 is at "offset" (BITS == 32 ? 34 : 26). */
+
+#undef GR
+ };
+#define PRSTATUS_REGS_SIZE (BITS / 8 * (BITS == 32 ? 37 : 27))
+
+static const Ebl_Register_Location fpregset_regs[] =
+ {
+#define FPR(at, n, dwreg) \
+ { .offset = at * 64/8, .regno = dwreg, .count = n, .bits = 64 }
+
+ /* fpc is at 0. */
+ FPR (1 + 0, 1, 16), /* f0 */
+ FPR (1 + 1, 1, 20), /* f1 */
+ FPR (1 + 2, 1, 17), /* f2 */
+ FPR (1 + 3, 1, 21), /* f3 */
+ FPR (1 + 4, 1, 18), /* f4 */
+ FPR (1 + 5, 1, 22), /* f5 */
+ FPR (1 + 6, 1, 19), /* f6 */
+ FPR (1 + 7, 1, 23), /* f7 */
+ FPR (1 + 8, 1, 24), /* f8 */
+ FPR (1 + 9, 1, 28), /* f9 */
+ FPR (1 + 10, 1, 25), /* f10 */
+ FPR (1 + 11, 1, 29), /* f11 */
+ FPR (1 + 12, 1, 26), /* f12 */
+ FPR (1 + 13, 1, 30), /* f13 */
+ FPR (1 + 14, 1, 27), /* f14 */
+ FPR (1 + 15, 1, 31), /* f15 */
+
+#undef FPR
+ };
+#define FPREGSET_SIZE (17 * 8)
+
+#if BITS == 32
+# define ULONG uint32_t
+# define ALIGN_ULONG 4
+# define TYPE_ULONG ELF_T_WORD
+# define TYPE_LONG ELF_T_SWORD
+# define UID_T uint16_t
+# define GID_T uint16_t
+# define ALIGN_UID_T 2
+# define ALIGN_GID_T 2
+# define TYPE_UID_T ELF_T_HALF
+# define TYPE_GID_T ELF_T_HALF
+#else
+# define ULONG uint64_t
+# define ALIGN_ULONG 8
+# define TYPE_ULONG ELF_T_XWORD
+# define TYPE_LONG ELF_T_SXWORD
+# define UID_T uint32_t
+# define GID_T uint32_t
+# define ALIGN_UID_T 4
+# define ALIGN_GID_T 4
+# define TYPE_UID_T ELF_T_WORD
+# define TYPE_GID_T ELF_T_WORD
+#endif
+#define PID_T int32_t
+#define ALIGN_PID_T 4
+#define TYPE_PID_T ELF_T_SWORD
+
+#define PRSTATUS_REGSET_ITEMS \
+ { \
+ .name = "orig_r2", .type = TYPE_LONG, .format = 'd', \
+ .offset = offsetof (struct EBLHOOK(prstatus), \
+ pr_reg[BITS == 32 ? 34 : 26]), .group = "register" \
+ }
+
+#if BITS == 32
+
+static const Ebl_Core_Item no_items[0];
+
+static const Ebl_Register_Location high_regs[] =
+ {
+ /* Upper halves of r0-r15 are stored here.
+ FIXME: It is currently not combined with the r0-r15 lower halves. */
+ { .offset = 0, .regno = 0, .count = 16, .bits = 32 },
+ };
+
+#define EXTRA_NOTES_HIGH_GPRS \
+ EXTRA_REGSET_ITEMS (NT_S390_HIGH_GPRS, 16 * BITS / 8, high_regs, no_items)
+
+#else /* BITS == 64 */
+
+#define EXTRA_NOTES_HIGH_GPRS
+
+#endif /* BITS == 64 */
+
+static const Ebl_Core_Item last_break_items[] =
+ {
+ {
+ .name = "last_break", .group = "last_break",
+ .offset = BITS == 32 ? 4 : 0,
+ .count = 0, .type = BITS == 32 ? ELF_T_WORD : ELF_T_XWORD,
+ .format = 'x',
+ },
+ };
+
+static const Ebl_Core_Item system_call_items[] =
+ {
+ {
+ .name = "system_call", .group = "system_call",
+ .offset = 0,
+ .count = 0, .type = ELF_T_WORD,
+ .format = 'x',
+ },
+ };
+
+static const Ebl_Register_Location no_regs[0];
+
+#define EXTRA_NOTES \
+ EXTRA_NOTES_HIGH_GPRS \
+ EXTRA_REGSET_ITEMS (NT_S390_LAST_BREAK, 8, no_regs, last_break_items) \
+ EXTRA_REGSET_ITEMS (NT_S390_SYSTEM_CALL, 4, no_regs, system_call_items)
+
+#include "linux-core-note.c"
diff --git a/backends/s390_init.c b/backends/s390_init.c
index 528e357..c1d3ef6 100644
--- a/backends/s390_init.c
+++ b/backends/s390_init.c
@@ -55,6 +55,13 @@ s390_init (elf, machine, eh, ehlen)
HOOK (eh, reloc_simple_type);
HOOK (eh, register_info);
HOOK (eh, return_value_location);
+ if (eh->class == ELFCLASS64)
+ {
+ __typeof (s390_core_note) s390x_core_note;
+ eh->core_note = s390x_core_note;
+ }
+ else
+ HOOK (eh, core_note);
/* Only the 64-bit format uses the incorrect hash table entry size. */
if (eh->class == ELFCLASS64)
diff --git a/backends/s390x_corenote.c b/backends/s390x_corenote.c
new file mode 100644
index 0000000..427bf7d
--- /dev/null
+++ b/backends/s390x_corenote.c
@@ -0,0 +1,2 @@
+#define BITS 64
+#include "s390_corenote.c"
diff --git a/src/readelf.c b/src/readelf.c
index 5d167eb..bf0c924 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -7698,6 +7698,7 @@ handle_core_items (Elf *core, const void *desc, size_t descsz,
const void *last = desc;
if (nitems == 1)
{
+ descsz -= sorted_items[0]->offset;
size_t size = descsz;
/* If this note contains registers as well as items, don't pass
&size to express that we don't wish to repeat. */
@@ -7706,6 +7707,7 @@ handle_core_items (Elf *core, const void *desc, size_t descsz,
if (size == 0)
return colno;
+ size += sorted_items[0]->offset;
desc += descsz - size;
descsz = size;
}
diff --git a/tests/run-readelf-mixed-corenote.sh b/tests/run-readelf-mixed-corenote.sh
index f9b96c8..bdb5d3e 100755
--- a/tests/run-readelf-mixed-corenote.sh
+++ b/tests/run-readelf-mixed-corenote.sh
@@ -84,4 +84,133 @@ Note segment of 892 bytes at offset 0x274:
d30: 0x0000000000000000 d31: 0x0000000000000000
EOF
+testfiles testfile67
+testrun_compare ../src/readelf -n testfile67 <<\EOF
+
+Note segment of 1044 bytes at offset 0xe8:
+ Owner Data size Type
+ CORE 336 PRSTATUS
+ info.si_signo: 4, info.si_code: 0, info.si_errno: 0, cursig: 4
+ sigpend: <>
+ sighold: <>
+ pid: 805, ppid: 804, pgrp: 804, sid: 699
+ utime: 0.000042, stime: 0.000103, cutime: 0.000000, cstime: 0.000000
+ orig_r2: 2571552016, fpvalid: 1
+ pswm: 0x0705c00180000000 pswa: 0x00000000800000d6
+ r0: 4393751543808 r1: 4398002544388
+ r2: 11 r3: 2571578208
+ r4: 2571702016 r5: 4398003235624
+ r6: 2571580768 r7: 2571702016
+ r8: 2571578208 r9: 2571552016
+ r10: 2571552016 r11: 0
+ r12: 4398003499008 r13: 2148274656
+ r14: 0 r15: 4398040761216
+ a0: 0x000003ff a1: 0xfd54a6f0 a2: 0x00000000 a3: 0x00000000
+ a4: 0x00000000 a5: 0x00000000 a6: 0x00000000 a7: 0x00000000
+ a8: 0x00000000 a9: 0x00000000 a10: 0x00000000 a11: 0x00000000
+ a12: 0x00000000 a13: 0x00000000 a14: 0x00000000 a15: 0x00000000
+ CORE 136 PRPSINFO
+ state: 0, sname: R, zomb: 0, nice: 0, flag: 0x0000000000400400
+ uid: 0, gid: 0, pid: 805, ppid: 804, pgrp: 804, sid: 699
+ fname: 1, psargs: ./1
+ CORE 304 AUXV
+ SYSINFO_EHDR: 0
+ HWCAP: 0x37f
+ PAGESZ: 4096
+ CLKTCK: 100
+ PHDR: 0x80000040
+ PHENT: 56
+ PHNUM: 2
+ BASE: 0
+ FLAGS: 0
+ ENTRY: 0x800000d4
+ UID: 0
+ EUID: 0
+ GID: 0
+ EGID: 0
+ SECURE: 0
+ RANDOM: 0x3ffffa8463c
+ EXECFN: 0x3ffffa85ff4
+ PLATFORM: 0x3ffffa8464c
+ NULL
+ CORE 136 FPREGSET
+ f0: 0x0000000000000040 f1: 0x4b00000000000000
+ f2: 0x0000000000000041 f3: 0x3ad50b5555555600
+ f4: 0x0000000000000000 f5: 0x0000000000000000
+ f6: 0x0000000000000000 f7: 0x0000000000000000
+ f8: 0x0000000000000000 f9: 0x0000000000000000
+ f10: 0x0000000000000000 f11: 0x0000000000000000
+ f12: 0x0000000000000000 f13: 0x0000000000000000
+ f14: 0x0000000000000000 f15: 0x0000000000000000
+ LINUX 8 S390_LAST_BREAK
+ last_break: 0x000003fffd75ccbe
+ LINUX 4 S390_SYSTEM_CALL
+ system_call: 0x00000000
+EOF
+
+testfiles testfile68
+testrun_compare ../src/readelf -n testfile68 <<\EOF
+
+Note segment of 852 bytes at offset 0x94:
+ Owner Data size Type
+ CORE 224 PRSTATUS
+ info.si_signo: 4, info.si_code: 0, info.si_errno: 0, cursig: 4
+ sigpend: <>
+ sighold: <>
+ pid: 839, ppid: 838, pgrp: 838, sid: 699
+ utime: 0.000043, stime: 0.000102, cutime: 0.000000, cstime: 0.000000
+ orig_r2: -1723388288, fpvalid: 0
+ pswm: 0x070dc000 pswa: 0x8040009a
+ r0: 0 r1: -43966716 r2: 11 r3: -1723238816
+ r4: -1723265280 r5: -43275480 r6: -1723245280 r7: -1723265280
+ r8: -1723238816 r9: -1723388288 r10: -1723388288 r11: 0
+ r12: -43012096 r13: -2146692640 r14: 0 r15: 2139883440
+ a0: 0x000003ff a1: 0xfd54a6f0 a2: 0x00000000 a3: 0x00000000
+ a4: 0x00000000 a5: 0x00000000 a6: 0x00000000 a7: 0x00000000
+ a8: 0x00000000 a9: 0x00000000 a10: 0x00000000 a11: 0x00000000
+ a12: 0x00000000 a13: 0x00000000 a14: 0x00000000 a15: 0x00000000
+ CORE 124 PRPSINFO
+ state: 0, sname: R, zomb: 0, nice: 0, flag: 0x00400400
+ uid: 0, gid: 0, pid: 839, ppid: 838, pgrp: 838, sid: 699
+ fname: 2, psargs: ./2
+ CORE 152 AUXV
+ SYSINFO_EHDR: 0
+ HWCAP: 0x37f
+ PAGESZ: 4096
+ CLKTCK: 100
+ PHDR: 0x400034
+ PHENT: 32
+ PHNUM: 2
+ BASE: 0
+ FLAGS: 0
+ ENTRY: 0x400098
+ UID: 0
+ EUID: 0
+ GID: 0
+ EGID: 0
+ SECURE: 0
+ RANDOM: 0x7f8c090c
+ EXECFN: 0x7f8c1ff4
+ PLATFORM: 0x7f8c091c
+ NULL
+ CORE 136 FPREGSET
+ f0: 0x0000000000000040 f1: 0x4b00000000000000
+ f2: 0x0000000000000041 f3: 0x3ad50b5555555600
+ f4: 0x0000000000000000 f5: 0x0000000000000000
+ f6: 0x0000000000000000 f7: 0x0000000000000000
+ f8: 0x0000000000000000 f9: 0x0000000000000000
+ f10: 0x0000000000000000 f11: 0x0000000000000000
+ f12: 0x0000000000000000 f13: 0x0000000000000000
+ f14: 0x0000000000000000 f15: 0x0000000000000000
+ LINUX 8 S390_LAST_BREAK
+ last_break: 0xfd75ccbe
+ LINUX 4 S390_SYSTEM_CALL
+ system_call: 0x00000000
+ LINUX 64 S390_HIGH_GPRS
+ r0: 1023 r1: 1023 r2: 0 r3: 0
+ r4: 0 r5: 1023 r6: 0 r7: 0
+ r8: 0 r9: 0 r10: 0 r11: 0
+ r12: 1023 r13: 0 r14: 0 r15: 0
+EOF
+
exit 0
diff --git a/tests/testfile67.bz2 b/tests/testfile67.bz2
new file mode 100644
index 0000000000000000000000000000000000000000..bb64745db70a79db3a6182241fe77b0fcaf49144
GIT binary patch
literal 424
zcmV;Z0ayM)T4*^jL0KkKSp%-fGyny?|NsC0^`z!m;#6;~*FfZmf&jok03ZQKKnX$w
z2LM1oL<+D0Ml&##1SIk_#Schm*+2tEjWjYe)6@+;O$MH(PbumRPf0aBNr=-;7$!qZ
z1k*GV34|Din3yIIBvNXF)X)r?8Z<P}WND^AG|&cyfB?w&!<bg=OB(IC)<|MqFF-*h
z$2l~;A#Q3NuA8jKD-hXbf3B_R6sQa_M;6xIz1|$XFLT4ki$-~9{)$^bED(es3wExs
zV@QM5fHrPRms%kYs4jL9V3l#CfI!=67KWCioYIixAQ!XXTF18_2#Z2vKp_V65&~CI
zq>v!8@R+|EuO8_UZb$@JkwUZ-N{Q);h(LnT1E@H|ft<#xihi^m<OBx^2wfnRASzJe
zR}i7f7_dhUhAz6?42@wBv=-`Ubir^dgL8!AvwPK=m5iGzZh2ke+-=z4qOKtGz`;NY
zH`;<n9*p`5<iSmh=3yv*?qs!Mqw7NRRVy+uwFTuUGUrH7M!`>3vcE0o@k3txP?A7n
SBPpSX{}*yaI8cxSuE;cf2DsJ$
literal 0
HcmV?d00001
diff --git a/tests/testfile68.bz2 b/tests/testfile68.bz2
new file mode 100644
index 0000000000000000000000000000000000000000..3fe67921ff46f4b00d215577798c9aac17329e81
GIT binary patch
literal 399
zcmV;A0dW38T4*^jL0KkKSqTOjlK=&l|NsC0;iTY6ln`sJmqTTUg9N}-1aJWeKnXwu
z0sue&L<+D0Og7pgo~EXrjUkZH>KbG;8UO&$27qV)8kr#g001-q00000G8qJkQMEzn
zhJmJoMvXMlpa1{{LqVp6&^Y<!wJa`?_=Gac$zoGyWk?N4W!)8zSe#QUg;(|Lc6BP3
zx)^$<gd~s?LAJ{d&F=~T7g?Wf3QRuVvtJh?Oeiv|!@C8lF)s)>okr$l2>^nd>mI{J
z$v`S6VHBQ+<RK|KWtax!#DpN7paN#IohGeu!3-qv@Isd}fB-=bPOl79VUXr%OD-U!
z46Ce{i$>0&ka9sxc2a@eQwUUq(_oT<FlY@DWE;dVz7UWGNQfvPh!z4E_eh9`Li`!d
zA-U($Oyj^n7#7=>rEIHVa$vg52!z#%`d&49>hM$d3ID5KFQyo?{)-!eG$;)$81;7D
t0H7j{fJm8zoJ7K~%a_SNR}He$TV1yn1d>2^wOC)`?ntK!5&<B?QedNJq*wp|
literal 0
HcmV?d00001
11 years, 6 months
[patch] Fix ebl_abi_cfi error return value
by Jan Kratochvil
Hi Roland,
jankratochvil/abicfi-retval
I think it is obvious, IIRC it was crashing for me before I have implemented
the new abi_cfi methods for non-x86* backends.
Thanks,
Jan
commit 2fac29b29b3eec5358f27f80f4d91c7d7b7d75dc
Author: Jan Kratochvil <jan.kratochvil(a)redhat.com>
Date: Fri Oct 12 20:43:21 2012 +0200
libebl/
2012-10-12 Jan Kratochvil <jan.kratochvil(a)redhat.com>
* ebl-hooks.h (abi_cfi): Extend its comment for return value.
* eblopenbackend.c (default_abi_cfi): Return -1.
* libebl.h (ebl_abi_cfi): Extend its comment for return value.
Signed-off-by: Jan Kratochvil <jan.kratochvil(a)redhat.com>
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index f12613a..e881ce7 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,9 @@
+2012-10-12 Jan Kratochvil <jan.kratochvil(a)redhat.com>
+
+ * ebl-hooks.h (abi_cfi): Extend its comment for return value.
+ * eblopenbackend.c (default_abi_cfi): Return -1.
+ * libebl.h (ebl_abi_cfi): Extend its comment for return value.
+
2012-08-30 Petr Machata <pmachata(a)redhat.com>
* eblcorenotetypename.c: Handle PPC_VSX, X86_XSTATE,
diff --git a/libebl/ebl-hooks.h b/libebl/ebl-hooks.h
index f629bce..d3cf3e6 100644
--- a/libebl/ebl-hooks.h
+++ b/libebl/ebl-hooks.h
@@ -151,7 +151,8 @@ int EBLHOOK(disasm) (const uint8_t **startp, const uint8_t *end,
GElf_Addr addr, const char *fmt, DisasmOutputCB_t outcb,
DisasmGetSymCB_t symcb, void *outcbarg, void *symcbarg);
-/* Supply the machine-specific state of CFI before CIE initial programs. */
+/* Supply the machine-specific state of CFI before CIE initial programs.
+ Function returns 0 on success and -1 on error. */
int EBLHOOK(abi_cfi) (Ebl *ebl, Dwarf_CIE *abi_info);
/* Destructor for ELF backend handle. */
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index 89e5da5..ed0c0ff 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -750,5 +750,5 @@ static int
default_abi_cfi (Ebl *ebl __attribute__ ((unused)),
Dwarf_CIE *abi_info __attribute__ ((unused)))
{
- return 0;
+ return -1;
}
diff --git a/libebl/libebl.h b/libebl/libebl.h
index 0d5621d..cae31c9 100644
--- a/libebl/libebl.h
+++ b/libebl/libebl.h
@@ -267,7 +267,10 @@ extern int ebl_syscall_abi (Ebl *ebl, int *sp, int *pc,
DWARF register number that identifies the actual PC in machine state.
If there is no canonical DWARF register number with that meaning, it's
left unchanged (callers usually initialize with (Dwarf_Word) -1).
- This value is not used by CFI per se. */
+ This value is not used by CFI per se.
+
+ Function returns 0 on success and -1 for error or unsupported by the
+ backend. */
extern int ebl_abi_cfi (Ebl *ebl, Dwarf_CIE *abi_info)
__nonnull_attribute__ (2);
11 years, 6 months
[patch] readelf bitmap display fix
by Jan Kratochvil
Hi Roland,
jankratochvil/readelf-bitmap
when you insist on src/readelf.c fixes the displayed bitmaps were already very
wrong when trying to fix the handling around.
Just I haven't found it worth some thorough testcase. I used some adjustments
of the attached reproducer to produce a core file with bitmap.
Particularly
ioperm: ~<-65535>
->
ioperm: ~<0-63>
and
ioperm: ~<-0,2,4,6,8,10,12,14-65535>
->
ioperm: ~<0,2,4,6,8,10,12,14>
.
Regards,
Jan
commit 69a2852e1d5661bc042dcc90c16e9aa7777c7340
Author: Jan Kratochvil <jan.kratochvil(a)redhat.com>
Date: Thu Oct 11 21:47:26 2012 +0200
src/
2012-10-11 Jan Kratochvil <jan.kratochvil(a)redhat.com>
* readelf.c (handle_core_item) <b>: Make run an outer block variable.
Increase run only if LASTBIT != 0. Print last element only if RUN > 0.
Signed-off-by: Jan Kratochvil <jan.kratochvil(a)redhat.com>
diff --git a/src/readelf.c b/src/readelf.c
index 5d167eb..470af4d 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -7515,19 +7515,19 @@ handle_core_item (Elf *core, const Ebl_Core_Item *item, const void *desc,
}
unsigned int lastbit = 0;
+ unsigned int run = 0;
for (const unsigned int *i = data;
(void *) i < data + count * size; ++i)
{
unsigned int bit = ((void *) i - data) * 8;
unsigned int w = negate ? ~*i : *i;
- unsigned int run = 0;
while (w != 0)
{
int n = ffs (w);
w >>= n;
bit += n;
- if (lastbit + 1 == bit)
+ if (lastbit != 0 && lastbit + 1 == bit)
++run;
else
{
@@ -7543,8 +7543,8 @@ handle_core_item (Elf *core, const Ebl_Core_Item *item, const void *desc,
lastbit = bit;
}
}
- if (lastbit > 0 && lastbit + 1 != nbits)
- p += sprintf (p, "-%u", nbits - bias);
+ if (lastbit > 0 && run > 0 && lastbit + 1 != nbits)
+ p += sprintf (p, "-%u", lastbit - bias);
colno = print_core_item (colno, ',', ITEM_WRAP_COLUMN, 0, item->name,
4 + nbits * 4,
#define _GNU_SOURCE
#include <sys/io.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>
int
main (void)
{
for (int j = 0; j < 0xf; j+=2)
{
int i = ioperm (j, 1, 1);
assert_perror (errno);
assert (i == 0);
}
raise (SIGSEGV);
assert (0);
return 0;
}
11 years, 6 months
[Patch] Add configure --enable-valgrind option to run all tests under valgrind.
by Mark Wielaard
Hi,
It seems beneficial to run the testcases under valgrind to find some
memory issues. This patch adds a new configure option --enable-valgrind
that makes it so that all tests run under valgrind and fail if valgrind
finds an memory issue (it succeeds with my latest two patches).
It is disabled by default since running make check becomes too slow
for normal use. But I enabled it for the make distcheck case, which
seems a good time to double check all tests are clean.
Comments?
Mark
11 years, 6 months
[patch] Fix bias for vDSOs from core files
by Jan Kratochvil
Hi,
$ bzip2 -dvk backtrace*.bz2
$ ./backtrace ./backtrace.ppc64.{exec,core}
0x10000000 0x100c0000 [exe]
0xfffa3000000 0xfffa3010000 linux-vdso64.so.1
TID 54659:
# 0 0x10007fa8 .raise
# 1 0x10008370 - 1 .abort
# 2 0x10001344 - 1 .sigusr2
-FAIL:
-# 3 0xfffa3000418 - 1 (null)
-No DWARF information found
+PASS:
+# 3 0xfffa3000418 __kernel_sigtramp_rt64
+# 4 0x10007fa8 .raise
+[...]
I find this initialization missing there.
Testcase for this patch is the whole testsuite of:
[API RFC] unwinder
https://lists.fedorahosted.org/pipermail/elfutils-devel/2012-October/0026...
Thanks,
Jan
libdwfl/
2012-10-08 Jan Kratochvil <jan.kratochvil(a)redhat.com>
* dwfl_segment_report_module.c (dwfl_segment_report_module):
Initialize mod->MAIN_BIAS.
diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
index afe9da1..96eae8e 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -650,6 +650,7 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
mod->main.elf = elf;
mod->main.vaddr = module_start - bias;
mod->main.address_sync = module_address_sync;
+ mod->main_bias = bias;
}
return finish ();
11 years, 6 months
[PATCH] Handle partial read or write.
by Adam Markey
Ran into a situation where pread was returning less data than requested for
remote files on a networked filesystem. This patch modifies the IO wrappers
to request the remaining data as long as no real errors occured.
Signed-off-by: Adam Markey <adam(a)etinternational.com>
---
lib/ChangeLog | 5 +++++
lib/system.h | 42 ++++++++++++++++++++++++++++++++++++------
2 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 47e831e..ac0ffd8 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,8 @@
+2012-10-5 Adam Markey <adam(a)etinternational.com>
+
+ * system.h: Changed pwrite_retry, write_retry, and pread_retry to
+ handle case where not all data was read/written.
+
2012-01-21 Ulrich Drepper <drepper(a)gmail.com>
* Makefile.am (libeu_a_SOURCES): Add color.c.
diff --git a/lib/system.h b/lib/system.h
index 9ac01f8..7315a3e 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -34,6 +34,7 @@
#include <stdint.h>
#include <endian.h>
#include <byteswap.h>
+#include <unistd.h>
#if __BYTE_ORDER == __LITTLE_ENDIAN
# define LE32(n) (n)
@@ -64,12 +65,41 @@ extern int crc32_file (int fd, uint32_t *resp);
#define gettext_noop(Str) Str
-#define pwrite_retry(fd, buf, len, off) \
- TEMP_FAILURE_RETRY (pwrite (fd, buf, len, off))
-#define write_retry(fd, buf, n) \
- TEMP_FAILURE_RETRY (write (fd, buf, n))
-#define pread_retry(fd, buf, len, off) \
- TEMP_FAILURE_RETRY (pread (fd, buf, len, off))
+static inline ssize_t pwrite_retry(int fd, const void *buf, size_t len, off_t off) {
+ ssize_t ret;
+ ssize_t recvd = 0;
+
+ do {
+ ret = TEMP_FAILURE_RETRY (pwrite (fd, buf + recvd, len - recvd, off + recvd));
+ if (ret > 0) recvd += ret;
+ } while (ret > 0 && (size_t)recvd < len);
+
+ return ret < 0 ? ret : recvd;
+}
+
+static inline ssize_t write_retry(int fd, const void *buf, size_t len) {
+ ssize_t ret;
+ ssize_t recvd = 0;
+
+ do {
+ ret = TEMP_FAILURE_RETRY (write (fd, buf + recvd, len - recvd));
+ if (ret > 0) recvd += ret;
+ } while (ret > 0 && (size_t)recvd < len);
+
+ return ret < 0 ? ret : recvd;
+}
+
+static inline ssize_t pread_retry(int fd, void *buf, size_t len, off_t off) {
+ ssize_t ret;
+ ssize_t recvd = 0;
+
+ do {
+ ret = TEMP_FAILURE_RETRY (pread (fd, buf + recvd, len - recvd, off + recvd));
+ if (ret > 0) recvd += ret;
+ } while (ret > 0 && (size_t)recvd < len);
+
+ return ret < 0 ? ret : recvd;
+}
/* We need define two variables, argp_program_version_hook and
--
1.7.0.4
11 years, 6 months
[PATCH] Handle GNU extension opcodes in dwarf_getlocation
by Petr Machata
This is just for low-level byte munching support, so that libdw knows
how to decode the opcode stream, and doesn't fail when it encounters one
of the new opcodes.
The context is that I'm reviving locstat. The test binary that I have
on hand uses some of these opcodes. locstat mostly doesn't care what
exact location expression describes location of variable on any
particular address. It just cares that there is at least one. So
what's below actually fixes the problem for locstat, even if there are
no higher-level interfaces for grokking the extensions.
OK to push this?
Thanks,
PM
---
libdw/ChangeLog | 7 +++++++
libdw/dwarf_getlocation.c | 26 ++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 416a16f..0e65da8 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,10 @@
+2012-10-09 Petr Machata <pmachata(a)redhat.com>
+
+ * dwarf_getlocation.c (__libdw_intern_expression): Handle
+ DW_OP_GNU_parameter_ref, DW_OP_GNU_convert, DW_OP_GNU_reinterpret,
+ DW_OP_GNU_regval_type, DW_OP_GNU_entry_value,
+ DW_OP_GNU_deref_type, DW_OP_GNU_const_type.
+
2012-08-24 Mark Wielaard <mjw(a)redhat.com>
* dwarf_begin_elf.c (check_section): Only probe for dwz multi files
diff --git a/libdw/dwarf_getlocation.c b/libdw/dwarf_getlocation.c
index dfaa742..daeff2d 100644
--- a/libdw/dwarf_getlocation.c
+++ b/libdw/dwarf_getlocation.c
@@ -339,6 +339,7 @@ __libdw_intern_expression (Dwarf *dbg, bool other_byte_order,
case DW_OP_const4s:
case DW_OP_call4:
+ case DW_OP_GNU_parameter_ref:
if (unlikely (data + 4 > end_data))
goto invalid;
@@ -363,6 +364,8 @@ __libdw_intern_expression (Dwarf *dbg, bool other_byte_order,
case DW_OP_plus_uconst:
case DW_OP_regx:
case DW_OP_piece:
+ case DW_OP_GNU_convert:
+ case DW_OP_GNU_reinterpret:
/* XXX Check size. */
get_uleb128 (newloc->number, data);
break;
@@ -381,12 +384,14 @@ __libdw_intern_expression (Dwarf *dbg, bool other_byte_order,
break;
case DW_OP_bit_piece:
+ case DW_OP_GNU_regval_type:
/* XXX Check size. */
get_uleb128 (newloc->number, data);
get_uleb128 (newloc->number2, data);
break;
case DW_OP_implicit_value:
+ case DW_OP_GNU_entry_value:
/* This cannot be used in a CFI expression. */
if (unlikely (dbg == NULL))
goto invalid;
@@ -408,6 +413,27 @@ __libdw_intern_expression (Dwarf *dbg, bool other_byte_order,
get_uleb128 (newloc->number2, data); /* Byte offset. */
break;
+ case DW_OP_GNU_deref_type:
+ if (unlikely (data >= end_data))
+ goto invalid;
+ newloc->number = *data++;
+ get_uleb128 (newloc->number2, data);
+ break;
+
+ case DW_OP_GNU_const_type:
+ /* XXX Check size. */
+ get_uleb128 (newloc->number, data);
+ if (unlikely (data >= end_data))
+ goto invalid;
+ newloc->number2 = *data++; /* Block length. */
+ if (unlikely ((Dwarf_Word) (end_data - data) < newloc->number2))
+ goto invalid;
+ /* The third operand is relative block offset:
+ newloc->number3 = data - block->data;
+ We don't support this at this point. */
+ data += newloc->number2; /* Skip the block. */
+ break;
+
default:
goto invalid;
}
--
1.7.6.5
11 years, 6 months
[rfc] Code cleanup: Permit BIAS to be NULL
by Jan Kratochvil
Hi,
I somehow guess this patch gets rejected so I have not written a ChangeLog.
Sure np to get the patch dropped.
I find using the functions easier this way, it already saves 5 LoC and it is
rather more convenient for elfutils applications.
Thanks,
Jan
diff --git a/libdwfl/derelocate.c b/libdwfl/derelocate.c
index 56f998c..c29aa6e 100644
--- a/libdwfl/derelocate.c
+++ b/libdwfl/derelocate.c
@@ -278,8 +278,7 @@ check_module (Dwfl_Module *mod)
if (mod->dw == NULL)
{
- Dwarf_Addr bias;
- if (INTUSE(dwfl_module_getdwarf) (mod, &bias) == NULL)
+ if (INTUSE(dwfl_module_getdwarf) (mod, NULL) == NULL)
{
Dwfl_Error error = dwfl_errno ();
if (error != DWFL_E_NO_DWARF)
diff --git a/libdwfl/dwfl_module_dwarf_cfi.c b/libdwfl/dwfl_module_dwarf_cfi.c
index 5182d6a..3a4a9c3 100644
--- a/libdwfl/dwfl_module_dwarf_cfi.c
+++ b/libdwfl/dwfl_module_dwarf_cfi.c
@@ -60,7 +60,8 @@ dwfl_module_dwarf_cfi (mod, bias)
if (mod->dwarf_cfi != NULL)
{
- *bias = dwfl_adjusted_dwarf_addr (mod, 0);
+ if (bias)
+ *bias = dwfl_adjusted_dwarf_addr (mod, 0);
return mod->dwarf_cfi;
}
diff --git a/libdwfl/dwfl_module_eh_cfi.c b/libdwfl/dwfl_module_eh_cfi.c
index da10d9f..9cd11db 100644
--- a/libdwfl/dwfl_module_eh_cfi.c
+++ b/libdwfl/dwfl_module_eh_cfi.c
@@ -39,7 +39,8 @@ dwfl_module_eh_cfi (mod, bias)
if (mod->eh_cfi != NULL)
{
- *bias = dwfl_adjusted_address (mod, 0);
+ if (bias)
+ *bias = dwfl_adjusted_address (mod, 0);
return mod->eh_cfi;
}
@@ -50,7 +51,8 @@ dwfl_module_eh_cfi (mod, bias)
return NULL;
}
- *bias = dwfl_adjusted_address (mod, 0);
+ if (bias)
+ *bias = dwfl_adjusted_address (mod, 0);
return __libdwfl_set_cfi (mod, &mod->eh_cfi,
INTUSE(dwarf_getcfi_elf) (mod->main.elf));
}
diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
index bbf9ff3..fc111df 100644
--- a/libdwfl/dwfl_module_getdwarf.c
+++ b/libdwfl/dwfl_module_getdwarf.c
@@ -1047,7 +1047,8 @@ dwfl_module_getdwarf (Dwfl_Module *mod, Dwarf_Addr *bias)
(void) __libdwfl_relocate (mod, mod->debug.elf, false);
}
- *bias = dwfl_adjusted_dwarf_addr (mod, 0);
+ if (bias)
+ *bias = dwfl_adjusted_dwarf_addr (mod, 0);
return mod->dw;
}
diff --git a/libdwfl/dwfl_module_getelf.c b/libdwfl/dwfl_module_getelf.c
index f20fb04..f88d8d8 100644
--- a/libdwfl/dwfl_module_getelf.c
+++ b/libdwfl/dwfl_module_getelf.c
@@ -57,7 +57,8 @@ dwfl_module_getelf (Dwfl_Module *mod, GElf_Addr *loadbase)
}
}
- *loadbase = dwfl_adjusted_address (mod, 0);
+ if (loadbase)
+ *loadbase = dwfl_adjusted_address (mod, 0);
return mod->main.elf;
}
diff --git a/libdwfl/dwfl_module_getsrc_file.c b/libdwfl/dwfl_module_getsrc_file.c
index 20aa8a5..edc466c 100644
--- a/libdwfl/dwfl_module_getsrc_file.c
+++ b/libdwfl/dwfl_module_getsrc_file.c
@@ -40,8 +40,7 @@ dwfl_module_getsrc_file (Dwfl_Module *mod,
if (mod->dw == NULL)
{
- Dwarf_Addr bias;
- if (INTUSE(dwfl_module_getdwarf) (mod, &bias) == NULL)
+ if (INTUSE(dwfl_module_getdwarf) (mod, NULL) == NULL)
return -1;
}
diff --git a/libdwfl/dwfl_nextcu.c b/libdwfl/dwfl_nextcu.c
index 9ea8388..3295ccb 100644
--- a/libdwfl/dwfl_nextcu.c
+++ b/libdwfl/dwfl_nextcu.c
@@ -54,7 +54,8 @@ dwfl_nextcu (Dwfl *dwfl, Dwarf_Die *lastcu, Dwarf_Addr *bias)
if (cu != NULL)
{
- *bias = dwfl_adjusted_dwarf_addr (mod, 0);
+ if (bias)
+ *bias = dwfl_adjusted_dwarf_addr (mod, 0);
return &cu->die;
}
diff --git a/libdwfl/libdwfl.h b/libdwfl/libdwfl.h
index 506a2a0..60f4e75 100644
--- a/libdwfl/libdwfl.h
+++ b/libdwfl/libdwfl.h
@@ -402,7 +402,8 @@ extern int dwfl_validate_address (Dwfl *dwfl,
/* Fetch the module main ELF file (where the allocated sections
are found) for use with libelf. If successful, fills in *BIAS
with the difference between addresses within the loaded module
- and those in symbol tables or Dwarf information referring to it. */
+ and those in symbol tables or Dwarf information referring to it.
+ BIAS may be passed as NULL. */
extern Elf *dwfl_module_getelf (Dwfl_Module *, GElf_Addr *bias);
/* Return the number of symbols in the module's symbol table,
@@ -443,9 +444,9 @@ extern Elf_Scn *dwfl_module_address_section (Dwfl_Module *mod,
/* Fetch the module's debug information for use with libdw.
If successful, fills in *BIAS with the difference between
- addresses within the loaded module and those to use with libdw. */
-extern Dwarf *dwfl_module_getdwarf (Dwfl_Module *, Dwarf_Addr *bias)
- __nonnull_attribute__ (2);
+ addresses within the loaded module and those to use with libdw.
+ BIAS may be pased as NULL. */
+extern Dwarf *dwfl_module_getdwarf (Dwfl_Module *, Dwarf_Addr *bias);
/* Get the libdw handle for each module. */
extern ptrdiff_t dwfl_getdwarf (Dwfl *,
@@ -455,24 +456,21 @@ extern ptrdiff_t dwfl_getdwarf (Dwfl *,
void *arg, ptrdiff_t offset);
/* Look up the module containing ADDR and return its debugging information,
- loading it if necessary. */
-extern Dwarf *dwfl_addrdwarf (Dwfl *dwfl, Dwarf_Addr addr, Dwarf_Addr *bias)
- __nonnull_attribute__ (3);
+ loading it if necessary. BIAS may be passed as NULL. */
+extern Dwarf *dwfl_addrdwarf (Dwfl *dwfl, Dwarf_Addr addr, Dwarf_Addr *bias);
-/* Find the CU containing ADDR and return its DIE. */
-extern Dwarf_Die *dwfl_addrdie (Dwfl *dwfl, Dwarf_Addr addr, Dwarf_Addr *bias)
- __nonnull_attribute__ (3);
+/* Find the CU containing ADDR and return its DIE.
+ BIAS may be passed as NULL. */
+extern Dwarf_Die *dwfl_addrdie (Dwfl *dwfl, Dwarf_Addr addr, Dwarf_Addr *bias);
extern Dwarf_Die *dwfl_module_addrdie (Dwfl_Module *mod,
- Dwarf_Addr addr, Dwarf_Addr *bias)
- __nonnull_attribute__ (3);
+ Dwarf_Addr addr, Dwarf_Addr *bias);
-/* Iterate through the CUs, start with null for LASTCU. */
-extern Dwarf_Die *dwfl_nextcu (Dwfl *dwfl, Dwarf_Die *lastcu, Dwarf_Addr *bias)
- __nonnull_attribute__ (3);
+/* Iterate through the CUs, start with null for LASTCU. BIAS may be passed as
+ NULL. */
+extern Dwarf_Die *dwfl_nextcu (Dwfl *dwfl, Dwarf_Die *lastcu, Dwarf_Addr *bias);
extern Dwarf_Die *dwfl_module_nextcu (Dwfl_Module *mod,
- Dwarf_Die *lastcu, Dwarf_Addr *bias)
- __nonnull_attribute__ (3);
+ Dwarf_Die *lastcu, Dwarf_Addr *bias);
/* Return the module containing the CU DIE. */
extern Dwfl_Module *dwfl_cumodule (Dwarf_Die *cudie);
@@ -546,8 +544,9 @@ extern int dwfl_module_register_names (Dwfl_Module *mod,
/* Find the CFI for this module. Returns NULL if there is no CFI.
On success, fills in *BIAS with the difference between addresses
within the loaded module and those in the CFI referring to it.
- The pointer returned can be used until the module is cleaned up.
- Calling these more than once returns the same pointers.
+ BIAS may be also passed as NULL. The pointer returned can be used
+ until the module is cleaned up. Calling these more than once returns
+ the same pointers.
dwfl_module_dwarf_cfi gets the '.debug_frame' information found with the
rest of the DWARF information. dwfl_module_eh_cfi gets the '.eh_frame'
diff --git a/src/readelf.c b/src/readelf.c
index 5d167eb..be53983 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -613,8 +613,7 @@ process_file (int fd, const char *fname, bool only_one)
static void
process_elf_file (Dwfl_Module *dwflmod, int fd)
{
- GElf_Addr dwflbias;
- Elf *elf = dwfl_module_getelf (dwflmod, &dwflbias);
+ Elf *elf = dwfl_module_getelf (dwflmod, NULL);
GElf_Ehdr ehdr_mem;
GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
@@ -7246,8 +7245,7 @@ static void
print_debug (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr)
{
/* Before we start the real work get a debug context descriptor. */
- Dwarf_Addr dwbias;
- Dwarf *dbg = dwfl_module_getdwarf (dwflmod, &dwbias);
+ Dwarf *dbg = dwfl_module_getdwarf (dwflmod, NULL);
Dwarf dummy_dbg =
{
.elf = ebl->elf,
diff --git a/src/unstrip.c b/src/unstrip.c
index f6660a3..acfa2d0 100644
--- a/src/unstrip.c
+++ b/src/unstrip.c
@@ -1979,8 +1979,7 @@ static void
handle_dwfl_module (const char *output_file, bool create_dirs,
Dwfl_Module *mod, bool all, bool ignore, bool relocate)
{
- GElf_Addr bias;
- Elf *stripped = dwfl_module_getelf (mod, &bias);
+ Elf *stripped = dwfl_module_getelf (mod, NULL);
if (stripped == NULL)
{
if (ignore)
@@ -1999,7 +1998,7 @@ handle_dwfl_module (const char *output_file, bool create_dirs,
modname, file, dwfl_errmsg (-1));
}
- Elf *debug = dwarf_getelf (dwfl_module_getdwarf (mod, &bias));
+ Elf *debug = dwarf_getelf (dwfl_module_getdwarf (mod, NULL));
if (debug == NULL && !all)
{
if (ignore)
@@ -2074,8 +2073,7 @@ handle_output_dir_module (const char *output_dir, Dwfl_Module *mod,
if (! modnames)
{
/* Make sure we've searched for the ELF file. */
- GElf_Addr bias;
- (void) dwfl_module_getelf (mod, &bias);
+ (void) dwfl_module_getelf (mod, NULL);
}
const char *file;
@@ -2097,9 +2095,8 @@ static void
list_module (Dwfl_Module *mod)
{
/* Make sure we have searched for the files. */
- GElf_Addr bias;
- bool have_elf = dwfl_module_getelf (mod, &bias) != NULL;
- bool have_dwarf = dwfl_module_getdwarf (mod, &bias) != NULL;
+ bool have_elf = dwfl_module_getelf (mod, NULL) != NULL;
+ bool have_dwarf = dwfl_module_getdwarf (mod, NULL) != NULL;
const char *file;
const char *debug;
@@ -2160,8 +2157,7 @@ match_module (Dwfl_Module *mod,
if (info->match_files)
{
/* Make sure we've searched for the ELF file. */
- GElf_Addr bias;
- (void) dwfl_module_getelf (mod, &bias);
+ (void) dwfl_module_getelf (mod, NULL);
const char *file;
const char *check = dwfl_module_info (mod, NULL, NULL, NULL,
diff --git a/tests/allregs.c b/tests/allregs.c
index b103ce1..8f77216 100644
--- a/tests/allregs.c
+++ b/tests/allregs.c
@@ -54,8 +54,7 @@ first_module (Dwfl_Module *mod,
Dwarf_Addr low_addr __attribute__ ((unused)),
void *arg)
{
- Dwarf_Addr bias;
- if (dwfl_module_getelf (mod, &bias) == NULL) /* Not really a module. */
+ if (dwfl_module_getelf (mod, NULL) == NULL) /* Not really a module. */
return DWARF_CB_OK;
*(Dwfl_Module **) arg = mod;
diff --git a/tests/dwfl-bug-fd-leak.c b/tests/dwfl-bug-fd-leak.c
index 170a61a..afbf95e 100644
--- a/tests/dwfl-bug-fd-leak.c
+++ b/tests/dwfl-bug-fd-leak.c
@@ -55,8 +55,7 @@ elfutils_open (pid_t pid, Dwarf_Addr address)
if (dwfl_report_end (dwfl, NULL, NULL) != 0)
error (2, 0, "dwfl_report_end: %s", dwfl_errmsg (-1));
- Dwarf_Addr bias;
- Dwarf *dbg = dwfl_addrdwarf (dwfl, address, &bias);
+ Dwarf *dbg = dwfl_addrdwarf (dwfl, address, NULL);
if (dbg != NULL)
{
Elf *elf = dwarf_getelf (dbg);
@@ -65,7 +64,7 @@ elfutils_open (pid_t pid, Dwarf_Addr address)
}
else
{
- Elf *elf = dwfl_module_getelf (dwfl_addrmodule (dwfl, address), &bias);
+ Elf *elf = dwfl_module_getelf (dwfl_addrmodule (dwfl, address), NULL);
if (elf == NULL)
error (2, 0, "dwfl_module_getelf: %s", dwfl_errmsg (-1));
}
11 years, 6 months
[patch] Improve ELF symbols preference (global > weak)
by Jan Kratochvil
Hi,
debuggers like GDB display symbol name 'raise' but elfutils have been
displaying 'gsignal' instead.
$ mv core.`ulimit -c unlimited;./backtrace-child --gencore --run` ./backtrace-child.core
$ ./backtrace ./backtrace-child{,.core}
[...]
TID 9971:
FAIL: # 0 0x7fe4ec6bd285 gsignal
->
PASS: # 0 0x7fe4ec6bd285 raise
# 1 0x7fe4ec6beb9b - 1 abort
# 2 0x7fe4ece7fa75 - 1 sigusr2
# 3 0x7fe4ece7fbd0 - 1 stdarg
# 4 0x7fe4ece7fbee - 1 backtracegen
# 5 0x7fe4ece7fc05 - 1 start
# 6 0x7fe4eca46d90 - 1 start_thread
# 7 0x7fe4ec77819d - 1 clone
This is because:
readelf -Ws /lib64/libc.so.6
Symbol table '.symtab' contains 7720 entries:
6650: 000000326ca36250 100 FUNC WEAK DEFAULT 12 gsignal
6675: 000000326ca36250 100 FUNC GLOBAL DEFAULT 12 raise
I believe when there are both such symbols STB_GLOBAL should be preferred over
STB_WEAK (which should be preferred over STB_LOCAL).
Testcase for this patch is the whole testsuite of:
[API RFC] unwinder
https://lists.fedorahosted.org/pipermail/elfutils-devel/2012-October/0026...
There is check_gsignal for it in tests/run-backtrace.sh. As there are shipped
non-x86* core files and self-contained -static files with ELF symbols the test
does not depend on host system. Still maybe some more thorough testcase for
symbols priorities could be there, currently there is not.
Thanks,
Jan
diff --git a/libdwfl/dwfl_module_addrsym.c b/libdwfl/dwfl_module_addrsym.c
index 4e0646e..7ea6289 100644
--- a/libdwfl/dwfl_module_addrsym.c
+++ b/libdwfl/dwfl_module_addrsym.c
@@ -133,13 +143,13 @@ dwfl_module_addrsym (Dwfl_Module *mod, GElf_Addr addr,
}
}
/* When the beginning of its range is no closer,
- the end of its range might be. But do not
- replace a global symbol with a local! */
+ the end of its range might be. Prefer STB_GLOBAL over
+ STB_WEAK and STB_WEAK over STB_LOCAL. */
else if (sym.st_size != 0
&& closest_sym->st_value == sym.st_value
- && closest_sym->st_size > sym.st_size
- && (GELF_ST_BIND (closest_sym->st_info)
- <= GELF_ST_BIND (sym.st_info)))
+ && closest_sym->st_size >= sym.st_size
+ && (GELF_ST_BIND (sym.st_info) == STB_GLOBAL
+ || GELF_ST_BIND (closest_sym->st_info) == STB_LOCAL))
{
*closest_sym = sym;
closest_shndx = shndx;
11 years, 6 months