xref: /llvm-project/llvm/test/tools/yaml2obj/ELF/content-array.yaml (revision a6436b0b3a7fd9f13d7a059a6a78544a7e0b702f)
1*64bae035SGeorgii Rymar## Check we are able to describe the content of a section
2*64bae035SGeorgii Rymar## using the ContentArray key.
3*64bae035SGeorgii Rymar
4*64bae035SGeorgii Rymar## Check we are able to use ContentArray to create multi-line descriptions
5*64bae035SGeorgii Rymar## of section contents with comments on the same line.
6*64bae035SGeorgii Rymar# RUN: yaml2obj --docnum=1 %s -o %t1
7*64bae035SGeorgii Rymar# RUN: llvm-readobj --sections --section-data %t1 | FileCheck %s
8*64bae035SGeorgii Rymar
9*64bae035SGeorgii Rymar# CHECK:      Section {
10*64bae035SGeorgii Rymar# CHECK:        Index: 1
11*64bae035SGeorgii Rymar# CHECK-NEXT:   Name: .foo
12*64bae035SGeorgii Rymar# CHECK-NEXT:   Type: SHT_PROGBITS
13*64bae035SGeorgii Rymar# CHECK-NEXT:   Flags [
14*64bae035SGeorgii Rymar# CHECK-NEXT:   ]
15*64bae035SGeorgii Rymar# CHECK-NEXT:   Address: 0x0
16*64bae035SGeorgii Rymar# CHECK-NEXT:   Offset: 0x40
17*64bae035SGeorgii Rymar# CHECK-NEXT:   Size: 16
18*64bae035SGeorgii Rymar# CHECK-NEXT:   Link: 0
19*64bae035SGeorgii Rymar# CHECK-NEXT:   Info: 0
20*64bae035SGeorgii Rymar# CHECK-NEXT:   AddressAlignment: 0
21*64bae035SGeorgii Rymar# CHECK-NEXT:   EntrySize: 0
22*64bae035SGeorgii Rymar# CHECK-NEXT:   SectionData (
23*64bae035SGeorgii Rymar# CHECK-NEXT:     0000: 11223344 55667788 99AABBCC DDEEFF00
24*64bae035SGeorgii Rymar# CHECK-NEXT:   )
25*64bae035SGeorgii Rymar# CHECK-NEXT: }
26*64bae035SGeorgii Rymar
27*64bae035SGeorgii Rymar--- !ELF
28*64bae035SGeorgii RymarFileHeader:
29*64bae035SGeorgii Rymar  Class: ELFCLASS64
30*64bae035SGeorgii Rymar  Data:  ELFDATA2LSB
31*64bae035SGeorgii Rymar  Type:  ET_DYN
32*64bae035SGeorgii RymarSections:
33*64bae035SGeorgii Rymar  - Name:         .foo
34*64bae035SGeorgii Rymar    Type:         SHT_PROGBITS
35*64bae035SGeorgii Rymar    ContentArray: [ 0x11, 0x22, 0x33, 0x44,                                ## .long 11223344
36*64bae035SGeorgii Rymar                    0x55, 0x66,                                            ## .short 5566.
37*64bae035SGeorgii Rymar                    0x77,                                                  ## .byte 0x77
38*64bae035SGeorgii Rymar                    0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00 ] ## .quad 0x8899aabbccddeeff00
39*64bae035SGeorgii Rymar
40*64bae035SGeorgii Rymar## Check we do not allow using 'Content' and 'ContentArray' at the same time.
41*64bae035SGeorgii Rymar# RUN: not yaml2obj --docnum=2 %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=BOTH
42*64bae035SGeorgii Rymar# BOTH: error: Content and ContentArray can't be used together
43*64bae035SGeorgii Rymar
44*64bae035SGeorgii Rymar--- !ELF
45*64bae035SGeorgii RymarFileHeader:
46*64bae035SGeorgii Rymar  Class: ELFCLASS64
47*64bae035SGeorgii Rymar  Data:  ELFDATA2LSB
48*64bae035SGeorgii Rymar  Type:  ET_DYN
49*64bae035SGeorgii RymarSections:
50*64bae035SGeorgii Rymar  - Name:         .foo
51*64bae035SGeorgii Rymar    Type:         SHT_PROGBITS
52*64bae035SGeorgii Rymar    Content:      [ 0x0 ]
53*64bae035SGeorgii Rymar    ContentArray: [ 0x1 ]
54*64bae035SGeorgii Rymar
55*64bae035SGeorgii Rymar## Check how the "Size" and the "ContentArray" keys can be used together.
56*64bae035SGeorgii Rymar
57*64bae035SGeorgii Rymar## Case A: check that we report an error when the the value of "Size" is less than the content size.
58*64bae035SGeorgii Rymar# RUN: not yaml2obj --docnum=3 -DSIZE=1 %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=SIZE-LESS
59*64bae035SGeorgii Rymar# SIZE-LESS: error: Section size must be greater than or equal to the content size
60*64bae035SGeorgii Rymar
61*64bae035SGeorgii Rymar--- !ELF
62*64bae035SGeorgii RymarFileHeader:
63*64bae035SGeorgii Rymar  Class: ELFCLASS64
64*64bae035SGeorgii Rymar  Data:  ELFDATA2LSB
65*64bae035SGeorgii Rymar  Type:  ET_DYN
66*64bae035SGeorgii RymarSections:
67*64bae035SGeorgii Rymar  - Name:         .foo
68*64bae035SGeorgii Rymar    Type:         SHT_PROGBITS
69*64bae035SGeorgii Rymar    ContentArray: [ 0x11, 0x22 ]
70*64bae035SGeorgii Rymar    Size:         [[SIZE]]
71*64bae035SGeorgii Rymar
72*64bae035SGeorgii Rymar## Case B: check we are able to produce an output when the value of "Size" is equal
73*64bae035SGeorgii Rymar##         to the content size. In this case the "Size" key has no effect.
74*64bae035SGeorgii Rymar# RUN: yaml2obj --docnum=3 -DSIZE=2 %s -o %t3.eq
75*64bae035SGeorgii Rymar# RUN: llvm-readobj --sections --section-data %t3.eq | FileCheck %s --check-prefix=SIZE-EQ
76*64bae035SGeorgii Rymar
77*64bae035SGeorgii Rymar# SIZE-EQ:      Name: .foo
78*64bae035SGeorgii Rymar# SIZE-EQ:      SectionData (
79*64bae035SGeorgii Rymar# SIZE-EQ-NEXT:   0000: 1122 |
80*64bae035SGeorgii Rymar# SIZE-EQ-NEXT: )
81*64bae035SGeorgii Rymar
82*64bae035SGeorgii Rymar## Case C: check we are able to produce an output when the value of "Size" is greater
83*64bae035SGeorgii Rymar##         than the content size. In this case zeroes are added as padding after the
84*64bae035SGeorgii Rymar##         specified content.
85*64bae035SGeorgii Rymar# RUN: yaml2obj --docnum=3 -DSIZE=3 %s -o %t4.gr
86*64bae035SGeorgii Rymar# RUN: llvm-readobj --sections --section-data %t4.gr | FileCheck %s --check-prefix=SIZE-GR
87*64bae035SGeorgii Rymar
88*64bae035SGeorgii Rymar# SIZE-GR:      Name: .foo
89*64bae035SGeorgii Rymar# SIZE-GR:      SectionData (
90*64bae035SGeorgii Rymar# SIZE-GR-NEXT:   0000: 112200 |
91*64bae035SGeorgii Rymar# SIZE-GR-NEXT: )
92