Re: [PATCH] readelf: Add base to offsets in format_dwarf_addr for debug_loc/ranges.
by Roland McGrath
> On 01/30/2013 01:55 PM, Roland McGrath wrote:
> > The long option name seems a little too generic-sounding for an
> > option that actually changes only the display of addresses in a few
> > particular contexts.
>
> Perhaps some other contexts should also be affected by the option?
Indeed. I would have to look through everything to think of more cases.
11 years, 3 months
[patch] Fix 64-bit->32-bit vDSO reporting
by Jan Kratochvil
Hi Roland,
jankratochvil/auxv32
the problem is obvious I think. I do not see how to write an easy testcase.
It is tested on the jankratochvil/unwind branch but a more minimal testcase
would just be a partial duplication of that testcase also involving biarch
compilation and ptrace attachment.
FAIL->PASS
0xf7502000 0xf76b0000 /lib/libc-2.14.90.so
0xf76b3000 0xf76cc000 /lib/libpthread-2.14.90.so
0xf76ec000 0xf770f000 /lib/ld-2.14.90.so
0xf770f000 0xf7711000 /home/jkratoch/redhat/elfutils-clean/tests/backtrace-child-biarch
TID 29871:
# 0 0xf76eb430 (null)
No DWARF information found
[...]
->
0xf74ff000 0xf76ad000 /lib/libc-2.14.90.so
0xf76b0000 0xf76c9000 /lib/libpthread-2.14.90.so
0xf76e8000 0xf76e9000 [vdso: 29682]
0xf76e9000 0xf770c000 /lib/ld-2.14.90.so
0xf770c000 0xf770e000 /home/jkratoch/redhat/elfutils-clean/tests/backtrace-child-biarch
TID 29683:
# 0 0xf76e8430 __kernel_vsyscall
[...]
One can see [vdso: 29682] is not reported above at all.
Thanks,
Jan
commit 77d700999426dec7004ea41af89376580aab264c
Author: Jan Kratochvil <jan.kratochvil(a)redhat.com>
Date: Wed Oct 10 20:42:30 2012 +0200
libdwfl/
2012-10-10 Jan Kratochvil <jan.kratochvil(a)redhat.com>
* linux-proc-maps.c (PROCEXEFMT, get_pid_width): New.
(grovel_auxv): New parameter width. Use it.
(dwfl_linux_proc_report): New variable width, initialize it by
get_pid_width, use it for grovel_auxv.
Signed-off-by: Jan Kratochvil <jan.kratochvil(a)redhat.com>
diff --git a/libdwfl/linux-proc-maps.c b/libdwfl/linux-proc-maps.c
index 4fbe90d..327eb32 100644
--- a/libdwfl/linux-proc-maps.c
+++ b/libdwfl/linux-proc-maps.c
@@ -44,12 +44,39 @@
#define PROCMAPSFMT "/proc/%d/maps"
#define PROCMEMFMT "/proc/%d/mem"
#define PROCAUXVFMT "/proc/%d/auxv"
+#define PROCEXEFMT "/proc/%d/exe"
+/* Return 64 for 64-bit main ELF executable, 32 accordingly otherwise.
+ Return -1 for errors. */
+
+static int
+get_pid_width (pid_t pid)
+{
+ char *fname;
+ if (asprintf (&fname, PROCEXEFMT, pid) < 0)
+ return -1;
+
+ int fd = open64 (fname, O_RDONLY);
+ free (fname);
+ if (fd < 0)
+ return -1;
+
+ unsigned char buf[5];
+ ssize_t nread = read (fd, &buf, sizeof buf);
+ close (fd);
+ if (nread != sizeof (buf) || buf[0] != ELFMAG0 || buf[1] != ELFMAG1
+ || buf[2] != ELFMAG2 || buf[3] != ELFMAG3
+ || (buf[4] != ELFCLASS64 && buf[4] != ELFCLASS32))
+ return -1;
+
+ return buf[4] == ELFCLASS64 ? 64 : 32;
+}
+
/* Search /proc/PID/auxv for the AT_SYSINFO_EHDR tag. */
static int
-grovel_auxv (pid_t pid, Dwfl *dwfl, GElf_Addr *sysinfo_ehdr)
+grovel_auxv (pid_t pid, Dwfl *dwfl, int width, GElf_Addr *sysinfo_ehdr)
{
char *fname;
if (asprintf (&fname, PROCAUXVFMT, pid) < 0)
@@ -72,9 +99,9 @@ grovel_auxv (pid_t pid, Dwfl *dwfl, GElf_Addr *sysinfo_ehdr)
nread = read (fd, &d, sizeof d);
if (nread > 0)
{
- switch (sizeof (long int))
+ switch (width)
{
- case 4:
+ case 32:
for (size_t i = 0; (char *) &d.a32[i] < &d.buffer[nread]; ++i)
if (d.a32[i].a_type == AT_SYSINFO_EHDR)
{
@@ -89,7 +116,7 @@ grovel_auxv (pid_t pid, Dwfl *dwfl, GElf_Addr *sysinfo_ehdr)
&& dwfl->segment_align <= 1)
dwfl->segment_align = d.a32[i].a_un.a_val;
break;
- case 8:
+ case 64:
for (size_t i = 0; (char *) &d.a64[i] < &d.buffer[nread]; ++i)
if (d.a64[i].a_type == AT_SYSINFO_EHDR)
{
@@ -227,9 +254,13 @@ dwfl_linux_proc_report (Dwfl *dwfl, pid_t pid)
if (dwfl == NULL)
return -1;
+ int width = get_pid_width (pid);
+ if (width == -1)
+ return -1;
+
/* We'll notice the AT_SYSINFO_EHDR address specially when we hit it. */
GElf_Addr sysinfo_ehdr = 0;
- int result = grovel_auxv (pid, dwfl, &sysinfo_ehdr);
+ int result = grovel_auxv (pid, dwfl, width, &sysinfo_ehdr);
if (result != 0)
return result;
11 years, 3 months
[patch 2/2] Implement reglocs for s390/s390x
by Jan Kratochvil
Hi Mark,
jankratochvil/s390-core
it inherits:
jankratochvil/s390-core-readelf
On Tue, 29 Jan 2013 11:22:17 +0100, Mark Wielaard wrote:
> On Wed, 2013-01-23 at 22:13 +0100, Jan Kratochvil wrote:
> > Re: [patch] Implement reglocs for s390/s390x
> > https://lists.fedorahosted.org/pipermail/elfutils-devel/2012-October/0027...
> > Message-ID: <20121014155013.GA5525(a)host2.jankratochvil.net>
>
> I admit to be a little lost in the review thread. But it seems to me
> this could be split up between formatting changes (like the \n, b, B
> readelf.c one) and the actual s390_corenote.c change. Would it be
> possible to post this as separate patches (and maybe even split off the
> test addition if that depends on the formatting)?
here is the s390 fix depending on the readelf fix. Testcase is included,
I really do not see why to separate it.
Thanks,
Jan
commit a9186724438a9b735096ece40ecb15bc43e1fbd2
Author: Jan Kratochvil <jan.kratochvil(a)redhat.com>
Date: Wed Oct 10 19:32:05 2012 +0200
backends/
* Makefile.am (s390_SRCS): Add s390_corenote.c and s390x_corenote.c.
* linux-core-note.c (ALIGN_PR_REG): New definitions.
(struct EBLHOOK(prstatus)): Change field pr_reg to anonymous union with
ALIGN_PR_REG.
(EXTRA_ITEMS): New macro.
* s390_corenote.c: New file.
* s390_init.c (s390x_core_note): New declaration.
(s390_init): Install s390x_core_note and s390_core_note.
* s390x_corenote.c: New file.
tests/
* run-readelf-mixed-corenote.sh: New testcase for readelf -n of s390
and s390x core notes.
* testfile67.bz2: New file.
* testfile68.bz2: New file.
* Makefile.am (EXTRA_DIST): Add testfile67.bz2 and testfile68.bz2 .
Signed-off-by: Jan Kratochvil <jan.kratochvil(a)redhat.com>
diff --git a/backends/ChangeLog b/backends/ChangeLog
index cca7113..f33cce0 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,16 @@
+2013-01-29 Jan Kratochvil <jan.kratochvil(a)redhat.com>
+ Roland McGrath <roland(a)hack.frob.com>
+
+ * Makefile.am (s390_SRCS): Add s390_corenote.c and s390x_corenote.c.
+ * linux-core-note.c (ALIGN_PR_REG): New definitions.
+ (struct EBLHOOK(prstatus)): Change field pr_reg to anonymous union with
+ ALIGN_PR_REG.
+ (EXTRA_ITEMS): New macro.
+ * s390_corenote.c: New file.
+ * s390_init.c (s390x_core_note): New declaration.
+ (s390_init): Install s390x_core_note and s390_core_note.
+ * s390x_corenote.c: New file.
+
2012-10-12 Jan Kratochvil <jan.kratochvil(a)redhat.com>
* linux-core-note.c (prstatus_items): Rename groups of sigpend and
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/arm_corenote.c b/backends/arm_corenote.c
index d527944..c5d8d88 100644
--- a/backends/arm_corenote.c
+++ b/backends/arm_corenote.c
@@ -84,7 +84,7 @@ static const Ebl_Core_Item vfp_items[] =
{
.name = "fpscr", .group = "register",
.offset = 0,
- .count = 0, .type = ELF_T_WORD, .format = 'x',
+ .type = ELF_T_WORD, .format = 'x',
},
};
diff --git a/backends/linux-core-note.c b/backends/linux-core-note.c
index b09154f..4f1642d 100644
--- a/backends/linux-core-note.c
+++ b/backends/linux-core-note.c
@@ -42,6 +42,9 @@
#define INT int32_t
#define ALIGN_INT 4
#define TYPE_INT ELF_T_SWORD
+#ifndef ALIGN_PR_REG
+# define ALIGN_PR_REG ALIGN_ULONG
+#endif
#define FIELD(type, name) type name __attribute__ ((aligned (ALIGN_##type)))
@@ -81,7 +84,14 @@ struct EBLHOOK(prstatus)
struct EBLHOOK(timeval) pr_stime;
struct EBLHOOK(timeval) pr_cutime;
struct EBLHOOK(timeval) pr_cstime;
- FIELD (ULONG, pr_reg[PRSTATUS_REGS_SIZE / sizeof (ULONG)]);
+ union
+ {
+ FIELD (ULONG, pr_reg[PRSTATUS_REGS_SIZE / sizeof (ULONG)]);
+ }
+#ifdef ALIGN_PR_REG
+ __attribute__ ((aligned (ALIGN_PR_REG)))
+#endif
+ ;
FIELD (INT, pr_fpvalid);
};
@@ -265,6 +275,17 @@ EBLHOOK(core_note) (nhdr, name, regs_offset, nregloc, reglocs, nitems, items)
*items = extra_items; \
return 1;
+#define EXTRA_ITEMS(type, size, extra_items) \
+ case type: \
+ if (nhdr->n_descsz != size) \
+ return 0; \
+ *regs_offset = 0; \
+ *nregloc = 0; \
+ *reglocs = NULL; \
+ *nitems = sizeof extra_items / sizeof extra_items[0]; \
+ *items = extra_items; \
+ return 1;
+
#ifdef FPREGSET_SIZE
EXTRA_REGSET (NT_FPREGSET, FPREGSET_SIZE, fpregset_regs)
#endif
diff --git a/backends/s390_corenote.c b/backends/s390_corenote.c
new file mode 100644
index 0000000..17cf819
--- /dev/null
+++ b/backends/s390_corenote.c
@@ -0,0 +1,189 @@
+/* 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, b) \
+ { .offset = at * BITS/8, .regno = dwreg, .count = n, .bits = b }
+
+ GR ( 0, 1, 64, BITS), /* pswm */
+ GR ( 1, 1, 65, BITS), /* pswa */
+ GR ( 2, 16, 0, BITS), /* r0-r15 */
+ GR (18, 16, 48, 32), /* ar0-ar15 */
+
+#undef GR
+ };
+
+ /* orig_r2 is at offset (BITS == 32 ? 34 * 4 : 26 * 8). */
+#define PRSTATUS_REGS_SIZE (BITS / 8 * (BITS == 32 ? 35 : 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 offset 0, see fpregset_items, it has no assigned DWARF regno.
+ Bytes at offsets 4 to 7 are unused. */
+ 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
+ };
+
+static const Ebl_Core_Item fpregset_items[] =
+ {
+ {
+ .name = "fpc", .group = "register", .offset = 0, .type = ELF_T_WORD,
+ .format = 'x',
+ },
+ };
+
+/* Do not set FPREGSET_SIZE so that we can supply fpregset_items. */
+#define EXTRA_NOTES_FPREGSET \
+ EXTRA_REGSET_ITEMS (NT_FPREGSET, 17 * 8, fpregset_regs, fpregset_items)
+
+#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
+/* s390 psw_compat_t has alignment 8 bytes where it is inherited from. */
+#define ALIGN_PR_REG 8
+
+#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 high_regs_items[] =
+ {
+#define HR(n) \
+ { \
+ .name = "high_r" #n , .group = "register", .offset = (n) * 4, \
+ .type = ELF_T_WORD, .format = 'x', \
+ }
+
+ /* Upper halves of r0-r15 are stored here.
+ FIXME: They are currently not combined with the r0-r15 lower halves. */
+ HR (0), HR (1), HR (2), HR (3), HR (4), HR (5), HR (6), HR (7),
+ HR (8), HR (9), HR (10), HR (11), HR (12), HR (13), HR (14), HR (15)
+
+#undef HR
+ };
+
+#define EXTRA_NOTES_HIGH_GPRS \
+ EXTRA_ITEMS (NT_S390_HIGH_GPRS, 16 * 4, high_regs_items)
+
+#else /* BITS == 64 */
+
+#define EXTRA_NOTES_HIGH_GPRS
+
+#endif /* BITS == 64 */
+
+static const Ebl_Core_Item last_break_items[] =
+ {
+ {
+ .name = "last_break", .group = "system", .offset = BITS == 32 ? 4 : 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", .offset = 0, .type = ELF_T_WORD,
+ .format = 'd',
+ },
+ };
+
+#define EXTRA_NOTES \
+ EXTRA_NOTES_FPREGSET \
+ EXTRA_NOTES_HIGH_GPRS \
+ EXTRA_ITEMS (NT_S390_LAST_BREAK, 8, last_break_items) \
+ EXTRA_ITEMS (NT_S390_SYSTEM_CALL, 4, system_call_items)
+
+#include "linux-core-note.c"
diff --git a/backends/s390_init.c b/backends/s390_init.c
index 528e357..91fe4b8 100644
--- a/backends/s390_init.c
+++ b/backends/s390_init.c
@@ -37,6 +37,8 @@
/* This defines the common reloc hooks based on arm_reloc.def. */
#include "common-reloc.c"
+extern __typeof (s390_core_note) s390x_core_note;
+
const char *
s390_init (elf, machine, eh, ehlen)
@@ -55,6 +57,10 @@ s390_init (elf, machine, eh, ehlen)
HOOK (eh, reloc_simple_type);
HOOK (eh, register_info);
HOOK (eh, return_value_location);
+ if (eh->class == ELFCLASS64)
+ 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/tests/ChangeLog b/tests/ChangeLog
index bc721c7..e363a17 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,11 @@
+2013-01-29 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.
+ * Makefile.am (EXTRA_DIST): Add testfile67.bz2 and testfile68.bz2 .
+
2013-01-23 Mark Wielaard <mjw(a)redhat.com>
* testfilebasmin.bz2: New testfile.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f32ea24..e8efcd0 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -185,7 +185,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
testfile60.bz2 testfile61.bz2 \
run-readelf-vmcoreinfo.sh testfile62.bz2 \
run-readelf-mixed-corenote.sh testfile63.bz2 testfile64.bz2 \
- testfile65.bz2 testfile69.core.bz2 testfile69.so.bz2 \
+ testfile65.bz2 testfile67.bz2 testfile68.bz2 \
+ testfile69.core.bz2 testfile69.so.bz2 \
testfile70.core.bz2 testfile70.exec.bz2
if USE_VALGRIND
diff --git a/tests/run-readelf-mixed-corenote.sh b/tests/run-readelf-mixed-corenote.sh
index f9b96c8..3c4ec51 100755
--- a/tests/run-readelf-mixed-corenote.sh
+++ b/tests/run-readelf-mixed-corenote.sh
@@ -84,4 +84,137 @@ 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
+ fpc: 0x00000000
+ 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: 0
+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: 1
+ 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
+ fpc: 0x00000000
+ 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: 0
+ LINUX 64 S390_HIGH_GPRS
+ high_r0: 0x000003ff, high_r1: 0x000003ff, high_r2: 0x00000000
+ high_r3: 0x00000000, high_r4: 0x00000000, high_r5: 0x000003ff
+ high_r6: 0x00000000, high_r7: 0x00000000, high_r8: 0x00000000
+ high_r9: 0x00000000, high_r10: 0x00000000, high_r11: 0x00000000
+ high_r12: 0x000003ff, high_r13: 0x00000000, high_r14: 0x00000000
+ high_r15: 0x00000000
+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, 3 months
[patch 1/2] Implement reglocs for s390/s390x - readelf
by Jan Kratochvil
Hi Mark,
jankratochvil/s390-core-readelf
On Tue, 29 Jan 2013 11:22:17 +0100, Mark Wielaard wrote:
> On Wed, 2013-01-23 at 22:13 +0100, Jan Kratochvil wrote:
> > Re: [patch] Implement reglocs for s390/s390x
> > https://lists.fedorahosted.org/pipermail/elfutils-devel/2012-October/0027...
> > Message-ID: <20121014155013.GA5525(a)host2.jankratochvil.net>
>
> I admit to be a little lost in the review thread. But it seems to me
> this could be split up between formatting changes (like the \n, b, B
> readelf.c one) and the actual s390_corenote.c change. Would it be
> possible to post this as separate patches (and maybe even split off the
> test addition if that depends on the formatting)?
here is the readelf.c part. But it is not useful without [patch 2/2] as
nothing in elfutils is using the format this patch fixes.
If you use jankratochvil/s390-core with this patch undone one sees (reversed):
LINUX 8 S390_LAST_BREAK
- last_break: 0xfd75ccbe, last_break: 0x06000000
- last_break: 0x07030000
[...]
- last_break: 0x10809f00
- la./test-subr.sh: line 73: 20195 Segmentation fault LD_LIBRARY_PATH="${built_library_path}${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" $VALGRIND_CMD "$@"
+ last_break: 0xfd75ccbe
+ LINUX 4 S390_SYSTEM_CALL
This is because S390_LAST_BREAK has only single item and readelf.c expected
single-item is repeating through the whole section data. But in this case the
item has even offset 4 bytes (and size 4 bytes in a section of 8 bytes;
initial 4 bytes are ignored). Repeating items with offset were not handled
correctly, which led to the crash.
So it is best not to errorneously consider S390_LAST_BREAK to have repeating
content.
Thanks,
Jan
commit 22881b36d6512394a20c67edfc31ae745e0e50b3
Author: Jan Kratochvil <jan.kratochvil(a)redhat.com>
Date: Wed Oct 10 19:32:05 2012 +0200
src/
* readelf.c (handle_core_items): Limit special repeated items handling
to single-item formats '\n', 'b' and 'B', assert OFFSET 0 there.
Signed-off-by: Jan Kratochvil <jan.kratochvil(a)redhat.com>
diff --git a/src/ChangeLog b/src/ChangeLog
index 377c124..4d00013 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2013-01-29 Jan Kratochvil <jan.kratochvil(a)redhat.com>
+
+ * readelf.c (handle_core_items): Limit special repeated items handling
+ to single-item formats '\n', 'b' and 'B', assert OFFSET 0 there.
+
2012-12-18 Mark Wielaard <mark(a)bordewijk.wildebeest.org>
* readelf.c (ELF_INPUT_SECTION): New argp key value.
diff --git a/src/readelf.c b/src/readelf.c
index 0b46459..c256102 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -7851,6 +7851,24 @@ handle_core_items (Elf *core, const void *desc, size_t descsz,
{
if (nitems == 0)
return 0;
+ unsigned int colno = 0;
+
+ /* FORMAT '\n' makes sense to be present only as a single item as it
+ processes all the data of a note. FORMATs 'b' and 'B' have a special case
+ if present as a single item but they can be also processed with other
+ items below. */
+ if (nitems == 1 && (items[0].format == '\n' || items[0].format == 'b'
+ || items[0].format == 'B'))
+ {
+ assert (items[0].offset == 0);
+ size_t size = descsz;
+ colno = handle_core_item (core, items, desc, colno, &size);
+ /* If SIZE is not zero here there is some remaining data. But we do not
+ know how to process it anyway. */
+ return colno;
+ }
+ for (size_t i = 0; i < nitems; ++i)
+ assert (items[i].format != '\n');
/* Sort to collect the groups together. */
const Ebl_Core_Item *sorted_items[nitems];
@@ -7869,23 +7887,7 @@ handle_core_items (Elf *core, const void *desc, size_t descsz,
qsort (groups, ngroups, sizeof groups[0], &compare_core_item_groups);
/* Write out all the groups. */
- unsigned int colno = 0;
-
const void *last = desc;
- if (nitems == 1)
- {
- 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. */
- colno = handle_core_item (core, sorted_items[0], desc, colno,
- size != 0 ? &size : NULL);
-
- if (size == 0)
- return colno;
- desc += descsz - size;
- descsz = size;
- }
-
do
{
for (size_t i = 0; i < ngroups; ++i)
11 years, 3 months
Treat ELFOSABI_NONE as ELFOSABI_LINUX in some places
by Florian Weimer
I noticed that eu-readelf sometimes prints LOOS+0, e.g. for this file on
Fedora 18 x86_64:
d8676a3561c9fe681a1ba80c305fa003 /usr/lib64/libboost_timer.so
Not sure if this a toolchain bug or elfutils bug. readelf from binutils
prints GNU_UNIQUE.
--
Florian Weimer / Red Hat Product Security Team
11 years, 3 months
MiniDebugInfo support
by Martin Milata
Hello,
a future version of Automatic Bug Reporting Tool [1] will use elfutils
for extracting stack traces from core dumps. These stack traces will be
more useful if we can take advantage of the MiniDebugInfo feature that
will be present in Fedora 18.
The idea behind minidebuginfo is to take the separate debuginfo file
that is created during the package build process, drop most of its
sections except the symbol table, LZMA-compress it and put it into the
.gnu_debugdata section of the binary being build. See the feature
page [2] or GDB [3] and RPM [4] implementation if you want details.
Thanks to the find_debuginfo callback in libdwfl, it is very simple to
implement the support in the application -- if regular debuginfo file is
not found we can extract the .gnu_debugdata section to a temporary file
and make the library use it, and then delete it when it's not needed
anymore.
However, if elfutils supported this feature directly, more users can
benefit from it. I'd like to try to put together a patch for that, but
it is not clear to me how to go about this. Implementing this as a
standard callback probably requires creating a temporary file as the
library needs a file descriptor of the debuginfo. We can then keep track
of the file and delete it afterwards, or unlink it immediately after
opening it - but that would prevent us from returning a meaningful file
name...
So essentially, I have two questions:
1) Is such functionality desirable in elfutils?
2) What is the right way to add the support for it to the library?
Thanks,
Martin Milata
[1] https://fedorahosted.org/abrt/
[2] http://fedoraproject.org/wiki/Features/MiniDebugInfo
[3] https://bugzilla.redhat.com/show_bug.cgi?id=834068
[4] https://bugzilla.redhat.com/show_bug.cgi?id=834073
11 years, 3 months
[PATCH] ar.c (do_oper_delete): Fix num passed to memset.
by David Abdurachmanov
Signed-off-by: David Abdurachmanov <David.Abdurachmanov(a)cern.ch>
---
src/ar.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/ar.c b/src/ar.c
index 03da1b7..2d6ad60 100644
--- a/src/ar.c
+++ b/src/ar.c
@@ -919,7 +919,7 @@ do_oper_delete (const char *arfname, char **argv, int argc,
long int instance)
{
bool *found = alloca (sizeof (bool) * argc);
- memset (found, '\0', sizeof (found));
+ memset (found, '\0', sizeof (bool) * argc);
/* List of the files we keep. */
struct armem *to_copy = NULL;
--
1.7.4.1
11 years, 3 months