1## Check how yaml2obj produces .llvm_bb_addr_map sections.
2
3# RUN: yaml2obj --docnum=1 %s -o %t1
4# RUN: llvm-readobj --sections --section-data %t1 | FileCheck %s
5
6## Case 1: Specify content.
7# CHECK:      Section {
8# CHECK:        Index: 1
9# CHECK-NEXT:   Name: .llvm_bb_addr_map (1)
10# CHECK-NEXT:   Type: SHT_LLVM_BB_ADDR_MAP (0x6FFF4C08)
11# CHECK-NEXT:   Flags [ (0x0)
12# CHECK-NEXT:   ]
13# CHECK-NEXT:   Address: 0x0
14# CHECK-NEXT:   Offset: 0x40
15# CHECK-NEXT:   Size: 12
16# CHECK-NEXT:   Link: 0
17# CHECK-NEXT:   Info: 0
18# CHECK-NEXT:   AddressAlignment: 0
19# CHECK-NEXT:   EntrySize: 0
20# CHECK-NEXT:   SectionData (
21# CHECK-NEXT:     0000: 00000000 00000000 01010203
22# 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 00000000
34# CHECK-NEXT:   )
35
36# Case 4: Specify Entries.
37# CHECK:        Name: .llvm_bb_addr_map (1)
38# CHECK:        SectionData (
39# CHECK-NEXT:     0000: 20000000 00000000 01010203
40# CHECK-NEXT:   )
41
42# Case 5: Specify Entries and omit the Address field.
43# CHECK:        Name: .llvm_bb_addr_map (1)
44# CHECK:        Address:
45# CHECK-SAME:   {{^ 0x0$}}
46# CHECK:        SectionData (
47# CHECK-NEXT:     0000: 00000000 00000000 01010203
48# CHECK-NEXT:   )
49
50--- !ELF
51FileHeader:
52  Class: ELFCLASS64
53  Data:  ELFDATA2LSB
54  Type:  ET_EXEC
55Sections:
56
57## Test the following cases:
58
59## 1) We can produce an .llvm_bb_addr_map section from a description with section
60##    content.
61##  Specify Content.
62  - Name:    '.llvm_bb_addr_map (1)'
63    Type:    SHT_LLVM_BB_ADDR_MAP
64    Content: "000000000000000001010203"
65
66## 2) We can produce an empty .llvm_bb_addr_map section from a description
67##    with empty section content.
68  - Name:    '.llvm_bb_addr_map (2)'
69    Type:    SHT_LLVM_BB_ADDR_MAP
70
71## 3) We can produce a zero .llvm_bb_addr_map section of a specific size when
72##    we specify the size only.
73  - Name:    '.llvm_bb_addr_map (3)'
74    Type:    SHT_LLVM_BB_ADDR_MAP
75    Size:    8
76
77## 4) We can produce an .llvm_bb_addr_map section from a description with
78##    Entries.
79  - Name:    '.llvm_bb_addr_map (4)'
80    Type:    SHT_LLVM_BB_ADDR_MAP
81    Entries:
82      - Address:   0x0000000000000020
83        BBEntries:
84          - AddressOffset:    0x00000001
85            Size:             0x00000002
86            Metadata:         0x00000003
87
88## 5) When specifying the description with Entries, the 'Address' field will be
89##    zero when omitted.
90  - Name:    '.llvm_bb_addr_map (5)'
91    Type:    SHT_LLVM_BB_ADDR_MAP
92    Entries:
93      - BBEntries:
94          - AddressOffset:    0x00000001
95            Size:             0x00000002
96            Metadata:         0x00000003
97
98
99## Check we can't use Entries at the same time as either Content or Size.
100# RUN: not yaml2obj --docnum=2 -DCONTENT="00" %s 2>&1 | FileCheck %s --check-prefix=INVALID
101# RUN: not yaml2obj --docnum=2 -DSIZE="0" %s 2>&1 | FileCheck %s --check-prefix=INVALID
102
103# INVALID: error: "Entries" cannot be used with "Content" or "Size"
104
105--- !ELF
106FileHeader:
107  Class: ELFCLASS64
108  Data:  ELFDATA2LSB
109  Type:  ET_EXEC
110Sections:
111##  Specify Content and Size
112  - Name:    '.llvm_bb_addr_map'
113    Type:    SHT_LLVM_BB_ADDR_MAP
114    Entries: []
115    Content: [[CONTENT=<none>]]
116    Size:    [[SIZE=<none>]]
117