1 ## This test checks how we handle the --elf-cg-profile option.
3 # RUN: yaml2obj %s -o %t.o
4 # RUN: llvm-readobj %t.o --cg-profile | FileCheck %s --check-prefix=LLVM
5 # RUN: llvm-readelf %t.o --cg-profile | FileCheck %s --check-prefix=GNU
6 # RUN: llvm-readobj %t.o --elf-cg-profile | FileCheck %s --check-prefix=LLVM
7 # RUN: llvm-readelf %t.o --elf-cg-profile | FileCheck %s --check-prefix=GNU
10 # LLVM-NEXT: CGProfileEntry {
11 # LLVM-NEXT: From: foo (1)
12 # LLVM-NEXT: To: bar (2)
13 # LLVM-NEXT: Weight: 89
15 # LLVM-NEXT: CGProfileEntry {
16 # LLVM-NEXT: From: bar (2)
17 # LLVM-NEXT: To: foo (1)
18 # LLVM-NEXT: Weight: 98
22 # GNU: GNUStyle::printCGProfile not implemented
31 - Name: .llvm.call-graph-profile
32 Type: SHT_LLVM_CALL_GRAPH_PROFILE
36 EntSize: [[ENTSIZE=<none>]]
37 - Name: .rel.llvm.call-graph-profile
39 Info: .llvm.call-graph-profile
56 ## Check we report a warning when unable to get the content of the SHT_LLVM_CALL_GRAPH_PROFILE section.
57 # RUN: yaml2obj %s -DENTSIZE=0xF -o %t2.o
58 # RUN: llvm-readobj %t2.o --cg-profile 2>&1 | FileCheck %s -DFILE=%t2.o --check-prefix=LLVM-ERR
59 # RUN: llvm-readelf %t2.o --cg-profile | FileCheck %s --check-prefix=GNU
61 # LLVM-ERR: warning: '[[FILE]]': unable to load the SHT_LLVM_CALL_GRAPH_PROFILE section: section [index 1] has invalid sh_entsize: expected 8, but got 15
63 ## Check we report a warning when unable to dump a name of a symbol.
64 # RUN: yaml2obj %s --docnum=2 -o %t3.o
65 # RUN: llvm-readobj %t3.o --cg-profile 2>&1 | FileCheck %s -DFILE=%t3.o --check-prefix=LLVM-BROKEN-SYM
66 # RUN: llvm-readelf %t3.o --cg-profile | FileCheck %s --check-prefix=GNU
68 # LLVM-BROKEN-SYM: CGProfile [
69 # LLVM-BROKEN-SYM-NEXT: CGProfileEntry {
70 # LLVM-BROKEN-SYM-NEXT: From: A (1)
71 # LLVM-BROKEN-SYM-NEXT: warning: '[[FILE]]': unable to read the name of symbol with index 2: st_name (0xff) is past the end of the string table of size 0x5
72 # LLVM-BROKEN-SYM-NEXT: To: <?> (2)
73 # LLVM-BROKEN-SYM-NEXT: Weight: 10
74 # LLVM-BROKEN-SYM-NEXT: }
75 # LLVM-BROKEN-SYM-NEXT: CGProfileEntry {
76 # LLVM-BROKEN-SYM-NEXT: From: <?> (2)
77 # LLVM-BROKEN-SYM-NEXT: To: B (3)
78 # LLVM-BROKEN-SYM-NEXT: Weight: 20
79 # LLVM-BROKEN-SYM-NEXT: }
80 # LLVM-BROKEN-SYM-NEXT: CGProfileEntry {
81 # LLVM-BROKEN-SYM-NEXT: From: (0)
82 # LLVM-BROKEN-SYM-NEXT: warning: '[[FILE]]': unable to read the name of symbol with index 4: unable to get symbol from section [index 4]: invalid symbol index (4)
83 # LLVM-BROKEN-SYM-NEXT: To: <?> (4)
84 # LLVM-BROKEN-SYM-NEXT: Weight: 20
85 # LLVM-BROKEN-SYM-NEXT: }
86 # LLVM-BROKEN-SYM-NEXT: ]
95 - Name: .llvm.call-graph-profile
96 Type: SHT_LLVM_CALL_GRAPH_PROFILE
101 - Name: .rel.llvm.call-graph-profile
103 Info: .llvm.call-graph-profile
117 Symbol: 0x0 ## Null symbol.
120 Symbol: 0x4 ## This index goes past the end of the symbol table.
124 Content: "0041004200" ## '\0', 'A', '\0', 'B', '\0'
127 - StName: 0xFF ## An arbitrary currupted index in the string table.
130 ## Check we report a warning when a relocation section is not present.
131 # RUN: yaml2obj %s --docnum=3 -o %t4.o
132 # RUN: llvm-readobj %t4.o --cg-profile 2>&1 | FileCheck %s -DFILE=%t4.o --check-prefix=LLVM-NO-RELOC
133 # RUN: llvm-readobj %t4.o --elf-cg-profile 2>&1 | FileCheck %s -DFILE=%t4.o --check-prefix=LLVM-NO-RELOC
135 # LLVM-NO-RELOC: warning: '[[FILE]]': relocation section for a call graph section doesn't exist
136 # LLVM-NO-RELOC-NEXT: CGProfile [
137 # LLVM-NO-RELOC-NEXT: CGProfileEntry {
138 # LLVM-NO-RELOC-NEXT: Weight: 89
139 # LLVM-NO-RELOC-NEXT: }
140 # LLVM-NO-RELOC-NEXT: CGProfileEntry {
141 # LLVM-NO-RELOC-NEXT: Weight: 98
142 # LLVM-NO-RELOC-NEXT: }
143 # LLVM-NO-RELOC-NEXT: ]
151 - Name: .llvm.call-graph-profile
152 Type: SHT_LLVM_CALL_GRAPH_PROFILE
160 ## Check we report a warning when the number of relocation section entries does not match the number of call graph entries.
161 # RUN: yaml2obj %s --docnum=4 -o %t5.o
162 # RUN: llvm-readobj %t5.o --cg-profile 2>&1 | FileCheck %s -DFILE=%t5.o --check-prefix=LLVM-RELOC-GRAPH-NOT-MATCH
163 # RUN: llvm-readobj %t5.o --elf-cg-profile 2>&1 | FileCheck %s -DFILE=%t5.o --check-prefix=LLVM-RELOC-GRAPH-NOT-MATCH
165 # LLVM-RELOC-GRAPH-NOT-MATCH: warning: '[[FILE]]': number of from/to pairs does not match number of frequencies
166 # LLVM-RELOC-GRAPH-NOT-MATCH-NEXT: CGProfile [
167 # LLVM-RELOC-GRAPH-NOT-MATCH-NEXT: CGProfileEntry {
168 # LLVM-RELOC-GRAPH-NOT-MATCH-NEXT: Weight: 89
169 # LLVM-RELOC-GRAPH-NOT-MATCH-NEXT: }
170 # LLVM-RELOC-GRAPH-NOT-MATCH-NEXT: CGProfileEntry {
171 # LLVM-RELOC-GRAPH-NOT-MATCH-NEXT: Weight: 98
172 # LLVM-RELOC-GRAPH-NOT-MATCH-NEXT: }
173 # LLVM-RELOC-GRAPH-NOT-MATCH-NEXT: ]
182 - Name: .llvm.call-graph-profile
183 Type: SHT_LLVM_CALL_GRAPH_PROFILE
187 - Name: .rel.llvm.call-graph-profile
189 Info: .llvm.call-graph-profile
209 ## Check we report a warning when a REL relocation section can't be loaded.
210 # RUN: yaml2obj %s --docnum=5 -o %t6.o
211 # RUN: llvm-readobj %t6.o --cg-profile 2>&1 | FileCheck %s -DFILE=%t6.o --check-prefix=LLVM-RELOC-WRONG-SIZE
212 # RUN: llvm-readobj %t6.o --elf-cg-profile 2>&1 | FileCheck %s -DFILE=%t6.o --check-prefix=LLVM-RELOC-WRONG-SIZE
214 # LLVM-RELOC-WRONG-SIZE: warning: '[[FILE]]': unable to load relocations for SHT_LLVM_CALL_GRAPH_PROFILE section: section [index 2] has invalid sh_entsize: expected 16, but got 24
215 # LLVM-RELOC-WRONG-SIZE-NEXT: CGProfile [
216 # LLVM-RELOC-WRONG-SIZE-NEXT: CGProfileEntry {
217 # LLVM-RELOC-WRONG-SIZE-NEXT: Weight: 89
218 # LLVM-RELOC-WRONG-SIZE-NEXT: }
219 # LLVM-RELOC-WRONG-SIZE-NEXT: CGProfileEntry {
220 # LLVM-RELOC-WRONG-SIZE-NEXT: Weight: 98
221 # LLVM-RELOC-WRONG-SIZE-NEXT: }
222 # LLVM-RELOC-WRONG-SIZE-NEXT: ]
231 - Name: .llvm.call-graph-profile
232 Type: SHT_LLVM_CALL_GRAPH_PROFILE
236 - Name: .rel.llvm.call-graph-profile
238 Info: .llvm.call-graph-profile
256 ## GNU strip may convert SHT_REL to SHT_RELA. Test we can handle SHT_RELA.
257 # RUN: yaml2obj %s --docnum=6 -o %t7.o
258 # RUN: llvm-readobj %t7.o --cg-profile | FileCheck %s --check-prefix=LLVM-RELA
259 # RUN: llvm-readelf %t7.o --cg-profile | FileCheck %s --check-prefix=GNU-RELA
261 # LLVM-RELA: CGProfile [
262 # LLVM-RELA-NEXT: CGProfileEntry {
263 # LLVM-RELA-NEXT: From: foo (1)
264 # LLVM-RELA-NEXT: To: bar (2)
265 # LLVM-RELA-NEXT: Weight: 89
267 # LLVM-RELA-NEXT: CGProfileEntry {
268 # LLVM-RELA-NEXT: From: bar (2)
269 # LLVM-RELA-NEXT: To: foo (1)
270 # LLVM-RELA-NEXT: Weight: 98
274 # GNU-RELA: GNUStyle::printCGProfile not implemented
283 - Name: .llvm.call-graph-profile
284 Type: SHT_LLVM_CALL_GRAPH_PROFILE
288 - Name: .rela.llvm.call-graph-profile
290 Info: .llvm.call-graph-profile
307 ## Check we report a warning when a RELA relocation section can't be loaded.
308 # RUN: yaml2obj %s --docnum=7 -o %t8.o
309 # RUN: llvm-readobj %t8.o --cg-profile 2>&1 | FileCheck %s -DFILE=%t8.o --check-prefix=LLVM-RELOC-WRONG-SIZE-RELA
310 # RUN: llvm-readobj %t8.o --elf-cg-profile 2>&1 | FileCheck %s -DFILE=%t8.o --check-prefix=LLVM-RELOC-WRONG-SIZE-RELA
312 # LLVM-RELOC-WRONG-SIZE-RELA: warning: '[[FILE]]': unable to load relocations for SHT_LLVM_CALL_GRAPH_PROFILE section: section [index 2] has invalid sh_entsize: expected 24, but got 16
313 # LLVM-RELOC-WRONG-SIZE-RELA-NEXT: CGProfile [
314 # LLVM-RELOC-WRONG-SIZE-RELA-NEXT: CGProfileEntry {
315 # LLVM-RELOC-WRONG-SIZE-RELA-NEXT: Weight: 89
316 # LLVM-RELOC-WRONG-SIZE-RELA-NEXT: }
317 # LLVM-RELOC-WRONG-SIZE-RELA-NEXT: CGProfileEntry {
318 # LLVM-RELOC-WRONG-SIZE-RELA-NEXT: Weight: 98
319 # LLVM-RELOC-WRONG-SIZE-RELA-NEXT: }
320 # LLVM-RELOC-WRONG-SIZE-RELA-NEXT: ]
329 - Name: .llvm.call-graph-profile
330 Type: SHT_LLVM_CALL_GRAPH_PROFILE
334 - Name: .rela.llvm.call-graph-profile
336 Info: .llvm.call-graph-profile
354 ## Check that we report a warning when we fail to get a section associated with
355 ## a relocation section.
357 # RUN: yaml2obj %s --docnum=8 -o %t9.o
358 # RUN: llvm-readobj %t9.o --cg-profile 2>&1 | FileCheck %s -DFILE=%t9.o --check-prefix=LLVM-RELOC-NO-SECTIONS
359 # RUN: llvm-readobj %t9.o --elf-cg-profile 2>&1 | FileCheck %s -DFILE=%t9.o --check-prefix=LLVM-RELOC-NO-SECTIONS
361 # LLVM-RELOC-NO-SECTIONS: warning: '[[FILE]]': unable to get CG Profile section(s): SHT_RELA section with index 1: failed to get a relocated section: invalid section index: 255
370 - Name: .rela.llvm.call-graph-profile