blob: 121b1e950c39a1ff24b6e6a4331372d3d8393a3f [file] [log] [blame]
## Test how we create SHT_LLVM_CALL_GRAPH_PROFILE sections.
## Test that the content of SHT_LLVM_CALL_GRAPH_PROFILE sections
## for 32/64-bit little/big endian targets is correct.
# RUN: yaml2obj --docnum=1 -D BITS=64 -D ENCODE=LSB %s -o %t.le64
# RUN: llvm-readobj --cg-profile --sections --section-data %t.le64 | FileCheck %s --check-prefixes=BASIC,BASIC-LE
# RUN: yaml2obj --docnum=1 -D BITS=64 -D ENCODE=MSB %s -o %t.be64
# RUN: llvm-readobj --cg-profile --sections --section-data %t.be64 | FileCheck %s --check-prefixes=BASIC,BASIC-BE
# RUN: yaml2obj --docnum=1 -D BITS=32 -D ENCODE=LSB %s -o %t.le32
# RUN: llvm-readobj --cg-profile --sections --section-data %t.le32 | FileCheck %s --check-prefixes=BASIC,BASIC-LE
# RUN: yaml2obj --docnum=1 -D BITS=32 -D ENCODE=MSB %s -o %t.be32
# RUN: llvm-readobj --cg-profile --sections --section-data %t.be32 | FileCheck %s --check-prefixes=BASIC,BASIC-BE
# BASIC: Name: .llvm.call-graph-profile
# BASIC-NEXT: Type: SHT_LLVM_CALL_GRAPH_PROFILE
# BASIC-NEXT: Flags [
# BASIC-NEXT: ]
# BASIC-NEXT: Address: 0x0
# BASIC-NEXT: Offset:
# BASIC-NEXT: Size: 16
## Check that we link SHT_LLVM_CALL_GRAPH_PROFILE section with .symtab by default.
# BASIC-NEXT: Link: [[SYMTABNDX:.*]]
# BASIC-NEXT: Info: 0
# BASIC-NEXT: AddressAlignment: 0
## Check that the entry size is set to 16 by default.
# BASIC-NEXT: EntrySize: 8
# BASIC-NEXT: SectionData (
# BASIC-LE-NEXT: 0000: 59000000 00000000 62000000 00000000
# BASIC-BE-NEXT: 0000: 00000000 00000059 00000000 00000062
# BASIC-NEXT: )
# BASIC-NEXT: }
# BASIC-NEXT: Section {
# BASIC-NEXT: Index: [[SYMTABNDX]]
# BASIC-NEXT: Name: .symtab
# BASIC: CGProfile [
# BASIC-NEXT: CGProfileEntry {
# BASIC-NEXT: Weight: 89
# BASIC-NEXT: }
# BASIC-NEXT: CGProfileEntry {
# BASIC-NEXT: Weight: 98
# BASIC-NEXT: }
# BASIC-NEXT: ]
--- !ELF
FileHeader:
Class: ELFCLASS[[BITS]]
Data: ELFDATA2[[ENCODE]]
Type: ET_DYN
Sections:
- Name: .llvm.call-graph-profile
Type: SHT_LLVM_CALL_GRAPH_PROFILE
Entries:
- Weight: 89
- Weight: 98
Symbols:
- Name: foo
- Name: bar
## Check we can set arbitrary sh_link and sh_entsize values.
## Check we can specify none of "Content", "Entries", and "Size" tags.
# RUN: yaml2obj --docnum=2 %s -o %t.link
# RUN: llvm-readelf --sections %t.link | FileCheck %s --check-prefix=LINK
# LINK: [Nr] Name Type Address Off Size ES Flg Lk
# LINK: [ 1] .llvm.foo LLVM_CALL_GRAPH_PROFILE 0000000000000000 000040 000000 00 0
# LINK: [ 2] .llvm.bar LLVM_CALL_GRAPH_PROFILE 0000000000000000 000040 000000 ff 255
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Sections:
- Name: .llvm.foo
Type: SHT_LLVM_CALL_GRAPH_PROFILE
Link: 0x0
EntSize: 0
- Name: .llvm.bar
Type: SHT_LLVM_CALL_GRAPH_PROFILE
Link: 0xFF
EntSize: 0xFF
## Check we can describe SHT_LLVM_CALL_GRAPH_PROFILE sections using the "Content" tag.
# RUN: yaml2obj --docnum=3 %s -o %t.content
# RUN: llvm-readobj --sections --section-data %t.content | FileCheck %s --check-prefix=CONTENT
# CONTENT: Name: .llvm.call-graph-profile
# CONTENT: SectionData (
# CONTENT-NEXT: 0000: 11223344 |
# CONTENT-NEXT: )
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Sections:
- Name: .llvm.call-graph-profile
Type: SHT_LLVM_CALL_GRAPH_PROFILE
Content: "11223344"
## Check we can use the "Content" key with the "Size" key when the size is greater
## than or equal to the content size.
# RUN: not yaml2obj --docnum=4 -DSIZE=1 -DCONTENT="'0011'" %s 2>&1 | \
# RUN: FileCheck %s --check-prefix=CONTENT-SIZE-ERR
# CONTENT-SIZE-ERR: error: Section size must be greater than or equal to the content size
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Sections:
- Name: .llvm.foo
Type: SHT_LLVM_CALL_GRAPH_PROFILE
Link: 0x1
EntSize: 0x2
Size: [[SIZE=<none>]]
Content: [[CONTENT=<none>]]
Entries: [[ENTRIES=<none>]]
# RUN: yaml2obj --docnum=4 -DSIZE=2 -DCONTENT="'0011'" %s -o %t.cont.size.eq.o
# RUN: llvm-readobj --sections --section-data %t.cont.size.eq.o | \
# RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="0011"
# RUN: yaml2obj --docnum=4 -DSIZE=3 -DCONTENT="'0011'" %s -o %t.cont.size.gr.o
# RUN: llvm-readobj --sections --section-data %t.cont.size.gr.o | \
# RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="001100"
# CHECK-CONTENT: Name: .llvm.foo
# CHECK-CONTENT-NEXT: Type: SHT_LLVM_CALL_GRAPH_PROFILE
# CHECK-CONTENT-NEXT: Flags [
# CHECK-CONTENT-NEXT: ]
# CHECK-CONTENT-NEXT: Address:
# CHECK-CONTENT-NEXT: Offset:
# CHECK-CONTENT-NEXT: Size:
# CHECK-CONTENT-NEXT: Link: 1
# CHECK-CONTENT-NEXT: Info:
# CHECK-CONTENT-NEXT: AddressAlignment:
# CHECK-CONTENT-NEXT: EntrySize: 2
# CHECK-CONTENT-NEXT: SectionData (
# CHECK-CONTENT-NEXT: 0000: [[DATA]] |
# CHECK-CONTENT-NEXT: )
## Check we can use the "Size" key alone to create the section.
# RUN: yaml2obj --docnum=4 -DSIZE=3 %s -o %t.size.o
# RUN: llvm-readobj --sections --section-data %t.size.o | \
# RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="000000"
## Check we can use the "Content" key alone to create the section.
# RUN: yaml2obj --docnum=4 -DCONTENT="'112233'" %s -o %t.content.o
# RUN: llvm-readobj --sections --section-data %t.content.o | \
# RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="112233"
## Check we can't use the "Entries" key together with the "Content" or "Size" keys.
# RUN: not yaml2obj --docnum=4 -DSIZE=0 -DENTRIES="[]" %s 2>&1 | \
# RUN: FileCheck %s --check-prefix=ENTRIES-ERR
# RUN: not yaml2obj --docnum=4 -DCONTENT="'00'" -DENTRIES="[]" %s 2>&1 | \
# RUN: FileCheck %s --check-prefix=ENTRIES-ERR
# ENTRIES-ERR: error: "Entries" cannot be used with "Content" or "Size"