1#!/usr/local/bin/bash
2# Copyright (C) 2012, 2013, 2014 Red Hat, Inc.
3# Copyright (C) H.J. Lu <hjl.tools@gmail.com>, 2015.
4# This file is part of elfutils.
5#
6# This file is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3 of the License, or
9# (at your option) any later version.
10#
11# elfutils is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19. $srcdir/test-subr.sh
20
21testfiles testfile63
22
23testrun_compare ${abs_top_builddir}/src/readelf -n testfile63 <<\EOF
24
25Note segment of 892 bytes at offset 0x274:
26  Owner          Data size  Type
27  CORE                 148  PRSTATUS
28    info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11
29    sigpend: <>
30    sighold: <>
31    pid: 11087, ppid: 11063, pgrp: 11087, sid: 11063
32    utime: 0.000000, stime: 0.010000, cutime: 0.000000, cstime: 0.000000
33    orig_r0: -1, fpvalid: 1
34    r0:             1  r1:   -1091672508  r2:   -1091672500
35    r3:             0  r4:             0  r5:             0
36    r6:         33728  r7:             0  r8:             0
37    r9:             0  r10:  -1225703496  r11:  -1091672844
38    r12:            0  sp:    0xbeee64f4  lr:    0xb6dc3f48
39    pc:    0x00008500  spsr:  0x60000010
40  CORE                 124  PRPSINFO
41    state: 0, sname: R, zomb: 0, nice: 0, flag: 0x00400500
42    uid: 0, gid: 0, pid: 11087, ppid: 11063, pgrp: 11087, sid: 11063
43    fname: a.out, psargs: ./a.out
44  CORE                 144  AUXV
45    HWCAP: 0xe8d7  <swp half thumb fast-mult vfp edsp>
46    PAGESZ: 4096
47    CLKTCK: 100
48    PHDR: 0x8034
49    PHENT: 32
50    PHNUM: 8
51    BASE: 0xb6eee000
52    FLAGS: 0
53    ENTRY: 0x83c0
54    UID: 0
55    EUID: 0
56    GID: 0
57    EGID: 0
58    SECURE: 0
59    RANDOM: 0xbeee674e
60    EXECFN: 0xbeee6ff4
61    PLATFORM: 0xbeee675e
62    NULL
63  CORE                 116  FPREGSET
64    f0: 0x000000000000000000000000  f1: 0x000000000000000000000000
65    f2: 0x000000000000000000000000  f3: 0x000000000000000000000000
66    f4: 0x000000000000000000000000  f5: 0x000000000000000000000000
67    f6: 0x000000000000000000000000  f7: 0x000000000000000000000000
68  LINUX                260  ARM_VFP
69    fpscr: 0x00000000
70    d0:  0x0000000000000000  d1:  0x0000000000000000
71    d2:  0x0000000000000000  d3:  0x0000000000000000
72    d4:  0x0000000000000000  d5:  0x0000000000000000
73    d6:  0x0000000000000000  d7:  0x0000000000000000
74    d8:  0x0000000000000000  d9:  0x0000000000000000
75    d10: 0x0000000000000000  d11: 0x0000000000000000
76    d12: 0x0000000000000000  d13: 0x0000000000000000
77    d14: 0x0000000000000000  d15: 0x0000000000000000
78    d16: 0x0000000000000000  d17: 0x0000000000000000
79    d18: 0x0000000000000000  d19: 0x0000000000000000
80    d20: 0x0000000000000000  d21: 0x0000000000000000
81    d22: 0x0000000000000000  d23: 0x0000000000000000
82    d24: 0x0000000000000000  d25: 0x0000000000000000
83    d26: 0x0000000000000000  d27: 0x0000000000000000
84    d28: 0x0000000000000000  d29: 0x0000000000000000
85    d30: 0x0000000000000000  d31: 0x0000000000000000
86EOF
87
88testfiles testfile67
89testrun_compare ${abs_top_builddir}/src/readelf -n testfile67 <<\EOF
90
91Note segment of 1044 bytes at offset 0xe8:
92  Owner          Data size  Type
93  CORE                 336  PRSTATUS
94    info.si_signo: 4, info.si_code: 0, info.si_errno: 0, cursig: 4
95    sigpend: <>
96    sighold: <>
97    pid: 805, ppid: 804, pgrp: 804, sid: 699
98    utime: 0.000042, stime: 0.000103, cutime: 0.000000, cstime: 0.000000
99    orig_r2: 2571552016, fpvalid: 1
100    pswm:   0x0705c00180000000  pswa:   0x00000000800000d6
101    r0:         4393751543808  r1:         4398002544388
102    r2:                    11  r3:            2571578208
103    r4:            2571702016  r5:         4398003235624
104    r6:            2571580768  r7:            2571702016
105    r8:            2571578208  r9:            2571552016
106    r10:           2571552016  r11:                    0
107    r12:        4398003499008  r13:           2148274656
108    r14:                    0  r15:        4398040761216
109    a0:   0x000003ff  a1:   0xfd54a6f0  a2:   0x00000000  a3:   0x00000000
110    a4:   0x00000000  a5:   0x00000000  a6:   0x00000000  a7:   0x00000000
111    a8:   0x00000000  a9:   0x00000000  a10:  0x00000000  a11:  0x00000000
112    a12:  0x00000000  a13:  0x00000000  a14:  0x00000000  a15:  0x00000000
113  CORE                 136  PRPSINFO
114    state: 0, sname: R, zomb: 0, nice: 0, flag: 0x0000000000400400
115    uid: 0, gid: 0, pid: 805, ppid: 804, pgrp: 804, sid: 699
116    fname: 1, psargs: ./1
117  CORE                 304  AUXV
118    SYSINFO_EHDR: 0
119    HWCAP: 0x37f
120    PAGESZ: 4096
121    CLKTCK: 100
122    PHDR: 0x80000040
123    PHENT: 56
124    PHNUM: 2
125    BASE: 0
126    FLAGS: 0
127    ENTRY: 0x800000d4
128    UID: 0
129    EUID: 0
130    GID: 0
131    EGID: 0
132    SECURE: 0
133    RANDOM: 0x3ffffa8463c
134    EXECFN: 0x3ffffa85ff4
135    PLATFORM: 0x3ffffa8464c
136    NULL
137  CORE                 136  FPREGSET
138    fpc: 0x00000000
139    f0:  0x0000000000000040  f1:  0x4b00000000000000
140    f2:  0x0000000000000041  f3:  0x3ad50b5555555600
141    f4:  0x0000000000000000  f5:  0x0000000000000000
142    f6:  0x0000000000000000  f7:  0x0000000000000000
143    f8:  0x0000000000000000  f9:  0x0000000000000000
144    f10: 0x0000000000000000  f11: 0x0000000000000000
145    f12: 0x0000000000000000  f13: 0x0000000000000000
146    f14: 0x0000000000000000  f15: 0x0000000000000000
147  LINUX                  8  S390_LAST_BREAK
148    last_break: 0x000003fffd75ccbe
149  LINUX                  4  S390_SYSTEM_CALL
150    system_call: 0
151EOF
152
153testfiles testfile68
154testrun_compare ${abs_top_builddir}/src/readelf -n testfile68 <<\EOF
155
156Note segment of 852 bytes at offset 0x94:
157  Owner          Data size  Type
158  CORE                 224  PRSTATUS
159    info.si_signo: 4, info.si_code: 0, info.si_errno: 0, cursig: 4
160    sigpend: <>
161    sighold: <>
162    pid: 839, ppid: 838, pgrp: 838, sid: 699
163    utime: 0.000043, stime: 0.000102, cutime: 0.000000, cstime: 0.000000
164    orig_r2: -1723388288, fpvalid: 1
165    pswm:  0x070dc000  pswa:  0x8040009a
166    r0:            0  r1:    -43966716  r2:           11  r3:  -1723238816
167    r4:  -1723265280  r5:    -43275480  r6:  -1723245280  r7:  -1723265280
168    r8:  -1723238816  r9:  -1723388288  r10: -1723388288  r11:           0
169    r12:   -43012096  r13: -2146692640  r14:           0  r15:  2139883440
170    a0:   0x000003ff  a1:   0xfd54a6f0  a2:   0x00000000  a3:   0x00000000
171    a4:   0x00000000  a5:   0x00000000  a6:   0x00000000  a7:   0x00000000
172    a8:   0x00000000  a9:   0x00000000  a10:  0x00000000  a11:  0x00000000
173    a12:  0x00000000  a13:  0x00000000  a14:  0x00000000  a15:  0x00000000
174  CORE                 124  PRPSINFO
175    state: 0, sname: R, zomb: 0, nice: 0, flag: 0x00400400
176    uid: 0, gid: 0, pid: 839, ppid: 838, pgrp: 838, sid: 699
177    fname: 2, psargs: ./2
178  CORE                 152  AUXV
179    SYSINFO_EHDR: 0
180    HWCAP: 0x37f
181    PAGESZ: 4096
182    CLKTCK: 100
183    PHDR: 0x400034
184    PHENT: 32
185    PHNUM: 2
186    BASE: 0
187    FLAGS: 0
188    ENTRY: 0x400098
189    UID: 0
190    EUID: 0
191    GID: 0
192    EGID: 0
193    SECURE: 0
194    RANDOM: 0x7f8c090c
195    EXECFN: 0x7f8c1ff4
196    PLATFORM: 0x7f8c091c
197    NULL
198  CORE                 136  FPREGSET
199    fpc: 0x00000000
200    f0:  0x0000000000000040  f1:  0x4b00000000000000
201    f2:  0x0000000000000041  f3:  0x3ad50b5555555600
202    f4:  0x0000000000000000  f5:  0x0000000000000000
203    f6:  0x0000000000000000  f7:  0x0000000000000000
204    f8:  0x0000000000000000  f9:  0x0000000000000000
205    f10: 0x0000000000000000  f11: 0x0000000000000000
206    f12: 0x0000000000000000  f13: 0x0000000000000000
207    f14: 0x0000000000000000  f15: 0x0000000000000000
208  LINUX                  8  S390_LAST_BREAK
209    last_break: 0xfd75ccbe
210  LINUX                  4  S390_SYSTEM_CALL
211    system_call: 0
212  LINUX                 64  S390_HIGH_GPRS
213    high_r0: 0x000003ff, high_r1: 0x000003ff, high_r2: 0x00000000
214    high_r3: 0x00000000, high_r4: 0x00000000, high_r5: 0x000003ff
215    high_r6: 0x00000000, high_r7: 0x00000000, high_r8: 0x00000000
216    high_r9: 0x00000000, high_r10: 0x00000000, high_r11: 0x00000000
217    high_r12: 0x000003ff, high_r13: 0x00000000, high_r14: 0x00000000
218    high_r15: 0x00000000
219EOF
220
221# To reproduce this core dump, do this on x86_64 machine with Linux
222# 3.7 or later:
223# $ gcc -x c <(echo 'int main () { return *(int *)0x12345678; }')
224# $ ./a.out
225testfiles testfile71
226testrun_compare ${abs_top_builddir}/src/readelf -n testfile71 <<\EOF
227
228Note segment of 1476 bytes at offset 0x430:
229  Owner          Data size  Type
230  CORE                 336  PRSTATUS
231    info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11
232    sigpend: <>
233    sighold: <>
234    pid: 9664, ppid: 2868, pgrp: 9664, sid: 2868
235    utime: 0.000000, stime: 0.004000, cutime: 0.000000, cstime: 0.000000
236    orig_rax: -1, fpvalid: 0
237    r15:                       0  r14:                       0
238    r13:         140734971656848  r12:                 4195328
239    rbp:      0x00007fff69fe39b0  rbx:                       0
240    r11:            266286012928  r10:         140734971656256
241    r9:                        0  r8:             266289790592
242    rax:               305419896  rcx:                 4195584
243    rdx:         140734971656872  rsi:         140734971656856
244    rdi:                       1  rip:      0x00000000004004f9
245    rflags:   0x0000000000010246  rsp:      0x00007fff69fe39b0
246    fs.base:   0x00007fa1c8933740  gs.base:   0x0000000000000000
247    cs: 0x0033  ss: 0x002b  ds: 0x0000  es: 0x0000  fs: 0x0000  gs: 0x0000
248  CORE                 136  PRPSINFO
249    state: 0, sname: R, zomb: 0, nice: 0, flag: 0x0000000000000200
250    uid: 1000, gid: 1000, pid: 9664, ppid: 2868, pgrp: 9664, sid: 2868
251    fname: a.out, psargs: ./a.out
252  CORE                 128  SIGINFO
253    si_signo: 11, si_errno: 0, si_code: 1
254    fault address: 0x12345678
255  CORE                 304  AUXV
256    SYSINFO_EHDR: 0x7fff69ffe000
257    HWCAP: 0xafebfbff  <fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss tm pbe>
258    PAGESZ: 4096
259    CLKTCK: 100
260    PHDR: 0x400040
261    PHENT: 56
262    PHNUM: 9
263    BASE: 0
264    FLAGS: 0
265    ENTRY: 0x400400
266    UID: 1000
267    EUID: 1000
268    GID: 1000
269    EGID: 1000
270    SECURE: 0
271    RANDOM: 0x7fff69fe3d19
272    EXECFN: 0x7fff69fe4ff0
273    PLATFORM: 0x7fff69fe3d29
274    NULL
275  CORE                 469  FILE
276    10 files:
277      00400000-00401000 00000000 4096                /home/petr/a.out
278      00600000-00601000 00000000 4096                /home/petr/a.out
279      00601000-00602000 00001000 4096                /home/petr/a.out
280      3dffa00000-3dffa21000 00000000 135168          /usr/lib64/ld-2.17.so
281      3dffc20000-3dffc21000 00020000 4096            /usr/lib64/ld-2.17.so
282      3dffc21000-3dffc22000 00021000 4096            /usr/lib64/ld-2.17.so
283      3dffe00000-3dfffb6000 00000000 1794048         /usr/lib64/libc-2.17.so
284      3dfffb6000-3e001b6000 001b6000 2097152         /usr/lib64/libc-2.17.so
285      3e001b6000-3e001ba000 001b6000 16384           /usr/lib64/libc-2.17.so
286      3e001ba000-3e001bc000 001ba000 8192            /usr/lib64/libc-2.17.so
287EOF
288
289# To reproduce this core dump, do this on an aarch64 machine:
290# $ gcc -x c <(echo 'int main () { return *(int *)0x12345678; }')
291# $ ./a.out
292testfiles testfile_aarch64_core
293testrun_compare ${abs_top_builddir}/src/readelf -n testfile_aarch64_core <<\EOF
294
295Note segment of 2512 bytes at offset 0x270:
296  Owner          Data size  Type
297  CORE                 392  PRSTATUS
298    info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11
299    sigpend: <>
300    sighold: <>
301    pid: 16547, ppid: 3822, pgrp: 16547, sid: 3822
302    utime: 0.010000, stime: 0.000000, cutime: 0.000000, cstime: 0.000000
303    pc: 0x0000000000400548, pstate: 0x0000000060000000, fpvalid: 1
304    x0:             305419896  x1:          548685596648
305    x2:          548685596664  x3:               4195648
306    x4:                     0  x5:          548536191688
307    x6:                     0  x7:  -6341196323062964528
308    x8:                   135  x9:            4294967295
309    x10:              4195026  x11:               184256
310    x12:                  144  x13:                   15
311    x14:         548536635328  x15:                    0
312    x16:         548534815304  x17:              4262024
313    x18:         548685596000  x19:                    0
314    x20:                    0  x21:              4195296
315    x22:                    0  x23:                    0
316    x24:                    0  x25:                    0
317    x26:                    0  x27:                    0
318    x28:                    0  x29:         548685596320
319    x30:         548534815544  sp:    0x0000007fc035c6a0
320  CORE                 136  PRPSINFO
321    state: 0, sname: R, zomb: 0, nice: 0, flag: 0x0000000000400400
322    uid: 0, gid: 0, pid: 16547, ppid: 3822, pgrp: 16547, sid: 3822
323    fname: a.out, psargs: ./a.out
324  CORE                 128  SIGINFO
325    si_signo: 11, si_errno: 0, si_code: 1
326    fault address: 0x12345678
327  CORE                 304  AUXV
328    SYSINFO_EHDR: 0x7fb7500000
329    HWCAP: 0x3
330    PAGESZ: 65536
331    CLKTCK: 100
332    PHDR: 0x400040
333    PHENT: 56
334    PHNUM: 7
335    BASE: 0x7fb7520000
336    FLAGS: 0
337    ENTRY: 0x4003e0
338    UID: 0
339    EUID: 0
340    GID: 0
341    EGID: 0
342    SECURE: 0
343    RANDOM: 0x7fc035c9e8
344    EXECFN: 0x7fc035fff0
345    PLATFORM: 0x7fc035c9f8
346    NULL
347  CORE                 306  FILE
348    6 files:
349      00400000-00410000 00000000 65536               /root/elfutils/build/a.out
350      00410000-00420000 00000000 65536               /root/elfutils/build/a.out
351      7fb7370000-7fb74d0000 00000000 1441792         /usr/lib64/libc-2.17.so
352      7fb74d0000-7fb74f0000 00150000 131072          /usr/lib64/libc-2.17.so
353      7fb7520000-7fb7540000 00000000 131072          /usr/lib64/ld-2.17.so
354      7fb7540000-7fb7550000 00010000 65536           /usr/lib64/ld-2.17.so
355  CORE                 528  FPREGSET
356    fpsr: 0x00000000, fpcr: 0x00000000
357    v0:  0x00000000000af54b000000000000fe02
358    v1:  0x00000000000000000000000000000000
359    v2:  0x00000000000000000000000000000000
360    v3:  0x00000000000000000000000000000000
361    v4:  0x00000000000000000000000000000000
362    v5:  0x00000000000000000000000000000000
363    v6:  0x00000000000000000000000000000000
364    v7:  0x00000000000000000000000000000000
365    v8:  0x00000000000000000000000000000000
366    v9:  0x00000000000000000000000000000000
367    v10: 0x00000000000000000000000000000000
368    v11: 0x00000000000000000000000000000000
369    v12: 0x00000000000000000000000000000000
370    v13: 0x00000000000000000000000000000000
371    v14: 0x00000000000000000000000000000000
372    v15: 0x00000000000000000000000000000000
373    v16: 0x00000000000000000000000000000000
374    v17: 0x00000000000000000000000000000000
375    v18: 0x00000000000000000000000000000000
376    v19: 0x00000000000000000000000000000000
377    v20: 0x00000000000000000000000000000000
378    v21: 0x00000000000000000000000000000000
379    v22: 0x00000000000000000000000000000000
380    v23: 0x00000000000000000000000000000000
381    v24: 0x00000000000000000000000000000000
382    v25: 0x00000000000000000000000000000000
383    v26: 0x00000000000000000000000000000000
384    v27: 0x00000000000000000000000000000000
385    v28: 0x00000000000000000000000000000000
386    v29: 0x00000000000000000000000000000000
387    v30: 0x00000000000000000000000000000000
388    v31: 0x00000000000000000000000000000000
389  LINUX                  8  ARM_TLS
390    tls: 0x0000007fb73606f0
391  LINUX                264  ARM_HW_BREAK
392    dbg_info: 0x00000610
393    DBGBVR0_EL1: 0x0000000000000000, DBGBCR0_EL1: 0x00000000
394    DBGBVR1_EL1: 0x0000000000000000, DBGBCR1_EL1: 0x00000000
395    DBGBVR2_EL1: 0x0000000000000000, DBGBCR2_EL1: 0x00000000
396    DBGBVR3_EL1: 0x0000000000000000, DBGBCR3_EL1: 0x00000000
397    DBGBVR4_EL1: 0x0000000000000000, DBGBCR4_EL1: 0x00000000
398    DBGBVR5_EL1: 0x0000000000000000, DBGBCR5_EL1: 0x00000000
399    DBGBVR6_EL1: 0x0000000000000000, DBGBCR6_EL1: 0x00000000
400    DBGBVR7_EL1: 0x0000000000000000, DBGBCR7_EL1: 0x00000000
401    DBGBVR8_EL1: 0x0000000000000000, DBGBCR8_EL1: 0x00000000
402    DBGBVR9_EL1: 0x0000000000000000, DBGBCR9_EL1: 0x00000000
403    DBGBVR10_EL1: 0x0000000000000000, DBGBCR10_EL1: 0x00000000
404    DBGBVR11_EL1: 0x0000000000000000, DBGBCR11_EL1: 0x00000000
405    DBGBVR12_EL1: 0x0000000000000000, DBGBCR12_EL1: 0x00000000
406    DBGBVR13_EL1: 0x0000000000000000, DBGBCR13_EL1: 0x00000000
407    DBGBVR14_EL1: 0x0000000000000000, DBGBCR14_EL1: 0x00000000
408    DBGBVR15_EL1: 0x0000000000000000, DBGBCR15_EL1: 0x00000000
409  LINUX                264  ARM_HW_WATCH
410    dbg_info: 0x00000610
411    DBGWVR0_EL1: 0x0000000000000000, DBGWCR0_EL1: 0x00000000
412    DBGWVR1_EL1: 0x0000000000000000, DBGWCR1_EL1: 0x00000000
413    DBGWVR2_EL1: 0x0000000000000000, DBGWCR2_EL1: 0x00000000
414    DBGWVR3_EL1: 0x0000000000000000, DBGWCR3_EL1: 0x00000000
415    DBGWVR4_EL1: 0x0000000000000000, DBGWCR4_EL1: 0x00000000
416    DBGWVR5_EL1: 0x0000000000000000, DBGWCR5_EL1: 0x00000000
417    DBGWVR6_EL1: 0x0000000000000000, DBGWCR6_EL1: 0x00000000
418    DBGWVR7_EL1: 0x0000000000000000, DBGWCR7_EL1: 0x00000000
419    DBGWVR8_EL1: 0x0000000000000000, DBGWCR8_EL1: 0x00000000
420    DBGWVR9_EL1: 0x0000000000000000, DBGWCR9_EL1: 0x00000000
421    DBGWVR10_EL1: 0x0000000000000000, DBGWCR10_EL1: 0x00000000
422    DBGWVR11_EL1: 0x0000000000000000, DBGWCR11_EL1: 0x00000000
423    DBGWVR12_EL1: 0x0000000000000000, DBGWCR12_EL1: 0x00000000
424    DBGWVR13_EL1: 0x0000000000000000, DBGWCR13_EL1: 0x00000000
425    DBGWVR14_EL1: 0x0000000000000000, DBGWCR14_EL1: 0x00000000
426    DBGWVR15_EL1: 0x0000000000000000, DBGWCR15_EL1: 0x00000000
427EOF
428
429# To reproduce this core dump, do this on an i686 machine:
430# $ gcc -x c <(echo 'int main () { return *(int *)0x12345678; }')
431# $ ./a.out
432testfiles testfile_i686_core
433testrun_compare ${abs_top_builddir}/src/readelf -n testfile_i686_core <<\EOF
434
435Note segment of 1000 bytes at offset 0x214:
436  Owner          Data size  Type
437  CORE                 144  PRSTATUS
438    info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11
439    sigpend: <>
440    sighold: <>
441    pid: 27395, ppid: 1130, pgrp: 27395, sid: 1130
442    utime: 0.000000, stime: 0.001000, cutime: 0.000000, cstime: 0.000000
443    orig_eax: -1, fpvalid: 0
444    ebx:     1334976512  ecx:    -1239415396  edx:    -1079283900
445    esi:              0  edi:              0  ebp:     0xbfab6f18
446    eax:      305419896  eip:     0x08048408  eflags:  0x00010246
447    esp:     0xbfab6f18
448    ds: 0x007b  es: 0x007b  fs: 0x0000  gs: 0x0033  cs: 0x0073  ss: 0x007b
449  CORE                 124  PRPSINFO
450    state: 0, sname: R, zomb: 0, nice: 0, flag: 0x00000200
451    uid: 1000, gid: 1000, pid: 27395, ppid: 1130, pgrp: 27395, sid: 1130
452    fname: a.out, psargs: ./a.out
453  CORE                 128  SIGINFO
454    si_signo: 11, si_errno: 0, si_code: 1
455    fault address: 0x12345678
456  CORE                 160  AUXV
457    SYSINFO: 0xb77fc414
458    SYSINFO_EHDR: 0xb77fc000
459    HWCAP: 0x780abfd  <fpu de pse tsc msr pae mce cx8 apic sep pge cmov mmx fxsr sse sse2>
460    PAGESZ: 4096
461    CLKTCK: 100
462    PHDR: 0x8048034
463    PHENT: 32
464    PHNUM: 9
465    BASE: 0
466    FLAGS: 0
467    ENTRY: 0x80482f0
468    UID: 1000
469    EUID: 1000
470    GID: 1000
471    EGID: 1000
472    SECURE: 0
473    RANDOM: 0xbfab70eb
474    EXECFN: 0xbfab7ff4
475    PLATFORM: 0xbfab70fb
476    NULL
477  CORE                 275  FILE
478    9 files:
479      08048000-08049000 00000000 4096                /tmp/a.out
480      08049000-0804a000 00000000 4096                /tmp/a.out
481      0804a000-0804b000 00001000 4096                /tmp/a.out
482      4f744000-4f763000 00000000 126976              /usr/lib/ld-2.18.so
483      4f764000-4f765000 0001f000 4096                /usr/lib/ld-2.18.so
484      4f765000-4f766000 00020000 4096                /usr/lib/ld-2.18.so
485      4f768000-4f920000 00000000 1802240             /usr/lib/libc-2.18.so
486      4f920000-4f922000 001b8000 8192                /usr/lib/libc-2.18.so
487      4f922000-4f923000 001ba000 4096                /usr/lib/libc-2.18.so
488  LINUX                 48  386_TLS
489    index: 6, base: 0xb77da700, limit: 0x000fffff, flags: 0x00000051
490    index: 7, base: 0x00000000, limit: 0x00000000, flags: 0x00000028
491    index: 8, base: 0x00000000, limit: 0x00000000, flags: 0x00000028
492EOF
493
494# To reproduce this core dump, do this on x86_64 machine with Linux
495# 3.7 or later:
496# $ gcc -mx32 -x c <(echo 'int main () { return *(int *)0x12345678; }')
497# $ ./a.out
498testfiles testfile-x32-core
499testrun_compare ${abs_top_builddir}/src/readelf -n testfile-x32-core <<\EOF
500
501Note segment of 2548 bytes at offset 0x234:
502  Owner          Data size  Type
503  CORE                 296  PRSTATUS
504    info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11
505    sigpend: <>
506    sighold: <>
507    pid: 6885, ppid: 2792, pgrp: 6885, sid: 2792
508    utime: 0.000000, stime: 0.001000, cutime: 0.000000, cstime: 0.000000
509    orig_rax: -1, fpvalid: 1
510    r15:                       0  r14:                       0
511    r13:              4290830656  r12:                 4194960
512    rbp:      0x00000000ffc0e070  rbx:                       0
513    r11:              4145779200  r10:                       0
514    r9:               4149627024  r8:               4149551744
515    rax:               305419896  rcx:                 4195216
516    rdx:              4290830668  rsi:              4290830660
517    rdi:                       1  rip:      0x0000000000400380
518    rflags:   0x0000000000010246  rsp:      0x00000000ffc0e070
519    fs.base:   0x00000000f7754700  gs.base:   0x0000000000000000
520    cs: 0x0033  ss: 0x002b  ds: 0x002b  es: 0x002b  fs: 0x0063  gs: 0x0000
521  CORE                 124  PRPSINFO
522    state: 0, sname: R, zomb: 0, nice: 0, flag: 0x00406600
523    uid: 1000, gid: 1000, pid: 6885, ppid: 2792, pgrp: 6885, sid: 2792
524    fname: a.out, psargs: ./a.out
525  CORE                 128  SIGINFO
526    si_signo: 11, si_errno: 0, si_code: 1
527    fault address: 0x12345678
528  CORE                 152  AUXV
529    SYSINFO_EHDR: 0xffd49000
530    HWCAP: 0xbfebfbff  <fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe>
531    PAGESZ: 4096
532    CLKTCK: 100
533    PHDR: 0x400034
534    PHENT: 32
535    PHNUM: 8
536    BASE: 0xf7555000
537    FLAGS: 0
538    ENTRY: 0x400290
539    UID: 1000
540    EUID: 1000
541    GID: 1000
542    EGID: 1000
543    SECURE: 0
544    RANDOM: 0xffc0e2cb
545    EXECFN: 0xffc0fff0
546    PLATFORM: 0xffc0e2db
547    NULL
548  CORE                 361  FILE
549    9 files:
550      00400000-00401000 00000000 4096                /export/home/hjl/bugs/gdb/x32-1/a.out
551      00600000-00601000 00000000 4096                /export/home/hjl/bugs/gdb/x32-1/a.out
552      f71a2000-f734f000 00000000 1757184             /usr/libx32/libc-2.20.so
553      f734f000-f754e000 001ad000 2093056             /usr/libx32/libc-2.20.so
554      f754e000-f7551000 001ac000 12288               /usr/libx32/libc-2.20.so
555      f7551000-f7552000 001af000 4096                /usr/libx32/libc-2.20.so
556      f7555000-f7575000 00000000 131072              /usr/libx32/ld-2.20.so
557      f7774000-f7775000 0001f000 4096                /usr/libx32/ld-2.20.so
558      f7775000-f7776000 00020000 4096                /usr/libx32/ld-2.20.so
559  CORE                 512  FPREGSET
560    xmm0:  0x0000000000000000000000000000ff00
561    xmm1:  0x2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f
562    xmm2:  0x00000000000000000000000000000000
563    xmm3:  0x0000000000000000ff00000000000000
564    xmm4:  0x000000000000000000ff000000000000
565    xmm5:  0x00000000000000000000000000000000
566    xmm6:  0x00000000000000000000000000000000
567    xmm7:  0x00000000000000000000000000000000
568    xmm8:  0x00000000000000000000000000000000
569    xmm9:  0x00000000000000000000000000000000
570    xmm10: 0x00000000000000000000000000000000
571    xmm11: 0x00000000000000000000000000000000
572    xmm12: 0x00000000000000000000000000000000
573    xmm13: 0x00000000000000000000000000000000
574    xmm14: 0x00000000000000000000000000000000
575    xmm15: 0x00000000000000000000000000000000
576    st0: 0x00000000000000000000  st1: 0x00000000000000000000
577    st2: 0x00000000000000000000  st3: 0x00000000000000000000
578    st4: 0x00000000000000000000  st5: 0x00000000000000000000
579    st6: 0x00000000000000000000  st7: 0x00000000000000000000
580    mxcsr:   0x0000ffff00001f80
581    fcw: 0x037f  fsw: 0x0000
582  LINUX                832  X86_XSTATE
583EOF
584
585# To reproduce this core dump, do this on an m68k machine:
586# $ gcc -x c <(echo 'int main () { return *(int *)0x12345678; }')
587# $ ./a.out
588testfiles testfile-m68k-core
589testrun_compare ${abs_top_builddir}/src/readelf -n testfile-m68k-core <<\EOF
590
591Note segment of 1056 bytes at offset 0x1f4:
592  Owner          Data size  Type
593  CORE                 154  PRSTATUS
594    info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11
595    sigpend: <>
596    sighold: <>
597    pid: 1963, ppid: 1084, pgrp: 1963, sid: 1084
598    utime: 0.000000, stime: 0.010000, cutime: 0.000000, cstime: 0.000000
599    fpvalid: 1
600    d1:           1  d2:           0  d3: -2146476616  d4: -2146476616
601    d5:           0  d6: -2147393212  d7: -2144827216  a0:  0x12345678
602    a1:  0xefe71460  a2:  0x00000000  a3:  0x80288df8  a4:  0x80000340
603    a5:  0xc017a000  a6:  0xefe71434  d0: -1073595312  a7:  0xefe71434
604    pc:  0x800003fe
605  CORE                 124  PRPSINFO
606    state: 0, sname: R, zomb: 0, nice: 0, flag: 0x00400600
607    uid: 1000, gid: 501, pid: 1963, ppid: 1084, pgrp: 1963, sid: 1084
608    fname: a.out, psargs: ./a.out
609  CORE                 128  SIGINFO
610    si_signo: 11, si_errno: 0, si_code: 1
611    fault address: 0x12345678
612  CORE                 136  AUXV
613    HWCAP: 0
614    PAGESZ: 4096
615    CLKTCK: 100
616    PHDR: 0x80000034
617    PHENT: 32
618    PHNUM: 9
619    BASE: 0xc0000000
620    FLAGS: 0
621    ENTRY: 0x80000340
622    UID: 1000
623    EUID: 1000
624    GID: 501
625    EGID: 501
626    SECURE: 0
627    RANDOM: 0xefe716d9
628    EXECFN: 0xefe71ff4
629    NULL
630  CORE                 281  FILE
631    10 files:
632      80000000-80001000 00000000 4096                /tmp/a.out
633      80003000-80004000 00001000 4096                /tmp/a.out
634      80004000-80005000 00002000 4096                /tmp/a.out
635      c0000000-c001c000 00000000 114688              /lib/ld-2.23.so
636      c001f000-c0020000 0001d000 4096                /lib/ld-2.23.so
637      c0020000-c0021000 0001e000 4096                /lib/ld-2.23.so
638      c0032000-c0177000 00000000 1331200             /lib/libc-2.23.so
639      c0177000-c0178000 00145000 4096                /lib/libc-2.23.so
640      c0178000-c017a000 00144000 8192                /lib/libc-2.23.so
641      c017a000-c017e000 00146000 16384               /lib/libc-2.23.so
642  CORE                 108  FPREGSET
643    fp0: 0x7fff0000ffffffffffffffff  fp1: 0x7fff0000ffffffffffffffff
644    fp2: 0x7fff0000ffffffffffffffff  fp3: 0x7fff0000ffffffffffffffff
645    fp4: 0x7fff0000ffffffffffffffff  fp5: 0x7fff0000ffffffffffffffff
646    fp6: 0x7fff0000ffffffffffffffff  fp7: 0x7fff0000ffffffffffffffff
647EOF
648
649# To reproduce this core dump, do this on a riscv64 machine:
650# $ gcc -x c <(echo 'int main () { return *(int *)0x12345678; }')
651# $ ./a.out
652testfiles testfile-riscv64-core
653testrun_compare ${abs_top_builddir}/src/readelf -n testfile-riscv64-core <<\EOF
654
655Note segment of 1408 bytes at offset 0x388:
656  Owner          Data size  Type
657  CORE                 376  PRSTATUS
658    info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11
659    sigpend: <>
660    sighold: <>
661    pid: 6801, ppid: 1155, pgrp: 6801, sid: 1155
662    utime: 0.000000, stime: 0.110000, cutime: 0.000000, cstime: 0.000000
663    pc: 0x000000000001049a, fpvalid: 0
664    ra:    0x0000002000051c9a  sp:    0x0000003fff981240
665    gp:    0x0000000000012828  tp:    0x00000020000311d0
666    t0:          137439068496  t1:          137439288314
667    t2:                 74672  s0:          274871095888
668    s1:                 66724  a0:                     1
669    a1:          274871096232  a2:          274871096248
670    a3:                     0  a4:          274871095928
671    a5:             305419896  a6:          137440357656
672    a7:                     0  s2:          183254994416
673    s3:          137439062288  s4:                     0
674    s5:          183257703888  s6:          183256061824
675    s7:                     0  s8:          183252656348
676    s9:          183257666368  s10:         183257700608
677    s11:                    0  t3:                130042
678    t4:                     2  t5:                     3
679    t6:                 15632
680  CORE                 136  PRPSINFO
681    state: 0, sname: R, zomb: 0, nice: 0, flag: 0x0000000000400600
682    uid: 0, gid: 0, pid: 6801, ppid: 1155, pgrp: 6801, sid: 1155
683    fname: a.out, psargs: /tmp/a.out
684  CORE                 128  SIGINFO
685    si_signo: 11, si_errno: 0, si_code: 1
686    fault address: 0x12345678
687  CORE                 288  AUXV
688    SYSINFO_EHDR: 0x200001d000
689    HWCAP: 0x1105
690    PAGESZ: 4096
691    CLKTCK: 100
692    PHDR: 0x10040
693    PHENT: 56
694    PHNUM: 9
695    BASE: 0x2000000000
696    FLAGS: 0
697    ENTRY: 0x103e0
698    UID: 0
699    EUID: 0
700    GID: 0
701    EGID: 0
702    SECURE: 0
703    RANDOM: 0x3fff9816d6
704    EXECFN: 0x3fff981fed
705    NULL
706  CORE                 379  FILE
707    9 files:
708      00010000-00011000 00000000 4096                /tmp/a.out
709      00011000-00012000 00000000 4096                /tmp/a.out
710      00012000-00013000 00001000 4096                /tmp/a.out
711      2000000000-200001a000 00000000 106496          /lib64/ld-2.27.so
712      200001a000-200001b000 00019000 4096            /lib64/ld-2.27.so
713      200001b000-200001c000 0001a000 4096            /lib64/ld-2.27.so
714      2000032000-2000151000 00000000 1175552         /lib64/libc-2.27.so
715      2000151000-2000155000 0011e000 16384           /lib64/libc-2.27.so
716      2000155000-2000157000 00122000 8192            /lib64/libc-2.27.so
717EOF
718
719exit 0
720