1## Check how obj2yaml produces YAML .llvm_bb_addr_map descriptions.
2
3## Check that obj2yaml uses the "Entries" tag to describe an .llvm_bb_addr_map section.
4
5# RUN: yaml2obj --docnum=1 %s -o %t1
6# RUN: obj2yaml %t1 | FileCheck %s --check-prefix=VALID
7
8# VALID:      --- !ELF
9# VALID-NEXT: FileHeader:
10# VALID-NEXT:   Class:   ELFCLASS64
11# VALID-NEXT:   Data:    ELFDATA2LSB
12# VALID-NEXT:   Type:    ET_EXEC
13# VALID-NEXT: Sections:
14# VALID-NEXT:   - Name: .llvm_bb_addr_map
15# VALID-NEXT:     Type: SHT_LLVM_BB_ADDR_MAP
16# VALID-NEXT:     Entries:
17## The 'Address' field is omitted when it's zero.
18# VALID-NEXT:         BBEntries:
19# VALID-NEXT:           - AddressOffset:    0x1
20# VALID-NEXT:             Size:             0x2
21# VALID-NEXT:             Metadata:         0x3
22# VALID-NEXT:           - AddressOffset:    0x4
23# VALID-NEXT:             Size:             0x5
24# VALID-NEXT:             Metadata:         0x6
25# VALID-NEXT:           - AddressOffset:    0x7
26# VALID-NEXT:             Size:             0x8
27# VALID-NEXT:             Metadata:         0x9
28# VALID-NEXT:       - Address:   0x20
29# VALID-NEXT:         BBEntries:
30# VALID-NEXT:           - AddressOffset:    0xA
31# VALID-NEXT:             Size:             0xB
32# VALID-NEXT:             Metadata:         0xC
33
34--- !ELF
35FileHeader:
36  Class: ELFCLASS64
37  Data:  ELFDATA2LSB
38  Type:  ET_EXEC
39Sections:
40  - Name:    .llvm_bb_addr_map
41    Type:    SHT_LLVM_BB_ADDR_MAP
42    Entries:
43      - Address:   0x0
44        BBEntries:
45          - AddressOffset:    0x1
46            Size:             0x2
47            Metadata:         0x3
48          - AddressOffset:    0x4
49            Size:             0x5
50            Metadata:         0x6
51          - AddressOffset:    0x7
52            Size:             0x8
53            Metadata:         0x9
54      - Address:   0x20
55        BBEntries:
56          - AddressOffset:    0xA
57            Size:             0xB
58            Metadata:         0xC
59
60## Check that obj2yaml uses the "Content" tag to describe an .llvm_bb_addr_map section
61## when it can't extract the entries. For instance, when truncated data is given as
62## 'Content'.
63
64# RUN: yaml2obj --docnum=2 %s -o %t2
65# RUN: obj2yaml %t2 | FileCheck %s --check-prefix=INVALID
66
67# INVALID:      --- !ELF
68# INVALID-NEXT: FileHeader:
69# INVALID-NEXT:   Class:   ELFCLASS64
70# INVALID-NEXT:   Data:    ELFDATA2LSB
71# INVALID-NEXT:   Type:    ET_EXEC
72# INVALID-NEXT: Sections:
73# INVALID-NEXT:   - Name: .llvm_bb_addr_map
74# INVALID-NEXT:     Type: SHT_LLVM_BB_ADDR_MAP
75# INVALID-NEXT:     Content: '10000000000000'
76
77--- !ELF
78FileHeader:
79  Class: ELFCLASS64
80  Data:  ELFDATA2LSB
81  Type:  ET_EXEC
82Sections:
83  - Name:    .llvm_bb_addr_map
84    Type:    SHT_LLVM_BB_ADDR_MAP
85    Content: '10000000000000'
86
87## Check obj2yaml can dump empty .llvm_bb_addr_map sections.
88
89# RUN: yaml2obj --docnum=3 %s -o %t3
90# RUN: obj2yaml %t3 | FileCheck %s --check-prefix=EMPTY
91
92# EMPTY:      --- !ELF
93# EMPTY-NEXT: FileHeader:
94# EMPTY-NEXT:   Class: ELFCLASS64
95# EMPTY-NEXT:   Data:  ELFDATA2LSB
96# EMPTY-NEXT:   Type:  ET_EXEC
97# EMPTY-NEXT: Sections:
98# EMPTY-NEXT:   - Name:    .llvm_bb_addr_map
99# EMPTY-NEXT:     Type:    SHT_LLVM_BB_ADDR_MAP
100# EMPTY-NOT:      Content:
101
102--- !ELF
103FileHeader:
104  Class: ELFCLASS64
105  Data:  ELFDATA2LSB
106  Type:  ET_EXEC
107Sections:
108  - Name:    .llvm_bb_addr_map
109    Type:    SHT_LLVM_BB_ADDR_MAP
110    Content: ""
111
112## Check obj2yaml can dump multiple .llvm_bb_addr_map sections.
113
114# RUN: yaml2obj --docnum=4 %s -o %t4
115# RUN: obj2yaml %t4 | FileCheck %s --check-prefix=MULTI
116
117# MULTI:      --- !ELF
118# MULTI-NEXT: FileHeader:
119# MULTI-NEXT:   Class: ELFCLASS64
120# MULTI-NEXT:   Data:  ELFDATA2LSB
121# MULTI-NEXT:   Type:  ET_EXEC
122# MULTI-NEXT: Sections:
123# MULTI-NEXT:   - Name:    .llvm_bb_addr_map
124# MULTI-NEXT:     Type:    SHT_LLVM_BB_ADDR_MAP
125# MULTI-NEXT:     Entries:
126## The 'Address' field is omitted when it's zero.
127# MULTI-NEXT:       - BBEntries:
128# MULTI-NEXT:           - AddressOffset:    0x1
129# MULTI-NEXT:             Size:             0x2
130# MULTI-NEXT:             Metadata:         0x3
131# MULTI-NEXT:   - Name:    '.llvm_bb_addr_map (1)'
132# MULTI-NEXT:     Type:    SHT_LLVM_BB_ADDR_MAP
133# MULTI-NEXT:     Entries:
134# MULTI-NEXT:       - Address: 0x20
135# MULTI-NEXT:         BBEntries: []
136
137--- !ELF
138FileHeader:
139  Class: ELFCLASS64
140  Data:  ELFDATA2LSB
141  Type:  ET_EXEC
142Sections:
143  - Name:    .llvm_bb_addr_map
144    Type:    SHT_LLVM_BB_ADDR_MAP
145    Entries:
146## Check that obj2yaml does not emit the Address field when it's zero.
147      - Address:   0x0
148        BBEntries:
149          - AddressOffset:    0x1
150            Size:             0x2
151            Metadata:         0x3
152  - Name:    '.llvm_bb_addr_map (1)'
153    Type:    SHT_LLVM_BB_ADDR_MAP
154    Entries:
155      - Address:   0x20
156