1 ## This test checks how we handle the --bb-addr-map option.
3 ## Fails on windows (https://github.com/llvm/llvm-project/issues/60013).
4 # UNSUPPORTED: system-windows
7 # RUN: yaml2obj --docnum=1 %s -DBITS=64 -DADDR=0x999999999 -o %t1.x64.o
8 # RUN: llvm-readobj %t1.x64.o --bb-addr-map 2>&1 | FileCheck %s -DADDR=0x999999999 -DFILE=%t1.x64.o --check-prefix=CHECK
9 # RUN: llvm-readelf %t1.x64.o --bb-addr-map | FileCheck %s --check-prefix=GNU
12 # RUN: yaml2obj --docnum=1 %s -DBITS=64 -DADDR=0x999999999 -o %t1.v1.x64.o
13 # RUN: llvm-readobj %t1.v1.x64.o --bb-addr-map 2>&1 | FileCheck %s -DADDR=0x999999999 -DFILE=%t1.v1.x64.o --check-prefix=CHECK
16 # RUN: yaml2obj --docnum=1 %s -DBITS=32 -o %t1.x32.o
17 # RUN: llvm-readobj %t1.x32.o --bb-addr-map 2>&1 | FileCheck -DADDR=0x11111 %s -DFILE=%t1.x32.o --check-prefix=CHECK
18 # RUN: llvm-readelf %t1.x32.o --bb-addr-map | FileCheck %s --check-prefix=GNU
20 ## Check that a malformed section can be handled.
21 # RUN: yaml2obj --docnum=1 %s -DBITS=32 -DSIZE=6 -o %t2.o
22 # RUN: llvm-readobj %t2.o --bb-addr-map 2>&1 | FileCheck %s -DOFFSET=0x00000006 -DFILE=%t2.o --check-prefix=TRUNCATED
24 ## Check that invalid metadata can be handled.
25 # RUN: yaml2obj --docnum=1 %s -DBITS=32 -DMETADATA=0xF000002 -o %t3.o
26 # RUN: llvm-readobj %t3.o --bb-addr-map 2>&1 | FileCheck %s -DFILE=%t3.o --check-prefix=INVALIDMD
29 # CHECK-NEXT: Function {
30 # CHECK-NEXT: At: [[ADDR]]
31 # CHECK-NEXT: warning: '[[FILE]]': could not identify function symbol for address ([[ADDR]]) in SHT_LLVM_BB_ADDR_MAP section with index 3
32 # CHECK-NEXT: Name: <?>
33 # CHECK-NEXT: BB entries [
36 # CHECK-NEXT: Offset: 0x0
37 # CHECK-NEXT: Size: 0x1
38 # CHECK-NEXT: HasReturn: No
39 # CHECK-NEXT: HasTailCall: Yes
40 # CHECK-NEXT: IsEHPad: No
41 # CHECK-NEXT: CanFallThrough: No
42 # CHECK-NEXT: HasIndirectBranch: No
46 # CHECK-NEXT: Offset: 0x4
47 # CHECK-NEXT: Size: 0x4
48 # CHECK-NEXT: HasReturn: Yes
49 # CHECK-NEXT: HasTailCall: No
50 # CHECK-NEXT: IsEHPad: Yes
51 # CHECK-NEXT: CanFallThrough: No
52 # CHECK-NEXT: HasIndirectBranch: Yes
56 # CHECK-NEXT: Function {
57 # CHECK-NEXT: At: 0x22222
58 # CHECK-NEXT: Name: foo
59 # CHECK-NEXT: BB entries [
62 # CHECK-NEXT: Offset: 0x6
63 # CHECK-NEXT: Size: 0x7
64 # CHECK-NEXT: HasReturn: No
65 # CHECK-NEXT: HasTailCall: No
66 # CHECK-NEXT: IsEHPad: No
67 # CHECK-NEXT: CanFallThrough: Yes
68 # CHECK-NEXT: HasIndirectBranch: No
74 # GNU: GNUStyle::printBBAddrMaps not implemented
76 # TRUNCATED: BBAddrMap [
77 # TRUNCATED-NEXT: warning: '[[FILE]]': unable to dump SHT_LLVM_BB_ADDR_MAP section with index 3: unable to decode LEB128 at offset [[OFFSET]]: malformed uleb128, extends past end
79 ## Check that the other valid section is properly dumped.
80 # TRUNCATED-NEXT: BBAddrMap [
81 # TRUNCATED-NEXT: Function {
82 # TRUNCATED-NEXT: At: 0x33333
83 # TRUNCATED-NEXT: Name: bar
84 # TRUNCATED-NEXT: BB entries [
86 # TRUNCATED-NEXT: ID: 6
87 # TRUNCATED-NEXT: Offset: 0x9
88 # TRUNCATED-NEXT: Size: 0xA
89 # TRUNCATED-NEXT: HasReturn: Yes
90 # TRUNCATED-NEXT: HasTailCall: Yes
91 # TRUNCATED-NEXT: IsEHPad: No
92 # TRUNCATED-NEXT: CanFallThrough: Yes
93 # TRUNCATED-NEXT: HasIndirectBranch: Yes
96 # TRUNCATED-NEXT: ID: 7
97 # TRUNCATED-NEXT: Offset: 0x1F
98 # TRUNCATED-NEXT: Size: 0xD
99 # TRUNCATED-NEXT: HasReturn: No
100 # TRUNCATED-NEXT: HasTailCall: Yes
101 # TRUNCATED-NEXT: IsEHPad: Yes
102 # TRUNCATED-NEXT: CanFallThrough: Yes
103 # TRUNCATED-NEXT: HasIndirectBranch: No
109 # INVALIDMD: BBAddrMap [
110 # INVALIDMD-NEXT: warning: '[[FILE]]': unable to dump SHT_LLVM_BB_ADDR_MAP section with index 3: invalid encoding for BBEntry::Metadata: 0xf000002
114 Class: ELFCLASS[[BITS]]
124 - Name: .llvm_bb_addr_map
125 Type: SHT_LLVM_BB_ADDR_MAP
126 ShSize: [[SIZE=<none>]]
130 Address: [[ADDR=0x11111]]
135 Metadata: [[METADATA=0x2]]
147 - Name: dummy_section
150 - Name: '.llvm_bb_addr_map (1)'
151 Type: SHT_LLVM_BB_ADDR_MAP
175 ## Check that using the SHT_LLVM_BB_ADDR_MAP_V0 section type generates the same
176 ## result as using the SHT_LLVM_BB_ADDR_MAP section type with Version=0.
177 ## The Version field is required even for SHT_LLVM_BB_ADDR_MAP_V0 but it
178 ## should not impact the result. This unideal behavior will be gone once
179 ## SHT_LLVM_BB_ADDR_MAP_V0 is deprecated.
181 # RUN: yaml2obj --docnum=2 %s -DVERSION=255 -DSECTION_TYPE=SHT_LLVM_BB_ADDR_MAP_V0 -o %t2.type0
182 # RUN: llvm-readobj %t2.type0 --bb-addr-map 2>&1 | FileCheck %s --check-prefix=V0
184 # RUN: yaml2obj --docnum=2 %s -DVERSION=0 -DSECTION_TYPE=SHT_LLVM_BB_ADDR_MAP -o %t2.version0
185 # RUN: llvm-readobj %t2.version0 --bb-addr-map 2>&1 | FileCheck %s --check-prefix=V0
188 # V0-NEXT: Function {
189 # V0-NEXT: At: 0x11111
191 # V0-NEXT: BB entries [
194 # V0-NEXT: Offset: 0x1
196 # V0-NEXT: HasReturn:
197 # V0-NEXT: HasTailCall:
199 # V0-NEXT: CanFallThrough:
200 # V0-NEXT: HasIndirectBranch:
204 # V0-NEXT: Offset: 0x4
206 # V0-NEXT: HasReturn:
207 # V0-NEXT: HasTailCall:
209 # V0-NEXT: CanFallThrough:
210 # V0-NEXT: HasIndirectBranch:
215 ## Check version 1 (without BB IDs).
216 # RUN: yaml2obj --docnum=2 %s -DVERSION=1 -DSECTION_TYPE=SHT_LLVM_BB_ADDR_MAP -o %t3
217 # RUN: llvm-readobj %t3 --bb-addr-map 2>&1 | FileCheck %s --check-prefix=V1
220 # V1-NEXT: Function {
221 # V1-NEXT: At: 0x11111
223 # V1-NEXT: BB entries [
226 # V1-NEXT: Offset: 0x1
228 # V1-NEXT: HasReturn:
229 # V1-NEXT: HasTailCall:
231 # V1-NEXT: CanFallThrough:
232 # V1-NEXT: HasIndirectBranch:
236 # V1-NEXT: Offset: 0x7
238 # V1-NEXT: HasReturn:
239 # V1-NEXT: HasTailCall:
241 # V1-NEXT: CanFallThrough:
242 # V1-NEXT: HasIndirectBranch:
256 - Name: .llvm_bb_addr_map
257 Type: [[SECTION_TYPE]]
260 - Version: [[VERSION]]