1 ## Test how we create SHT_RELR sections.
3 ## Test that the content of SHT_RELR sections for 64-bit little endian targets is correct.
4 # RUN: yaml2obj --docnum=1 -D ENCODE=LSB %s -o %t.le64
5 # RUN: llvm-readobj --sections --section-data %t.le64 | FileCheck %s --check-prefix=LE64
7 # LE64: Name: .relr.dyn
8 # LE64-NEXT: Type: SHT_RELR
10 # LE64-NEXT: SHF_ALLOC
12 # LE64-NEXT: Address: 0x0
13 # LE64-NEXT: Offset: 0x40
17 # LE64-NEXT: AddressAlignment: 0
18 # LE64-NEXT: EntrySize: 8
19 # LE64-NEXT: SectionData (
20 # LE64-NEXT: 0000: DDCCBBAA 00000000 2211FFEE 00000000
21 # LE64-NEXT: 0010: 66554433 00000010 AA998877 00000010
24 ## Test that the content of SHT_RELR sections for 64-bit big endian targets is correct.
25 # RUN: yaml2obj --docnum=1 -D ENCODE=MSB %s -o %t.be64
26 # RUN: llvm-readobj --sections --section-data %t.be64 | FileCheck %s --check-prefix=BE64
28 # BE64: Name: .relr.dyn
30 # BE64-NEXT: 0000: 00000000 AABBCCDD 00000000 EEFF1122
31 # BE64-NEXT: 0010: 10000000 33445566 10000000 778899AA
37 Data: ELFDATA2[[ENCODE]]
42 ## Set an arbitrary flag to demonstrate flags are set when requested.
44 Entries: [ 0x00000000AABBCCDD, 0x00000000EEFF1122,
45 0x1000000033445566, 0x10000000778899AA ]
47 ## Test that the content of SHT_RELR sections for 32-bit little endian targets is correct.
48 # RUN: yaml2obj --docnum=2 -D ENCODE=LSB %s -o %t.le32
49 # RUN: llvm-readobj --sections --section-data %t.le32 | FileCheck %s --check-prefix=LE32
51 # LE32: Name: .relr.dyn
52 # LE32-NEXT: Type: SHT_RELR
54 # LE32-NEXT: SHF_ALLOC
56 # LE32-NEXT: Address: 0x0
57 # LE32-NEXT: Offset: 0x34
61 # LE32-NEXT: AddressAlignment: 0
62 # LE32-NEXT: EntrySize: 4
63 # LE32-NEXT: SectionData (
64 # LE32-NEXT: 0000: DDCCBBAA BBAAFFEE BBAAFFEE BCAAFFEE
67 ## Test that the content of SHT_RELR sections for 32-bit big endian targets is correct.
68 # RUN: yaml2obj --docnum=2 -D ENCODE=MSB %s -o %t.be32
69 # RUN: llvm-readobj --sections --section-data %t.be32 | FileCheck %s --check-prefix=BE32
71 # BE32: Name: .relr.dyn
73 # BE32-NEXT: 0000: AABBCCDD EEFFAABB EEFFAABB EEFFAABC |
79 Data: ELFDATA2[[ENCODE]]
84 ## Set an arbitrary flag to demonstrate flags are set when requested.
86 Entries: [ 0xAABBCCDD, 0xEEFFAABB,
87 0xEEFFAABB, 0xEEFFAABC ]
89 ## Check we are able to set an arbitrary sh_entsize.
90 # RUN: yaml2obj --docnum=3 %s -o %t.entsize
91 # RUN: llvm-readelf --sections %t.entsize | FileCheck %s --check-prefix=ENTSIZE
93 # ENTSIZE: [Nr] Name Type Address Off Size ES
94 # ENTSIZE: [ 1] .relr.dyn RELR 00000000 000034 000001 34
107 ## Test we can't use 64-bit offsets/bitmaps when creating a 32-bit object.
108 # RUN: yaml2obj --docnum=4 %s -o %t.nottoolarge
109 # RUN: llvm-readobj --sections --section-data %t.nottoolarge | FileCheck %s --check-prefix=NOT-TOO-LARGE
111 # NOT-TOO-LARGE: Name: .relr.dyn
112 # NOT-TOO-LARGE: SectionData (
113 # NOT-TOO-LARGE-NEXT: 0000: FFFFFFFF
114 # NOT-TOO-LARGE-NEXT: )
116 # RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=TOO-LARGE
117 # TOO-LARGE: error: .relr.dyn: the value is too large for 32-bits: 0x100000000
127 Entries: [ 0x00000000FFFFFFFF ]
137 Entries: [ 0x0000000100000000 ]
139 ## Check we can use the "Content" key with the "Size" key when the size is greater
140 ## than or equal to the content size.
142 # RUN: not yaml2obj --docnum=6 -DSIZE=1 -DCONTENT="'0011'" %s 2>&1 | \
143 # RUN: FileCheck %s --check-prefix=CONTENT-SIZE-ERR
145 # CONTENT-SIZE-ERR: error: Section size must be greater than or equal to the content size
156 Size: [[SIZE=<none>]]
157 Content: [[CONTENT=<none>]]
158 Entries: [[ENTRIES=<none>]]
160 # RUN: yaml2obj --docnum=6 -DSIZE=2 -DCONTENT="'0011'" %s -o %t.cont.size.eq.o
161 # RUN: llvm-readobj --sections --section-data %t.cont.size.eq.o | \
162 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="0011"
164 # RUN: yaml2obj --docnum=6 -DSIZE=3 -DCONTENT="'0011'" %s -o %t.cont.size.gr.o
165 # RUN: llvm-readobj --sections --section-data %t.cont.size.gr.o | \
166 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="001100"
168 # CHECK-CONTENT: Name: .relr.dyn
169 # CHECK-CONTENT-NEXT: Type: SHT_RELR
170 # CHECK-CONTENT-NEXT: Flags [
171 # CHECK-CONTENT-NEXT: ]
172 # CHECK-CONTENT-NEXT: Address:
173 # CHECK-CONTENT-NEXT: Offset:
174 # CHECK-CONTENT-NEXT: Size:
175 # CHECK-CONTENT-NEXT: Link:
176 # CHECK-CONTENT-NEXT: Info:
177 # CHECK-CONTENT-NEXT: AddressAlignment:
178 # CHECK-CONTENT-NEXT: EntrySize: 255
179 # CHECK-CONTENT-NEXT: SectionData (
180 # CHECK-CONTENT-NEXT: 0000: [[DATA]] |
181 # CHECK-CONTENT-NEXT: )
183 ## Check we can use the "Size" key alone to create the section.
185 # RUN: yaml2obj --docnum=6 -DSIZE=3 %s -o %t.size.o
186 # RUN: llvm-readobj --sections --section-data %t.size.o | \
187 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="000000"
189 ## Check we can use the "Content" key alone to create the section.
191 # RUN: yaml2obj --docnum=6 -DCONTENT="'112233'" %s -o %t.content.o
192 # RUN: llvm-readobj --sections --section-data %t.content.o | \
193 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="112233"
195 ## Check we can't use the "Entries" key together with the "Content" or "Size" keys.
197 # RUN: not yaml2obj --docnum=6 -DSIZE=0 -DENTRIES="[]" %s 2>&1 | \
198 # RUN: FileCheck %s --check-prefix=ENTRIES-ERR
199 # RUN: not yaml2obj --docnum=6 -DCONTENT="'00'" -DENTRIES="[]" %s 2>&1 | \
200 # RUN: FileCheck %s --check-prefix=ENTRIES-ERR
202 # ENTRIES-ERR: error: "Entries" cannot be used with "Content" or "Size"
204 ## Check we create an empty section when none of "Size", "Content" or "Entries" are specified.
206 # RUN: yaml2obj %s --docnum=6 -o %t.empty.o
207 # RUN: llvm-readelf --sections --section-data %t.empty.o | \
208 # RUN: FileCheck %s --check-prefix=EMPTY-SEC
210 # EMPTY-SEC: [Nr] Name Type Address Off Size
211 # EMPTY-SEC: [ 1] .relr.dyn RELR 0000000000000000 000040 000000