1## Test how we create SHT_RELR sections. 2 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 6 7# LE64: Name: .relr.dyn 8# LE64-NEXT: Type: SHT_RELR 9# LE64-NEXT: Flags [ 10# LE64-NEXT: SHF_ALLOC 11# LE64-NEXT: ] 12# LE64-NEXT: Address: 0x0 13# LE64-NEXT: Offset: 0x40 14# LE64-NEXT: Size: 32 15# LE64-NEXT: Link: 0 16# LE64-NEXT: Info: 0 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 22# LE64-NEXT: ) 23 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 27 28# BE64: Name: .relr.dyn 29# BE64: SectionData ( 30# BE64-NEXT: 0000: 00000000 AABBCCDD 00000000 EEFF1122 31# BE64-NEXT: 0010: 10000000 33445566 10000000 778899AA 32# BE64-NEXT: ) 33 34--- !ELF 35FileHeader: 36 Class: ELFCLASS64 37 Data: ELFDATA2[[ENCODE]] 38 Type: ET_DYN 39Sections: 40 - Name: .relr.dyn 41 Type: SHT_RELR 42## Set an arbitrary flag to demonstrate flags are set when requested. 43 Flags: [ SHF_ALLOC ] 44 Entries: [ 0x00000000AABBCCDD, 0x00000000EEFF1122, 45 0x1000000033445566, 0x10000000778899AA ] 46 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 50 51# LE32: Name: .relr.dyn 52# LE32-NEXT: Type: SHT_RELR 53# LE32-NEXT: Flags [ 54# LE32-NEXT: SHF_ALLOC 55# LE32-NEXT: ] 56# LE32-NEXT: Address: 0x0 57# LE32-NEXT: Offset: 0x34 58# LE32-NEXT: Size: 16 59# LE32-NEXT: Link: 0 60# LE32-NEXT: Info: 0 61# LE32-NEXT: AddressAlignment: 0 62# LE32-NEXT: EntrySize: 4 63# LE32-NEXT: SectionData ( 64# LE32-NEXT: 0000: DDCCBBAA BBAAFFEE BBAAFFEE BCAAFFEE 65# LE32-NEXT: ) 66 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 70 71# BE32: Name: .relr.dyn 72# BE32: SectionData ( 73# BE32-NEXT: 0000: AABBCCDD EEFFAABB EEFFAABB EEFFAABC | 74# BE32-NEXT: ) 75 76--- !ELF 77FileHeader: 78 Class: ELFCLASS32 79 Data: ELFDATA2[[ENCODE]] 80 Type: ET_DYN 81Sections: 82 - Name: .relr.dyn 83 Type: SHT_RELR 84## Set an arbitrary flag to demonstrate flags are set when requested. 85 Flags: [ SHF_ALLOC ] 86 Entries: [ 0xAABBCCDD, 0xEEFFAABB, 87 0xEEFFAABB, 0xEEFFAABC ] 88 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 92 93# ENTSIZE: [Nr] Name Type Address Off Size ES 94# ENTSIZE: [ 1] .relr.dyn RELR 00000000 000034 000001 34 95 96--- !ELF 97FileHeader: 98 Class: ELFCLASS32 99 Data: ELFDATA2LSB 100 Type: ET_DYN 101Sections: 102 - Name: .relr.dyn 103 Type: SHT_RELR 104 EntSize: 0x34 105 Content: "12" 106 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 110 111# NOT-TOO-LARGE: Name: .relr.dyn 112# NOT-TOO-LARGE: SectionData ( 113# NOT-TOO-LARGE-NEXT: 0000: FFFFFFFF 114# NOT-TOO-LARGE-NEXT: ) 115 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 118 119--- !ELF 120FileHeader: 121 Class: ELFCLASS32 122 Data: ELFDATA2LSB 123 Type: ET_DYN 124Sections: 125 - Name: .relr.dyn 126 Type: SHT_RELR 127 Entries: [ 0x00000000FFFFFFFF ] 128 129--- !ELF 130FileHeader: 131 Class: ELFCLASS32 132 Data: ELFDATA2LSB 133 Type: ET_DYN 134Sections: 135 - Name: .relr.dyn 136 Type: SHT_RELR 137 Entries: [ 0x0000000100000000 ] 138 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. 141 142# RUN: not yaml2obj --docnum=6 -DSIZE=1 -DCONTENT="'0011'" %s 2>&1 | \ 143# RUN: FileCheck %s --check-prefix=CONTENT-SIZE-ERR 144 145# CONTENT-SIZE-ERR: error: Section size must be greater than or equal to the content size 146 147--- !ELF 148FileHeader: 149 Class: ELFCLASS64 150 Data: ELFDATA2LSB 151 Type: ET_DYN 152Sections: 153 - Name: .relr.dyn 154 Type: SHT_RELR 155 EntSize: 0xff 156 Size: [[SIZE=<none>]] 157 Content: [[CONTENT=<none>]] 158 Entries: [[ENTRIES=<none>]] 159 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" 163 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" 167 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: ) 182 183## Check we can use the "Size" key alone to create the section. 184 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" 188 189## Check we can use the "Content" key alone to create the section. 190 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" 194 195## Check we can't use the "Entries" key together with the "Content" or "Size" keys. 196 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 201 202# ENTRIES-ERR: error: "Entries" cannot be used with "Content" or "Size" 203 204## Check we create an empty section when none of "Size", "Content" or "Entries" are specified. 205 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 209 210# EMPTY-SEC: [Nr] Name Type Address Off Size 211# EMPTY-SEC: [ 1] .relr.dyn RELR 0000000000000000 000040 000000 212