xref: /llvm-project/llvm/test/tools/yaml2obj/ELF/override-shtype.yaml (revision 51f4958057d6c246e85c3fbc65353bc0d7c1049b)
1## Check we are able to override the sh_type field for different sections.
2## When doing this we are still able to use YAML keys that can be normally used
3## to describe a section with the original type specified with the Type key.
4
5# RUN: yaml2obj %s -o %t1
6# RUN: llvm-readobj --sections --section-data %t1 | FileCheck %s --check-prefixes=COMMON,ORIGINAL
7
8## Check we can use a hex value for the ShType. SHT_PROGBITS == 0x1.
9# RUN: yaml2obj -DTYPE=0x1 %s -o %t2
10# RUN: llvm-readobj --sections --section-data %t2 | FileCheck %s --check-prefixes=COMMON,OVERRIDE
11
12# COMMON:        Name: .gnu.version_r
13# ORIGINAL-NEXT: Type: SHT_GNU_verneed
14# OVERRIDE-NEXT: Type: SHT_PROGBITS
15# COMMON:        SectionData (
16# COMMON-NEXT:     0000: 01000100 04000000 10000000 00000000 |
17# COMMON-NEXT:     0010: 91070000 00000300 01000000 00000000 |
18# COMMON-NEXT:   )
19
20## Check we can use a string type name for the ShType.
21# RUN: yaml2obj -DTYPE=SHT_PROGBITS %s -o %t3
22# RUN: cmp %t2 %t3
23
24--- !ELF
25FileHeader:
26  Class: ELFCLASS64
27  Data:  ELFDATA2LSB
28  Type:  ET_EXEC
29Sections:
30  - Name:   .gnu.version_r
31    Type:   SHT_GNU_verneed
32    Flags:  [ SHF_ALLOC ]
33    ShType: [[TYPE=SHT_GNU_verneed]]
34    Dependencies:
35      - Version: 1
36        File:    dso.so.0
37        Entries:
38          - Name:  v1
39            Hash:  1937
40            Flags: 0
41            Other: 3
42DynamicSymbols: []
43