236 lines · yaml
1## Check how yaml2obj produces .llvm_bb_addr_map sections.2 3# RUN: yaml2obj --docnum=1 %s -o %t14# RUN: llvm-readobj --sections --section-data %t1 | FileCheck %s5 6## Case 1: Specify content.7# CHECK: Section {8# CHECK: Index: 19# CHECK-NEXT: Name: .llvm_bb_addr_map (1)10# CHECK-NEXT: Type: SHT_LLVM_BB_ADDR_MAP (0x6FFF4C0A)11# CHECK-NEXT: Flags [ (0x0)12# CHECK-NEXT: ]13# CHECK-NEXT: Address: 0x014# CHECK-NEXT: Offset: 0x4015# CHECK-NEXT: Size: 1316# CHECK-NEXT: Link: 017# CHECK-NEXT: Info: 018# CHECK-NEXT: AddressAlignment: 019# CHECK-NEXT: EntrySize: 020# CHECK-NEXT: SectionData (21# CHECK-NEXT: 0000: 00000000 00000000 01010203 0422# CHECK-NEXT: )23# CHECK-NEXT: }24 25## Case 2: Empty.26# CHECK: Name: .llvm_bb_addr_map (1)27# CHECK: Size:28# CHECK-SAME: {{^ 0$}}29 30## Case 3: Specify Size only.31# CHECK: Name: .llvm_bb_addr_map (1)32# CHECK: SectionData (33# CHECK-NEXT: 0000: 00000000 0000000034# CHECK-NEXT: )35 36# Case 4: Specify Entries.37# CHECK: Name: .llvm_bb_addr_map (1)38# CHECK: SectionData (39# CHECK-NEXT: 0000: 03002000 00000000 0000010B 0102010240# CHECK-NEXT: 0010: 020341# CHECK-NEXT: )42 43# Case 5: Specify Entries and omit the Address field.44# CHECK: Name: .llvm_bb_addr_map (1)45# CHECK: Address:46# CHECK-SAME: {{^ 0x0$}}47# CHECK: SectionData (48# CHECK-NEXT: 0000: 03000000 00000000 0000010C 01020349# CHECK-NEXT: )50 51# Case 6: Override the NumBlocks field.52# CHECK: Name: .llvm_bb_addr_map (1)53# CHECK: SectionData (54# CHECK-NEXT: 0000: 03002000 00000000 0000020D 01020355# CHECK-NEXT: )56 57# Case 7: Specify empty BBRanges.58# CHECK: Name: .llvm_bb_addr_map (1)59# CHECK: SectionData (60# CHECK-NEXT: 0000: 03000061# CHECK-NEXT: )62 63# Case 8: Specify empty BBRanges with multi-bb-range.64# CHECK: Name: .llvm_bb_addr_map (1)65# CHECK: SectionData (66# CHECK-NEXT: 0000: 03080067# CHECK-NEXT: )68 69# Case 9: Specify empty CallsiteEndOffsets.70# CHECK: Name: .llvm_bb_addr_map (1)71# CHECK: SectionData (72# CHECK-NEXT: 0000: 03202000 00000000 0000010E 0100020373# CHECK-NEXT: )74 75# Case 10: Specify basic block hash.76# CHECK: Name: .llvm_bb_addr_map (1)77# CHECK: SectionData (78# CHECK-NEXT: 0000: 04602000 00000000 0000010E 0100020379# CHECK-NEXT: 0010: 23010000 0000000080# CHECK-NEXT: )81 82 83--- !ELF84FileHeader:85 Class: ELFCLASS6486 Data: ELFDATA2LSB87 Type: ET_EXEC88Sections:89 90## Test the following cases:91 92## 1) We can produce an .llvm_bb_addr_map section from a description with section93## content.94## Specify Content.95 - Name: '.llvm_bb_addr_map (1)'96 Type: SHT_LLVM_BB_ADDR_MAP97 Content: "00000000000000000101020304"98 99## 2) We can produce an empty .llvm_bb_addr_map section from a description100## with empty section content.101 - Name: '.llvm_bb_addr_map (2)'102 Type: SHT_LLVM_BB_ADDR_MAP103 104## 3) We can produce a zero .llvm_bb_addr_map section of a specific size when105## we specify the size only.106 - Name: '.llvm_bb_addr_map (3)'107 Type: SHT_LLVM_BB_ADDR_MAP108 Size: 8109 110## 4) We can produce an .llvm_bb_addr_map section from a description with111## Entries.112 - Name: '.llvm_bb_addr_map (4)'113 Type: SHT_LLVM_BB_ADDR_MAP114 Entries:115 - Version: 3116 BBRanges:117 - BaseAddress: 0x0000000000000020118 BBEntries:119 - ID: 11120 AddressOffset: 0x00000001121 Size: 0x00000002122 Metadata: 0x00000003123 CallsiteEndOffsets: [0x1, 0x2]124 125## 5) When specifying the description with Entries, the 'Address' field will be126## zero when omitted.127 - Name: '.llvm_bb_addr_map (5)'128 Type: SHT_LLVM_BB_ADDR_MAP129 Entries:130 - Version: 3131 BBRanges:132 - BBEntries:133 - ID: 12134 AddressOffset: 0x00000001135 Size: 0x00000002136 Metadata: 0x00000003137 138## 6) We can override the NumBlocks field with a value different from the139## actual number of BB Entries.140 - Name: '.llvm_bb_addr_map (6)'141 Type: SHT_LLVM_BB_ADDR_MAP142 Entries:143 - Version: 3144 BBRanges:145 - BaseAddress: 0x0000000000000020146 NumBlocks: 2147 BBEntries:148 - ID: 13149 AddressOffset: 0x00000001150 Size: 0x00000002151 Metadata: 0x00000003152 153## 7) We can produce a SHT_LLVM_BB_ADDR_MAP section from a description154## with one entry with empty BBRanges.155 - Name: '.llvm_bb_addr_map (7)'156 Type: SHT_LLVM_BB_ADDR_MAP157 Entries:158 - Version: 3159 BBRanges: []160 161## 8) We can produce a SHT_LLVM_BB_ADDR_MAP section from a multi-bb-range162## description with one entry with empty BBRanges.163 - Name: '.llvm_bb_addr_map (8)'164 Type: SHT_LLVM_BB_ADDR_MAP165 Entries:166 - Version: 3167 Feature: 0x8168 BBRanges: []169 170## 9) We can produce a SHT_LLVM_BB_ADDR_MAP section from a description171## with empty callsite offsets.172 - Name: '.llvm_bb_addr_map (9)'173 Type: SHT_LLVM_BB_ADDR_MAP174 Entries:175 - Version: 3176 Feature: 0x20177 BBRanges:178 - BaseAddress: 0x0000000000000020179 BBEntries:180 - ID: 14181 AddressOffset: 0x00000001182 Size: 0x00000002183 Metadata: 0x00000003184 CallsiteEndOffsets: []185 186## 10) We can produce a SHT_LLVM_BB_ADDR_MAP section with basic block hash.187 - Name: '.llvm_bb_addr_map (10)'188 Type: SHT_LLVM_BB_ADDR_MAP189 Entries:190 - Version: 4191 Feature: 0x60192 BBRanges:193 - BaseAddress: 0x0000000000000020194 BBEntries:195 - ID: 14196 AddressOffset: 0x00000001197 Size: 0x00000002198 Metadata: 0x00000003199 CallsiteEndOffsets: []200 Hash: 0x123201 202## Check we can't use Entries at the same time as either Content or Size.203# RUN: not yaml2obj --docnum=2 -DCONTENT="00" %s 2>&1 | FileCheck %s --check-prefix=INVALID204# RUN: not yaml2obj --docnum=2 -DSIZE="0" %s 2>&1 | FileCheck %s --check-prefix=INVALID205 206# INVALID: error: "Entries" cannot be used with "Content" or "Size"207 208--- !ELF209FileHeader:210 Class: ELFCLASS64211 Data: ELFDATA2LSB212 Type: ET_EXEC213Sections:214## Specify Content and Size215 - Name: '.llvm_bb_addr_map'216 Type: SHT_LLVM_BB_ADDR_MAP217 Entries: []218 Content: [[CONTENT=<none>]]219 Size: [[SIZE=<none>]]220 221## Check that yaml2obj generates a warning when we use unsupported versions.222# RUN: yaml2obj --docnum=3 %s 2>&1 | FileCheck %s --check-prefix=INVALID-VERSION223# INVALID-VERSION: warning: unsupported SHT_LLVM_BB_ADDR_MAP version: 6; encoding using the most recent version224 225--- !ELF226FileHeader:227 Class: ELFCLASS64228 Data: ELFDATA2LSB229 Type: ET_EXEC230Sections:231 - Name: '.llvm_bb_addr_map'232 Type: SHT_LLVM_BB_ADDR_MAP233 Entries:234## Specify unsupported version235 - Version: 6236