1 ## Test that NT_FILE sections in core files are interpreted correctly.
3 # RUN: yaml2obj %s -o %t.o
4 # RUN: llvm-readelf --notes %t.o | FileCheck %s --check-prefix=GNU
5 # RUN: llvm-readobj --notes %t.o | FileCheck %s --check-prefix=LLVM
6 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --notes %t.o | FileCheck %s --check-prefix=JSON
8 ## llvm-mc doesn't support generating ET_CORE files; the 'Content' field was
9 ## generated with the following steps:
10 # $ llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu tmp.s -o tmp.o
11 # $ bin/llvm-objcopy --dump-section=.note.foo=tmp.txt tmp.o /dev/null
12 # $ xxd -p tmp.txt | tr -d '\n'; echo
13 ## Using the following input:
14 # .section ".note.foo", "a"
16 # .long 5 /* namesz */
17 # .long end - begin /* descsz */
18 # .long 0x46494c45 /* type = NT_FILE */
22 # .quad 3 /* 3 file mappings */
23 # .quad 4096 /* page size */
24 # .quad 0x1000 /* start #1 */
25 # .quad 0x2000 /* end #1 */
26 # .quad 0x3000 /* offset #1 */
27 # .quad 0x4000 /* start #2 */
28 # .quad 0x5000 /* end #2 */
29 # .quad 0x6000 /* offset #2 */
30 # .quad 0x7000 /* start #3 */
31 # .quad 0x8000 /* end #3 */
32 # .quad 0x9000 /* offset #3 */
33 # .asciz "/path/to/a.out"
34 # .asciz "/path/to/libc.so"
47 Content: 0500000080000000454C4946434F524500000000030000000000000000100000000000000010000000000000002000000000000000300000000000000040000000000000005000000000000000600000000000000070000000000000008000000000000000900000000000002F706174682F746F2F612E6F7574002F706174682F746F2F6C6962632E736F005B737461636B5D00
53 # GNU: Displaying notes found
54 # GNU-NEXT: Owner Data size Description
55 # GNU-NEXT: CORE 0x00000080 NT_FILE (mapped files)
56 # GNU-NEXT: Page size: 4096
57 # GNU-NEXT: Start End Page Offset
58 # GNU-NEXT: 0x0000000000001000 0x0000000000002000 0x0000000000003000
59 # GNU-NEXT: /path/to/a.out
60 # GNU-NEXT: 0x0000000000004000 0x0000000000005000 0x0000000000006000
61 # GNU-NEXT: /path/to/libc.so
62 # GNU-NEXT: 0x0000000000007000 0x0000000000008000 0x0000000000009000
66 # LLVM: NoteSections [
67 # LLVM-NEXT: NoteSection {
68 # LLVM-NEXT: Name: <?>
73 # LLVM-NEXT: Owner: CORE
74 # LLVM-NEXT: Data size: 0x80
75 # LLVM-NEXT: Type: NT_FILE (mapped files)
76 # LLVM-NEXT: Page Size: 4096
77 # LLVM-NEXT: Mappings [
79 # LLVM-NEXT: Start: 0x1000
80 # LLVM-NEXT: End: 0x2000
81 # LLVM-NEXT: Offset: 0x3000
82 # LLVM-NEXT: Filename: /path/to/a.out
85 # LLVM-NEXT: Start: 0x4000
86 # LLVM-NEXT: End: 0x5000
87 # LLVM-NEXT: Offset: 0x6000
88 # LLVM-NEXT: Filename: /path/to/libc.so
91 # LLVM-NEXT: Start: 0x7000
92 # LLVM-NEXT: End: 0x8000
93 # LLVM-NEXT: Offset: 0x9000
94 # LLVM-NEXT: Filename: [stack]
102 # JSON: "NoteSections": [
104 # JSON-NEXT: "NoteSection": {
105 # JSON-NEXT: "Name": "<?>",
106 # JSON-NEXT: "Offset": 120,
107 # JSON-NEXT: "Size": 148,
108 # JSON-NEXT: "Notes": [
110 # JSON-NEXT: "Owner": "CORE",
111 # JSON-NEXT: "Data size": 128,
112 # JSON-NEXT: "Type": "NT_FILE (mapped files)",
113 # JSON-NEXT: "Page Size": 4096,
114 # JSON-NEXT: "Mappings": [
116 # JSON-NEXT: "Start": 4096,
117 # JSON-NEXT: "End": 8192,
118 # JSON-NEXT: "Offset": 12288,
119 # JSON-NEXT: "Filename": "/path/to/a.out"
122 # JSON-NEXT: "Start": 16384,
123 # JSON-NEXT: "End": 20480,
124 # JSON-NEXT: "Offset": 24576,
125 # JSON-NEXT: "Filename": "/path/to/libc.so"
128 # JSON-NEXT: "Start": 28672,
129 # JSON-NEXT: "End": 32768,
130 # JSON-NEXT: "Offset": 36864,
131 # JSON-NEXT: "Filename": "[stack]"