1 ## Check how yaml2obj produces SHT_NOTE sections.
3 ## Check we can describe SHT_NOTE using the "Notes" tag. We can define
4 ## notes using names, descriptions and types.
5 ## Check we produce a valid name size and description size fields.
6 ## Check we produce valid paddings.
8 # RUN: yaml2obj --docnum=1 %s -o %t1
9 # RUN: llvm-readobj --sections --section-data %t1 | FileCheck %s --check-prefix=NOTE
13 # NOTE-NEXT: Name: .note.foo (1)
14 # NOTE-NEXT: Type: SHT_NOTE (0x7)
15 # NOTE-NEXT: Flags [ (0x2)
16 # NOTE-NEXT: SHF_ALLOC (0x2)
23 # NOTE-NEXT: AddressAlignment: 0
24 # NOTE-NEXT: EntrySize: 0
25 # NOTE-NEXT: SectionData (
26 ## namesz == (0x03000000) == sizeof("AB") + NUL terminator.
27 ## descsz == (0x00000000) for an empty description.
28 ## Check we produce a valid 2 bytes zeroes padding after the Name.
29 # NOTE-NEXT: 0000: 03000000 00000000 FF000000 41420000 |............AB..|
30 ## namesz == (0x04000000) == sizeof("ABC") + NUL terminator.
31 ## descsz == (0x06000000) == sizeof("123456").
32 ## Check we produce a valid (zero align to 4) 1 byte padding after the Name.
33 ## Check we produce a valid (zero align to 4) 2 bytes padding after the Desc.
34 # NOTE-NEXT: 0010: 04000000 03000000 FE000000 41424300 |............ABC.|
35 # NOTE-NEXT: 0020: 12345600 |.4V.|
55 ## Check that for 32-bit little-endian case we produce the same section content.
57 # RUN: yaml2obj --docnum=2 %s -o %t2
58 # RUN: llvm-readobj --sections --section-data %t2 | FileCheck %s --check-prefix=NOTE
77 ## Check big-endian 32/64 bit cases.
78 ## Check they produce the same content.
80 # RUN: yaml2obj --docnum=3 %s -o %t3
81 # RUN: llvm-readobj --sections --section-data %t3 | FileCheck %s --check-prefix=NOTE-BE
82 # RUN: yaml2obj --docnum=4 %s -o %t4
83 # RUN: llvm-readobj --sections --section-data %t4 | FileCheck %s --check-prefix=NOTE-BE
85 # NOTE-BE: Name: .note.foo
86 # NOTE-BE: SectionData (
87 # NOTE-BE-NEXT: 0000: 00000004 00000003 000000FE 41424300 |
88 # NOTE-BE-NEXT: 0010: 12345600 |
117 ## Check that 'Type' field is mandatory.
119 # RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=TYPE-REQ
120 # TYPE-REQ: error: missing required key 'Type'
134 ## Check that neither `Name` nor `Desc` are mandatory fields.
136 # RUN: yaml2obj --docnum=6 %s -o %t6
137 # RUN: llvm-readobj --sections --section-data %t6 | FileCheck %s --check-prefix=NAME-DESC
139 # NAME-DESC: Name: .note.foo
140 # NAME-DESC: SectionData (
141 # NAME-DESC-NEXT: 0000: 00000000 00000000 FF000000 |
155 ## Check we can use the "Content" tag to specify any data for SHT_NOTE sections.
157 # RUN: yaml2obj --docnum=7 %s -o %t7
158 # RUN: llvm-readobj --sections --section-data %t7 | FileCheck %s --check-prefix=CONTENT
160 # CONTENT: Name: .note.foo
161 # CONTENT: SectionData (
162 # CONTENT-NEXT: 0000: 11223344 55 |
173 Content: "1122334455"
175 ## Check we emit an empty section if neither "Content", "Size" nor "Notes" were set.
177 # RUN: yaml2obj --docnum=8 %s -o %t8
178 # RUN: llvm-readelf --sections %t8 | FileCheck %s --check-prefix=NO-TAGS
180 # NO-TAGS: [Nr] Name Type Address Off Size
181 # NO-TAGS: [ 1] .note.foo NOTE 0000000000000000 000040 000000
192 ## "Content" and "Notes" cannot be used together to describe the SHT_NOTE section.
194 # RUN: not yaml2obj --docnum=9 %s 2>&1 | FileCheck %s --check-prefix=CONTENT-NOTES
196 # CONTENT-NOTES: error: "Notes" cannot be used with "Content" or "Size"
209 ## "Size" and "Notes" cannot be used together to describe the SHT_NOTE section.
211 # RUN: not yaml2obj --docnum=10 %s 2>&1 | FileCheck %s --check-prefix=CONTENT-NOTES
224 ## Check we can use only "Size" to create a SHT_NOTE section.
226 # RUN: yaml2obj --docnum=11 %s -o %t11
227 # RUN: llvm-readobj --sections --section-data %t11 | FileCheck %s --check-prefix=SIZE
229 # SIZE: Name: .note.foo
230 # SIZE: SectionData (
231 # SIZE-NEXT: 0000: 00000000 00000000 00000000 00000000 |
232 # SIZE-NEXT: 0010: 00 |
245 ## Check we can use "Size" and "Content" together to create a SHT_NOTE section.
247 # RUN: yaml2obj --docnum=12 %s -o %t12
248 # RUN: llvm-readobj --sections --section-data %t12 | FileCheck %s --check-prefix=SIZE-CONTENT
250 # SIZE-CONTENT: Name: .note.sizegr
251 # SIZE-CONTENT: SectionData (
252 # SIZE-CONTENT-NEXT: 0000: 11223300 00 |
253 # SIZE-CONTENT-NEXT: )
255 # SIZE-CONTENT: Name: .note.sizeeq
256 # SIZE-CONTENT: SectionData (
257 # SIZE-CONTENT-NEXT: 0000: 112233 |
258 # SIZE-CONTENT-NEXT: )
275 ## Check that when "Size" and "Content" are used together, the size
276 ## must be greater than or equal to the content size.
278 # RUN: not yaml2obj --docnum=13 %s 2>&1 | FileCheck %s --check-prefix=SIZE-CONTENT-ERR
279 # SIZE-CONTENT-ERR: error: Section size must be greater than or equal to the content size
292 ## Check we can't use "Size" and "Notes" tags together.
294 # RUN: not yaml2obj --docnum=14 %s 2>&1 | FileCheck %s --check-prefix=CONTENT-NOTES
307 ## Check that we can use NT_* names for the note type.
309 # RUN: yaml2obj --docnum=15 %s -o %t15
310 # RUN: llvm-readobj --sections --section-data %t15 | FileCheck %s --check-prefix=TEXTUAL-TYPE
312 # TEXTUAL-TYPE: Name: .note.foo
313 # TEXTUAL-TYPE: SectionData (
314 # TEXTUAL-TYPE-NEXT: 0000: 03000000 00000000 03000000 41420000 |............AB..|
315 # TEXTUAL-TYPE-NEXT: 0010: 04000000 03000000 01000000 41424300 |............ABC.|
316 # TEXTUAL-TYPE-NEXT: 0020: 12345600 |.4V.|
317 # TEXTUAL-TYPE-NEXT: )
332 Type: NT_GNU_BUILD_ID