]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
readelf: convert up to a target long in buf_read_ulong.
authorMark Wielaard <mjw@redhat.com>
Thu, 10 Apr 2014 13:02:53 +0000 (15:02 +0200)
committerMark Wielaard <mjw@redhat.com>
Mon, 14 Apr 2014 13:27:04 +0000 (15:27 +0200)
Add a i686 corefile test.

Reported-by: Markus Engel <m_engel@cs.uni-kl.de>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
src/ChangeLog
src/readelf.c
tests/ChangeLog
tests/Makefile.am
tests/run-readelf-mixed-corenote.sh
tests/testfile_i686_core.bz2 [new file with mode: 0644]

index c16626710ceec4592f673150c6f664c46f6ac8b4..a6218e23c550df122db2cf9cbb2c115b29736ed3 100644 (file)
@@ -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
index d2efbaebb7b935df0b8b9440d9492bca208d33b6..ff8048ef471bd3903794b9b952d8331a518fbf92 100644 (file)
@@ -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;
index 776ea66fbe29f1abf22e28f03378a7f29206c8d4..a813f9c1781b94b4d3c0c560d0bdbd11c04ac205 100644 (file)
@@ -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.
index 698e2cfa2a92a47f210844a45f307a2fae36f130..4ff032db8819a06a0005160c10dde1659727d53d 100644 (file)
@@ -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 \
index c176e283533afe9ba73a2ad985dba2bb8d6ff53d..01e4594d3726028be13d41d99133698489af0598 100755 (executable)
@@ -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 (file)
index 0000000..8412776
Binary files /dev/null and b/tests/testfile_i686_core.bz2 differ