summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2014-04-10 15:02:53 +0200
committerMark Wielaard <mjw@redhat.com>2014-04-14 15:27:04 +0200
commit110c273d35515ebcfba0c88ad70dbcd5548b0d3c (patch)
tree5e87170fab20d3c5ac9e564076d1c87cf9db2084
parent66637fa21044ac0058b25522f473669e73de328b (diff)
downloadelfutils-110c273d35515ebcfba0c88ad70dbcd5548b0d3c.tar.gz
readelf: convert up to a target long in buf_read_ulong.
Add a i686 corefile test. Reported-by: Markus Engel <m_engel@cs.uni-kl.de> Signed-off-by: Mark Wielaard <mjw@redhat.com>
-rw-r--r--src/ChangeLog4
-rw-r--r--src/readelf.c2
-rw-r--r--tests/ChangeLog6
-rw-r--r--tests/Makefile.am2
-rwxr-xr-xtests/run-readelf-mixed-corenote.sh67
-rw-r--r--tests/testfile_i686_core.bz2bin0 -> 15980 bytes
6 files changed, 78 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c1662671..a6218e23 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2014-04-10 Mark Wielaard <mjw@redhat.com>
+
+ * readelf.c (buf_read_ulong): Pass actual long size to convert.
+
2014-03-05 Mark Wielaard <mjw@redhat.com>
* readelf.c (attr_callback): Print DW_FORM_sdata values as signed
diff --git a/src/readelf.c b/src/readelf.c
index d2efbaeb..ff8048ef 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -8736,7 +8736,7 @@ buf_read_ulong (Elf *core, unsigned char const **ptrp, unsigned char const *end,
uint32_t u32;
} u;
- *ptrp = convert (core, ELF_T_ADDR, 1, &u, *ptrp, sizeof u);
+ *ptrp = convert (core, ELF_T_ADDR, 1, &u, *ptrp, sz);
if (sz == 4)
*retp = u.u32;
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 776ea66f..a813f9c1 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2014-04-10 Mark Wielaard <mjw@redhat.com>
+
+ * testfile_i686_core.bz2: New test file.
+ * run-readelf-mixed-corenote.sh: Add testfile_i686_core test.
+ * Makefile.am (EXTRA_DIST): Add testfile_i686_core.bz2
+
2014-04-09 Mark Wielaard <mjw@redhat.com>
* Makefile.am (TESTS): Add run-backtrace-core-aarch64.sh.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 698e2cfa..4ff032db 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -250,7 +250,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
testfile_parameter_ref.c testfile_parameter_ref.bz2 \
testfile_entry_value.c testfile_entry_value.bz2 \
testfile_implicit_value.c testfile_implicit_value.bz2 \
- testfile_aarch64_core.bz2 \
+ testfile_aarch64_core.bz2 testfile_i686_core.bz2 \
run-funcretval.sh funcretval_test.c funcretval_test_aarch64.bz2 \
run-backtrace-data.sh run-backtrace-dwarf.sh cleanup-13.c \
run-backtrace-native.sh run-backtrace-native-biarch.sh \
diff --git a/tests/run-readelf-mixed-corenote.sh b/tests/run-readelf-mixed-corenote.sh
index c176e283..01e4594d 100755
--- a/tests/run-readelf-mixed-corenote.sh
+++ b/tests/run-readelf-mixed-corenote.sh
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2012, 2013 Red Hat, Inc.
+# Copyright (C) 2012, 2013, 2014 Red Hat, Inc.
# This file is part of elfutils.
#
# This file is free software; you can redistribute it and/or modify
@@ -425,4 +425,69 @@ Note segment of 2512 bytes at offset 0x270:
DBGWVR15_EL1: 0x0000000000000000, DBGWCR15_EL1: 0x00000000
EOF
+# To reproduce this core dump, do this on an i686 machine:
+# $ gcc -x c <(echo 'int main () { return *(int *)0x12345678; }')
+# $ ./a.out
+testfiles testfile_i686_core
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile_i686_core <<\EOF
+
+Note segment of 1000 bytes at offset 0x214:
+ Owner Data size Type
+ CORE 144 PRSTATUS
+ info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11
+ sigpend: <>
+ sighold: <>
+ pid: 27395, ppid: 1130, pgrp: 27395, sid: 1130
+ utime: 0.000000, stime: 0.001000, cutime: 0.000000, cstime: 0.000000
+ orig_eax: -1, fpvalid: 0
+ ebx: 1334976512 ecx: -1239415396 edx: -1079283900
+ esi: 0 edi: 0 ebp: 0xbfab6f18
+ eax: 305419896 eip: 0x08048408 eflags: 0x00010246
+ esp: 0xbfab6f18
+ ds: 0x007b es: 0x007b fs: 0x0000 gs: 0x0033 cs: 0x0073 ss: 0x007b
+ CORE 124 PRPSINFO
+ state: 0, sname: R, zomb: 0, nice: 0, flag: 0x00000200
+ uid: 1000, gid: 1000, pid: 27395, ppid: 1130, pgrp: 27395, sid: 1130
+ fname: a.out, psargs: ./a.out
+ CORE 128 SIGINFO
+ si_signo: 11, si_errno: 0, si_code: 1
+ fault address: 0x12345678
+ CORE 160 AUXV
+ SYSINFO: 0xb77fc414
+ SYSINFO_EHDR: 0xb77fc000
+ HWCAP: 0x780abfd <fpu de pse tsc msr pae mce cx8 apic sep pge cmov mmx fxsr sse sse2>
+ PAGESZ: 4096
+ CLKTCK: 100
+ PHDR: 0x8048034
+ PHENT: 32
+ PHNUM: 9
+ BASE: 0
+ FLAGS: 0
+ ENTRY: 0x80482f0
+ UID: 1000
+ EUID: 1000
+ GID: 1000
+ EGID: 1000
+ SECURE: 0
+ RANDOM: 0xbfab70eb
+ EXECFN: 0xbfab7ff4
+ PLATFORM: 0xbfab70fb
+ NULL
+ CORE 275 FILE
+ 9 files:
+ 08048000-08049000 00000000 4096 /tmp/a.out
+ 08049000-0804a000 00000000 4096 /tmp/a.out
+ 0804a000-0804b000 00001000 4096 /tmp/a.out
+ 4f744000-4f763000 00000000 126976 /usr/lib/ld-2.18.so
+ 4f764000-4f765000 0001f000 4096 /usr/lib/ld-2.18.so
+ 4f765000-4f766000 00020000 4096 /usr/lib/ld-2.18.so
+ 4f768000-4f920000 00000000 1802240 /usr/lib/libc-2.18.so
+ 4f920000-4f922000 001b8000 8192 /usr/lib/libc-2.18.so
+ 4f922000-4f923000 001ba000 4096 /usr/lib/libc-2.18.so
+ LINUX 48 386_TLS
+ index: 6, base: 0xb77da700, limit: 0x000fffff, flags: 0x00000051
+ index: 7, base: 0x00000000, limit: 0x00000000, flags: 0x00000028
+ index: 8, base: 0x00000000, limit: 0x00000000, flags: 0x00000028
+EOF
+
exit 0
diff --git a/tests/testfile_i686_core.bz2 b/tests/testfile_i686_core.bz2
new file mode 100644
index 00000000..8412776e
--- /dev/null
+++ b/tests/testfile_i686_core.bz2
Binary files differ