1 ## Test tools are able to dump different types of notes.
3 # RUN: yaml2obj --docnum=1 %s -o %t1.so
4 # RUN: llvm-readelf --notes %t1.so | FileCheck %s --check-prefix=GNU --strict-whitespace --match-full-lines
5 # RUN: llvm-readobj --notes %t1.so | FileCheck %s --check-prefix=LLVM
6 # RUN: llvm-objcopy --strip-sections %t1.so %t1.stripped.so
7 # RUN: llvm-readelf --notes %t1.stripped.so | FileCheck %s --check-prefix=GNU-STRIPPED --strict-whitespace --match-full-lines
8 # RUN: llvm-readobj --notes %t1.stripped.so | FileCheck %s --check-prefix=LLVM-STRIPPED
10 # GNU:Displaying notes found in: .note.ABI-tag
11 # GNU-NEXT: Owner Data size Description
12 # GNU-NEXT: GNU 0x00000010 NT_GNU_ABI_TAG (ABI version tag)
13 # GNU-NEXT: OS: Linux, ABI: 2.6.32
15 # GNU-NEXT:Displaying notes found in: .note.gnu.build-id
16 # GNU-NEXT: Owner Data size Description
17 # GNU-NEXT: GNU 0x00000010 NT_GNU_BUILD_ID (unique build ID bitstring)
18 # GNU-NEXT: Build ID: 4fcb712aa6387724a9f465a32cd8c14b
20 # GNU-NEXT:Displaying notes found in: .note.gnu.gold-version
21 # GNU-NEXT: Owner Data size Description
22 # GNU-NEXT: GNU 0x00000009 NT_GNU_GOLD_VERSION (gold version)
23 # GNU-NEXT: Version: gold 1.11
25 # GNU-NEXT:Displaying notes found in: .note.gnu.unknown
26 # GNU-NEXT: Owner Data size Description
27 # GNU-NEXT: GNU 0x00000004 Unknown note type: (0x0000abcd)
28 # GNU-NEXT: description data: 61 62 63 64
32 # LLVM-NEXT: NoteSection {
33 # LLVM-NEXT: Name: .note.ABI-tag
34 # LLVM-NEXT: Offset: 0x78
35 # LLVM-NEXT: Size: 0x20
37 # LLVM-NEXT: Owner: GNU
38 # LLVM-NEXT: Data size: 0x10
39 # LLVM-NEXT: Type: NT_GNU_ABI_TAG (ABI version tag)
40 # LLVM-NEXT: OS: Linux
41 # LLVM-NEXT: ABI: 2.6.32
44 # LLVM-NEXT: NoteSection {
45 # LLVM-NEXT: Name: .note.gnu.build-id
46 # LLVM-NEXT: Offset: 0x98
47 # LLVM-NEXT: Size: 0x20
49 # LLVM-NEXT: Owner: GNU
50 # LLVM-NEXT: Data size: 0x10
51 # LLVM-NEXT: Type: NT_GNU_BUILD_ID (unique build ID bitstring)
52 # LLVM-NEXT: Build ID: 4fcb712aa6387724a9f465a32cd8c14b
55 # LLVM-NEXT: NoteSection {
56 # LLVM-NEXT: Name: .note.gnu.gold-version
57 # LLVM-NEXT: Offset: 0xB8
58 # LLVM-NEXT: Size: 0x1C
60 # LLVM-NEXT: Owner: GNU
61 # LLVM-NEXT: Data size: 0x9
62 # LLVM-NEXT: Type: NT_GNU_GOLD_VERSION (gold version)
63 # LLVM-NEXT: Version: gold 1.11
66 # LLVM-NEXT: NoteSection {
67 # LLVM-NEXT: Name: .note.gnu.unknown
68 # LLVM-NEXT: Offset: 0xD4
69 # LLVM-NEXT: Size: 0x14
71 # LLVM-NEXT: Owner: GNU
72 # LLVM-NEXT: Data size: 0x4
73 # LLVM-NEXT: Type: Unknown (0x0000abcd)
74 # LLVM-NEXT: Description data (
75 # LLVM-NEXT: 0000: 61626364 |abcd|
81 ## Note: the section name is <?> here because the section header table is not present.
82 # LLVM-STRIPPED: Notes [
83 # LLVM-STRIPPED-NEXT: NoteSection {
84 # LLVM-STRIPPED-NEXT: Name: <?>
85 # LLVM-STRIPPED-NEXT: Offset: 0x78
86 # LLVM-STRIPPED-NEXT: Size: 0x20
87 # LLVM-STRIPPED-NEXT: Note {
88 # LLVM-STRIPPED-NEXT: Owner: GNU
89 # LLVM-STRIPPED-NEXT: Data size: 0x10
90 # LLVM-STRIPPED-NEXT: Type: NT_GNU_BUILD_ID (unique build ID bitstring)
91 # LLVM-STRIPPED-NEXT: Build ID: 4fcb712aa6387724a9f465a32cd8c14b
92 # LLVM-STRIPPED-NEXT: }
93 # LLVM-STRIPPED-NEXT: }
94 # LLVM-STRIPPED-NEXT: ]
96 ## Note: offset and length printed instead of "found in: .note.gnu.build-id"
97 ## because the section header table is not present.
98 # GNU-STRIPPED:Displaying notes found at file offset 0x00000078 with length 0x00000020:
99 # GNU-STRIPPED-NEXT: Owner Data size Description
100 # GNU-STRIPPED-NEXT: GNU 0x00000010 NT_GNU_BUILD_ID (unique build ID bitstring)
101 # GNU-STRIPPED-NEXT: Build ID: 4fcb712aa6387724a9f465a32cd8c14b
108 EPhEntSize: [[PHENTSIZE=<none>]]
109 EShNum: [[SHNUM=<none>]]
111 - Name: .note.ABI-tag
113 AddressAlign: 0x0000000000000004
114 Content: 040000001000000001000000474E550000000000020000000600000020000000
115 - Name: .note.gnu.build-id
118 Address: 0x0000000000400120
119 AddressAlign: 0x0000000000000004
120 Content: 040000001000000003000000474E55004FCB712AA6387724A9F465A32CD8C14B
121 - Name: .note.gnu.gold-version
123 AddressAlign: 0x0000000000000004
124 Content: 040000000900000004000000474E5500676F6C6420312E3131000000
125 - Name: .note.gnu.unknown
127 AddressAlign: 0x0000000000000004
128 Content: 0400000004000000cdab0000474E550061626364
132 FirstSec: .note.gnu.build-id
133 LastSec: .note.gnu.build-id
135 ## Test tools report an error if a note section has an invalid offset
136 ## that goes past the end of file.
138 # RUN: yaml2obj --docnum=2 -DSHOFFSET=0xffff0000 %s -o %t2.so
139 # RUN: llvm-readelf --notes %t2.so 2>&1 | FileCheck -DFILE=%t2.so %s --check-prefix=ERR1-GNU
140 # RUN: llvm-readobj --notes %t2.so 2>&1 | FileCheck -DFILE=%t2.so %s --check-prefix=ERR1-LLVM
142 # ERR1-GNU: Displaying notes found in: .note
143 # ERR1-GNU-NEXT: Owner Data size Description
144 # ERR1-GNU-NEXT: warning: '[[FILE]]': unable to read notes from the SHT_NOTE section with index 1: invalid offset (0xffff0000) or size (0x0)
148 # ERR1-LLVM-NEXT: NoteSection {
149 # ERR1-LLVM-NEXT: Name: .note
150 # ERR1-LLVM-NEXT: Offset: 0xFFFF0000
151 # ERR1-LLVM-NEXT: Size: 0x0
152 # ERR1-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the SHT_NOTE section with index 1: invalid offset (0xffff0000) or size (0x0)
165 ShOffset: [[SHOFFSET=<none>]]
166 ShSize: [[SHSIZE=<none>]]
168 ## Test tools report an error if a note section has invalid size
169 ## that goes past the end of file.
171 # RUN: yaml2obj --docnum=2 -DSHSIZE=0xffff0000 %s -o %t3.so
172 # RUN: llvm-readelf --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s --check-prefix=ERR2-GNU
173 # RUN: llvm-readobj --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s --check-prefix=ERR2-LLVM
175 # ERR2-GNU: Displaying notes found in: .note
176 # ERR2-GNU-NEXT: Owner Data size Description
177 # ERR2-GNU-NEXT: warning: '[[FILE]]': unable to read notes from the SHT_NOTE section with index 1: invalid offset (0x40) or size (0xffff0000)
181 # ERR2-LLVM-NEXT: NoteSection {
182 # ERR2-LLVM-NEXT: Name: .note
183 # ERR2-LLVM-NEXT: Offset: 0x40
184 # ERR2-LLVM-NEXT: Size: 0xFFFF0000
185 # ERR2-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the SHT_NOTE section with index 1: invalid offset (0x40) or size (0xffff0000)
189 ## Test tools report an error if a note program header has an invalid offset that
190 ## goes past the end of file.
192 # RUN: yaml2obj --docnum=3 -DPHOFFSET=0xffff0000 %s -o %t4.so
193 # RUN: llvm-readelf --notes %t4.so 2>&1 | FileCheck -DFILE=%t4.so %s --check-prefix=ERR3-GNU
194 # RUN: llvm-readobj --notes %t4.so 2>&1 | FileCheck -DFILE=%t4.so %s --check-prefix=ERR3-LLVM
196 # ERR3-GNU: Displaying notes found at file offset 0xffff0000 with length 0x00000000:
197 # ERR3-GNU-NEXT: Owner Data size Description
198 # ERR3-GNU-NEXT: warning: '[[FILE]]': unable to read notes from the PT_NOTE segment with index 0: invalid offset (0xffff0000) or size (0x0)
199 # ERR3-GNU-NOT: {{.}}
202 # ERR3-LLVM-NEXT: NoteSection {
203 # ERR3-LLVM-NEXT: Name: <?>
204 # ERR3-LLVM-NEXT: Offset: 0xFFFF0000
205 # ERR3-LLVM-NEXT: Size: 0x0
206 # ERR3-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the PT_NOTE segment with index 0: invalid offset (0xffff0000) or size (0x0)
217 Offset: [[PHOFFSET=<none>]]
218 FileSize: [[PHFILESIZE=<none>]]
220 ## Test tools report an error if a note program header has an invalid size that
221 ## goes past the end of file.
223 # RUN: yaml2obj --docnum=3 -DPHFILESIZE=0xffff0000 %s -o %t5.so
224 # RUN: llvm-readelf --notes %t5.so 2>&1 | FileCheck -DFILE=%t5.so %s --check-prefix=ERR4-GNU
225 # RUN: llvm-readobj --notes %t5.so 2>&1 | FileCheck -DFILE=%t5.so %s --check-prefix=ERR4-LLVM
227 # ERR4-GNU: Displaying notes found at file offset 0x00000000 with length 0xffff0000:
228 # ERR4-GNU-NEXT: Owner Data size Description
229 # ERR4-GNU-NEXT: warning: '[[FILE]]': unable to read notes from the PT_NOTE segment with index 0: invalid offset (0x0) or size (0xffff0000)
233 # ERR4-LLVM-NEXT: NoteSection {
234 # ERR4-LLVM-NEXT: Name: <?>
235 # ERR4-LLVM-NEXT: Offset: 0x0
236 # ERR4-LLVM-NEXT: Size: 0xFFFF0000
237 # ERR4-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the PT_NOTE segment with index 0: invalid offset (0x0) or size (0xffff0000)
241 ## Check we report a warning when we are unable to locate the PT_NOTE
242 ## segment because of broken program headers.
243 # RUN: yaml2obj --docnum=1 -DPHENTSIZE=1 -DSHNUM=0 %s -o %t6.so
244 # RUN: llvm-readelf --notes %t6.so 2>&1 | FileCheck %s -DFILE=%t6.so --check-prefix=PHENTSIZE-WARN-GNU
245 # RUN: llvm-readobj --notes %t6.so 2>&1 | FileCheck %s -DFILE=%t6.so --check-prefix=PHENTSIZE-WARN-LLVM
247 # PHENTSIZE-WARN-GNU: warning: '[[FILE]]': unable to read program headers to locate the PT_DYNAMIC segment: invalid e_phentsize: 1
248 # PHENTSIZE-WARN-GNU: warning: '[[FILE]]': unable to read program headers to locate the PT_NOTE segment: invalid e_phentsize: 1
250 # PHENTSIZE-WARN-LLVM: Notes [
251 # PHENTSIZE-WARN-LLVM-NEXT: warning: '[[FILE]]': unable to read program headers to locate the PT_NOTE segment: invalid e_phentsize: 1
252 # PHENTSIZE-WARN-LLVM-NEXT: ]