Skip to content

Commit c4ea41d

Browse files
committed
Relocatable file tests fixed.
1 parent 5b3bff0 commit c4ea41d

File tree

2 files changed

+473
-177
lines changed

2 files changed

+473
-177
lines changed
Lines changed: 147 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
## Tests how --call-graph-info prints the call graph information.
2-
# RUN: yaml2obj --docnum=1 %s -o %t
3-
# RUN: llvm-readelf --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines --allow-empty -DFILE=%t
4-
# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines --check-prefix=LLVM -DFILE=%t
5-
# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines --check-prefix=JSON -DFILE=%t
1+
## Tests --call-graph-info prints information from call graph section.
62

7-
## Yaml input is obtained by compiling the below source to object with:
8-
## clang -fexperimental-call-graph-section test.c -o test.o
9-
## then to yaml with:
10-
## obj2yaml test.o > test.yaml
11-
## Remove ProgramHeaders if obj2yaml fails.
3+
# REQUIRES: x86-registered-target
124

13-
## YAML output was generated from the following source:
5+
# RUN: llvm-mc %s -filetype=obj -triple=x86_64-pc-linux -o %t
6+
# RUN: llvm-readelf --call-graph-info %t 2>&1 | FileCheck %s --allow-empty -DFILE=%t
7+
# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=LLVM
8+
# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=JSON
9+
10+
## Assembly output was generated from the following source using this command
11+
## clang -fexperimental-call-graph-section -S test.cpp -o test.S
1412
##
1513
## void foo() {}
1614
##
@@ -75,7 +73,7 @@
7573
# LLVM-NEXT: IndirectTypeIDs: []
7674
# LLVM-NEXT: }
7775
# LLVM-NEXT: Function {
78-
# LLVM-NEXT: Name: main
76+
# LLVM-NEXT: Name: _Z6callerv
7977
# LLVM-NEXT: Version: 0
8078
# LLVM-NEXT: IsIndirectTarget: Yes
8179
# LLVM-NEXT: TypeId: 0xA9494DEF81A01DC
@@ -135,7 +133,7 @@
135133
# JSON-NEXT: },
136134
# JSON-NEXT: {
137135
# JSON-NEXT: "Function": {
138-
# JSON-NEXT: "Name": "caller",
136+
# JSON-NEXT: "Name": "_Z6callerv",
139137
# JSON-NEXT: "Version": 0,
140138
# JSON-NEXT: "IsIndirectTarget": true,
141139
# JSON-NEXT: "TypeId": 762397922298560988,
@@ -160,167 +158,139 @@
160158
# JSON-NEXT: }
161159
# JSON-NEXT: ]
162160

163-
--- !ELF
164-
FileHeader:
165-
Class: ELFCLASS64
166-
Data: ELFDATA2LSB
167-
Type: ET_REL
168-
Machine: EM_X86_64
169-
SectionHeaderStringTable: .strtab
170-
Sections:
171-
- Name: .text
172-
Type: SHT_PROGBITS
173-
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
174-
AddressAlign: 0x10
175-
Content: 554889E55DC3662E0F1F840000000000554889E55DC3662E0F1F840000000000554889E54088F88845FF31C05DC36690554889E54883EC20488D0500000000488945F8FF55F8488D0500000000488945F0FF55F0488D0500000000488945E0488B45E00FBE7DEFFFD0E800000000E8000000000FBE7DEFE80000000031C04883C4205DC3
176-
- Name: .llvm.callgraph
177-
Type: SHT_LLVM_CALL_GRAPH
178-
Flags: [ SHF_LINK_ORDER ]
179-
Link: .text
180-
AddressAlign: 0x1
181-
Content: 00010000000000000000A220EFB89B695CF800010000000000000000A220EFB89B695CF8000100000000000000005486BC59814B8E3000070000000000000000DC011AF8DE94940A0300000000000000000000000000000000000000000000000002A220EFB89B695CF85486BC59814B8E30
182-
- Name: .comment
183-
Type: SHT_PROGBITS
184-
Flags: [ SHF_MERGE, SHF_STRINGS ]
185-
AddressAlign: 0x1
186-
EntSize: 0x1
187-
Content: 004675636873696120636C616E672076657273696F6E2032322E302E306769742028676974406769746875622E636F6D3A5072616268756B2F6C6C766D2D70726F6A6563742E67697420366532323235343933303736346536613734323839613261633731616637633834333038356633622900
188-
- Name: .note.GNU-stack
189-
Type: SHT_PROGBITS
190-
AddressAlign: 0x1
191-
- Name: .eh_frame
192-
Type: SHT_X86_64_UNWIND
193-
Flags: [ SHF_ALLOC ]
194-
AddressAlign: 0x8
195-
Content: 1400000000000000017A5200017810011B0C0708900100001C0000001C000000000000000600000000410E108602430D06410C07080000001C0000003C000000000000000600000000410E108602430D06410C07080000001C0000005C000000000000000E00000000410E108602430D06490C07080000001C0000007C000000000000005400000000410E108602430D06024F0C07080000
196-
- Name: .rela.text
197-
Type: SHT_RELA
198-
Flags: [ SHF_INFO_LINK ]
199-
Link: .symtab
200-
AddressAlign: 0x8
201-
Info: .text
202-
Relocations:
203-
- Offset: 0x3B
204-
Symbol: _Z3foov
205-
Type: R_X86_64_PC32
206-
Addend: -4
207-
- Offset: 0x49
208-
Symbol: _Z3barv
209-
Type: R_X86_64_PC32
210-
Addend: -4
211-
- Offset: 0x57
212-
Symbol: _Z3bazc
213-
Type: R_X86_64_PC32
214-
Addend: -4
215-
- Offset: 0x6A
216-
Symbol: _Z3foov
217-
Type: R_X86_64_PLT32
218-
Addend: -4
219-
- Offset: 0x6F
220-
Symbol: _Z3barv
221-
Type: R_X86_64_PLT32
222-
Addend: -4
223-
- Offset: 0x78
224-
Symbol: _Z3bazc
225-
Type: R_X86_64_PLT32
226-
Addend: -4
227-
- Name: .rela.llvm.callgraph
228-
Type: SHT_RELA
229-
Flags: [ SHF_INFO_LINK ]
230-
Link: .symtab
231-
AddressAlign: 0x8
232-
Info: .llvm.callgraph
233-
Relocations:
234-
- Offset: 0x2
235-
Symbol: _Z3foov
236-
Type: R_X86_64_64
237-
- Offset: 0x14
238-
Symbol: _Z3barv
239-
Type: R_X86_64_64
240-
- Offset: 0x26
241-
Symbol: _Z3bazc
242-
Type: R_X86_64_64
243-
- Offset: 0x38
244-
Symbol: _Z6callerv
245-
Type: R_X86_64_64
246-
- Offset: 0x49
247-
Symbol: _Z3foov
248-
Type: R_X86_64_64
249-
- Offset: 0x51
250-
Symbol: _Z3barv
251-
Type: R_X86_64_64
252-
- Offset: 0x59
253-
Symbol: _Z3bazc
254-
Type: R_X86_64_64
255-
- Name: .rela.eh_frame
256-
Type: SHT_RELA
257-
Flags: [ SHF_INFO_LINK ]
258-
Link: .symtab
259-
AddressAlign: 0x8
260-
Info: .eh_frame
261-
Relocations:
262-
- Offset: 0x20
263-
Symbol: .text
264-
Type: R_X86_64_PC32
265-
- Offset: 0x40
266-
Symbol: .text
267-
Type: R_X86_64_PC32
268-
Addend: 16
269-
- Offset: 0x60
270-
Symbol: .text
271-
Type: R_X86_64_PC32
272-
Addend: 32
273-
- Offset: 0x80
274-
Symbol: .text
275-
Type: R_X86_64_PC32
276-
Addend: 48
277-
- Name: .llvm_addrsig
278-
Type: SHT_LLVM_ADDRSIG
279-
Flags: [ SHF_EXCLUDE ]
280-
Link: .symtab
281-
AddressAlign: 0x1
282-
Symbols: [ _Z3foov, _Z3barv, _Z3bazc ]
283-
- Type: SectionHeaderTable
284-
Sections:
285-
- Name: .strtab
286-
- Name: .text
287-
- Name: .rela.text
288-
- Name: .llvm.callgraph
289-
- Name: .rela.llvm.callgraph
290-
- Name: .comment
291-
- Name: .note.GNU-stack
292-
- Name: .eh_frame
293-
- Name: .rela.eh_frame
294-
- Name: .llvm_addrsig
295-
- Name: .symtab
296-
Symbols:
297-
- Name: cg.cpp
298-
Type: STT_FILE
299-
Index: SHN_ABS
300-
- Name: .text
301-
Type: STT_SECTION
302-
Section: .text
303-
- Name: _Z3foov
304-
Type: STT_FUNC
305-
Section: .text
306-
Binding: STB_GLOBAL
307-
Size: 0x6
308-
- Name: _Z3barv
309-
Type: STT_FUNC
310-
Section: .text
311-
Binding: STB_GLOBAL
312-
Value: 0x10
313-
Size: 0x6
314-
- Name: _Z3bazc
315-
Type: STT_FUNC
316-
Section: .text
317-
Binding: STB_GLOBAL
318-
Value: 0x20
319-
Size: 0xE
320-
- Name: _Z6callerv
321-
Type: STT_FUNC
322-
Section: .text
323-
Binding: STB_GLOBAL
324-
Value: 0x30
325-
Size: 0x54
326-
...
161+
.file "cg.cpp"
162+
.text
163+
.globl _Z3foov # -- Begin function _Z3foov
164+
.p2align 4
165+
.type _Z3foov,@function
166+
_Z3foov: # @_Z3foov
167+
.Lfunc_begin0:
168+
.cfi_startproc
169+
# %bb.0: # %entry
170+
pushq %rbp
171+
.cfi_def_cfa_offset 16
172+
.cfi_offset %rbp, -16
173+
movq %rsp, %rbp
174+
.cfi_def_cfa_register %rbp
175+
popq %rbp
176+
.cfi_def_cfa %rsp, 8
177+
retq
178+
.Lfunc_end0:
179+
.size _Z3foov, .Lfunc_end0-_Z3foov
180+
.cfi_endproc
181+
.section .llvm.callgraph,"o",@llvm_call_graph,.text
182+
.byte 0
183+
.byte 1
184+
.quad _Z3foov
185+
.quad -550448936902516574
186+
.text
187+
# -- End function
188+
.globl _Z3barv # -- Begin function _Z3barv
189+
.p2align 4
190+
.type _Z3barv,@function
191+
_Z3barv: # @_Z3barv
192+
.Lfunc_begin1:
193+
.cfi_startproc
194+
# %bb.0: # %entry
195+
pushq %rbp
196+
.cfi_def_cfa_offset 16
197+
.cfi_offset %rbp, -16
198+
movq %rsp, %rbp
199+
.cfi_def_cfa_register %rbp
200+
popq %rbp
201+
.cfi_def_cfa %rsp, 8
202+
retq
203+
.Lfunc_end1:
204+
.size _Z3barv, .Lfunc_end1-_Z3barv
205+
.cfi_endproc
206+
.section .llvm.callgraph,"o",@llvm_call_graph,.text
207+
.byte 0
208+
.byte 1
209+
.quad _Z3barv
210+
.quad -550448936902516574
211+
.text
212+
# -- End function
213+
.globl _Z3bazc # -- Begin function _Z3bazc
214+
.p2align 4
215+
.type _Z3bazc,@function
216+
_Z3bazc: # @_Z3bazc
217+
.Lfunc_begin2:
218+
.cfi_startproc
219+
# %bb.0: # %entry
220+
pushq %rbp
221+
.cfi_def_cfa_offset 16
222+
.cfi_offset %rbp, -16
223+
movq %rsp, %rbp
224+
.cfi_def_cfa_register %rbp
225+
movb %dil, %al
226+
movb %al, -1(%rbp)
227+
xorl %eax, %eax
228+
popq %rbp
229+
.cfi_def_cfa %rsp, 8
230+
retq
231+
.Lfunc_end2:
232+
.size _Z3bazc, .Lfunc_end2-_Z3bazc
233+
.cfi_endproc
234+
.section .llvm.callgraph,"o",@llvm_call_graph,.text
235+
.byte 0
236+
.byte 1
237+
.quad _Z3bazc
238+
.quad 3498816979441845844
239+
.text
240+
# -- End function
241+
.globl _Z6callerv # -- Begin function _Z6callerv
242+
.p2align 4
243+
.type _Z6callerv,@function
244+
_Z6callerv: # @_Z6callerv
245+
.Lfunc_begin3:
246+
.cfi_startproc
247+
# %bb.0: # %entry
248+
pushq %rbp
249+
.cfi_def_cfa_offset 16
250+
.cfi_offset %rbp, -16
251+
movq %rsp, %rbp
252+
.cfi_def_cfa_register %rbp
253+
subq $32, %rsp
254+
leaq _Z3foov(%rip), %rax
255+
movq %rax, -8(%rbp)
256+
callq *-8(%rbp)
257+
leaq _Z3barv(%rip), %rax
258+
movq %rax, -16(%rbp)
259+
callq *-16(%rbp)
260+
leaq _Z3bazc(%rip), %rax
261+
movq %rax, -32(%rbp)
262+
movq -32(%rbp), %rax
263+
movsbl -17(%rbp), %edi
264+
callq *%rax
265+
callq _Z3foov
266+
callq _Z3barv
267+
movsbl -17(%rbp), %edi
268+
callq _Z3bazc
269+
xorl %eax, %eax
270+
addq $32, %rsp
271+
popq %rbp
272+
.cfi_def_cfa %rsp, 8
273+
retq
274+
.Lfunc_end3:
275+
.size _Z6callerv, .Lfunc_end3-_Z6callerv
276+
.cfi_endproc
277+
.section .llvm.callgraph,"o",@llvm_call_graph,.text
278+
.byte 0
279+
.byte 7
280+
.quad _Z6callerv
281+
.quad 762397922298560988
282+
.byte 3
283+
.quad _Z3foov
284+
.quad _Z3barv
285+
.quad _Z3bazc
286+
.byte 2
287+
.quad -550448936902516574
288+
.quad 3498816979441845844
289+
.text
290+
# -- End function
291+
.ident "Fuchsia clang version 22.0.0git ([email protected]:Prabhuk/llvm-project.git 5b3bff0cec35606b5b1b6564730fea8f8081b1ff)"
292+
.section ".note.GNU-stack","",@progbits
293+
.addrsig
294+
.addrsig_sym _Z3foov
295+
.addrsig_sym _Z3barv
296+
.addrsig_sym _Z3bazc

0 commit comments

Comments
 (0)