1 ## This test checks how we handle the --bb-addr-map option.
4 # RUN: yaml2obj --docnum=1 %s -DBITS=64 -DADDR=0x999999999 -o %t1.x64.o
5 # RUN: llvm-readobj %t1.x64.o --bb-addr-map 2>&1 | FileCheck %s -DADDR=0x999999999 -DFILE=%t1.x64.o --check-prefix=CHECK
6 # RUN: llvm-readelf %t1.x64.o --bb-addr-map | FileCheck %s --check-prefix=GNU
9 # RUN: yaml2obj --docnum=1 %s -DBITS=64 -DADDR=0x999999999 -o %t1.v1.x64.o
10 # RUN: llvm-readobj %t1.v1.x64.o --bb-addr-map 2>&1 | FileCheck %s -DADDR=0x999999999 -DFILE=%t1.v1.x64.o --check-prefix=CHECK
13 # RUN: yaml2obj --docnum=1 %s -DBITS=32 -o %t1.x32.o
14 # RUN: llvm-readobj %t1.x32.o --bb-addr-map 2>&1 | FileCheck -DADDR=0x11111 %s -DFILE=%t1.x32.o --check-prefix=CHECK
15 # RUN: llvm-readelf %t1.x32.o --bb-addr-map | FileCheck %s --check-prefix=GNU
17 ## Check that a malformed section can be handled.
18 # RUN: yaml2obj --docnum=1 %s -DBITS=32 -DSIZE=7 -o %t2.o
19 # RUN: llvm-readobj %t2.o --bb-addr-map 2>&1 | FileCheck %s -DOFFSET=0x00000007 -DFILE=%t2.o --check-prefix=TRUNCATED
21 ## Check that invalid metadata can be handled.
22 # RUN: yaml2obj --docnum=1 %s -DBITS=32 -DMETADATA=0xF000002 -o %t3.o
23 # RUN: llvm-readobj %t3.o --bb-addr-map 2>&1 | FileCheck %s -DFILE=%t3.o --check-prefix=INVALIDMD
26 # CHECK-NEXT: Function {
27 # CHECK-NEXT: At: [[ADDR]]
28 # CHECK-NEXT: warning: '[[FILE]]': could not identify function symbol for address ([[ADDR]]) in SHT_LLVM_BB_ADDR_MAP section with index 3
29 # CHECK-NEXT: Name: <?>
30 # CHECK-NEXT: BB Ranges [
32 # CHECK-NEXT: Base Address: [[ADDR]]
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
47 # CHECK-NEXT: Base Address: 0x44444
48 # CHECK-NEXT: BB Entries [
51 # CHECK-NEXT: Offset: 0x3
52 # CHECK-NEXT: Size: 0x4
53 # CHECK-NEXT: HasReturn: Yes
54 # CHECK-NEXT: HasTailCall: No
55 # CHECK-NEXT: IsEHPad: Yes
56 # CHECK-NEXT: CanFallThrough: No
57 # CHECK-NEXT: HasIndirectBranch: Yes
63 # CHECK-NEXT: Function {
64 # CHECK-NEXT: At: 0x22222
65 # CHECK-NEXT: Name: foo
66 # CHECK-NEXT: BB Ranges [
68 # CHECK-NEXT: Base Address: 0x22222
69 # CHECK-NEXT: BB Entries [
72 # CHECK-NEXT: Offset: 0x6
73 # CHECK-NEXT: Size: 0x7
74 # CHECK-NEXT: HasReturn: No
75 # CHECK-NEXT: HasTailCall: No
76 # CHECK-NEXT: IsEHPad: No
77 # CHECK-NEXT: CanFallThrough: Yes
78 # CHECK-NEXT: HasIndirectBranch: No
86 # GNU: GNUStyle::printBBAddrMaps not implemented
88 # TRUNCATED: BBAddrMap [
89 # 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
91 ## Check that the other valid section is properly dumped.
92 # TRUNCATED-NEXT: BBAddrMap [
93 # TRUNCATED-NEXT: Function {
94 # TRUNCATED-NEXT: At: 0x33333
95 # TRUNCATED-NEXT: Name: bar
96 # TRUNCATED-NEXT: BB Ranges [
98 # TRUNCATED-NEXT: Base Address: 0x33333
99 # TRUNCATED-NEXT: BB Entries [
101 # TRUNCATED-NEXT: ID: 6
102 # TRUNCATED-NEXT: Offset: 0x9
103 # TRUNCATED-NEXT: Size: 0xA
104 # TRUNCATED-NEXT: HasReturn: Yes
105 # TRUNCATED-NEXT: HasTailCall: Yes
106 # TRUNCATED-NEXT: IsEHPad: No
107 # TRUNCATED-NEXT: CanFallThrough: Yes
108 # TRUNCATED-NEXT: HasIndirectBranch: Yes
111 # TRUNCATED-NEXT: ID: 7
112 # TRUNCATED-NEXT: Offset: 0x1F
113 # TRUNCATED-NEXT: Size: 0xD
114 # TRUNCATED-NEXT: HasReturn: No
115 # TRUNCATED-NEXT: HasTailCall: Yes
116 # TRUNCATED-NEXT: IsEHPad: Yes
117 # TRUNCATED-NEXT: CanFallThrough: Yes
118 # TRUNCATED-NEXT: HasIndirectBranch: No
126 # INVALIDMD: BBAddrMap [
127 # INVALIDMD-NEXT: warning: '[[FILE]]': unable to dump SHT_LLVM_BB_ADDR_MAP section with index 3: invalid encoding for BBEntry::Metadata: 0xf000002
131 Class: ELFCLASS[[BITS]]
141 - Name: .llvm_bb_addr_map
142 Type: SHT_LLVM_BB_ADDR_MAP
143 ShSize: [[SIZE=<none>]]
149 - BaseAddress: [[ADDR=0x11111]]
154 Metadata: [[METADATA=0x2]]
155 - BaseAddress: 0x44444
163 - BaseAddress: 0x22222
169 - Name: dummy_section
172 - Name: '.llvm_bb_addr_map (1)'
173 Type: SHT_LLVM_BB_ADDR_MAP
178 - BaseAddress: 0x33333