1## Check we are able to set custom sh_flags field
2## for different sections.
3
4# RUN: yaml2obj --docnum=1 %s -o %t1
5# RUN: llvm-readobj --sections %t1 | FileCheck %s --check-prefix=UPDATE-FLAGS
6
7# UPDATE-FLAGS:      Name: .symtab
8# UPDATE-FLAGS-NEXT: Type: SHT_SYMTAB
9# UPDATE-FLAGS-NEXT: Flags [ (0x1)
10
11# UPDATE-FLAGS:      Name: .strtab
12# UPDATE-FLAGS-NEXT: Type: SHT_STRTAB
13# UPDATE-FLAGS-NEXT: Flags [ (0x2)
14
15# UPDATE-FLAGS:      Name: .shstrtab
16# UPDATE-FLAGS-NEXT: Type: SHT_STRTAB
17# UPDATE-FLAGS-NEXT: Flags [ (0x3)
18
19# UPDATE-FLAGS:      Name: .dynsym
20# UPDATE-FLAGS-NEXT: Type: SHT_DYNSYM
21# UPDATE-FLAGS-NEXT: Flags [ (0x4)
22
23# UPDATE-FLAGS:      Name: .dynstr
24# UPDATE-FLAGS-NEXT: Type: SHT_STRTAB
25# UPDATE-FLAGS-NEXT: Flags [ (0x5)
26
27# UPDATE-FLAGS:      Name: .regular.os
28# UPDATE-FLAGS-NEXT: Type: SHT_PROGBITS
29# UPDATE-FLAGS-NEXT: Flags [ (0xAB00000)
30
31# UPDATE-FLAGS:      Name: .regular.proc
32# UPDATE-FLAGS-NEXT: Type: SHT_PROGBITS
33# UPDATE-FLAGS-NEXT: Flags [ (0xC0000000)
34
35# UPDATE-FLAGS:      Name: .regular.all
36# UPDATE-FLAGS-NEXT: Type: SHT_PROGBITS
37# UPDATE-FLAGS-NEXT: Flags [ (0xFFFFFFFF)
38
39--- !ELF
40FileHeader:
41  Class: ELFCLASS64
42  Data:  ELFDATA2LSB
43  Type:  ET_REL
44Sections:
45## Check we can override flags for implicit sections.
46  - Name: .symtab
47    Type: SHT_SYMTAB
48    ShFlags: 0x000000001
49  - Name: .strtab
50    Type: SHT_STRTAB
51    ShFlags: 0x000000002
52  - Name: .shstrtab
53    Type: SHT_STRTAB
54    ShFlags: 0x000000003
55  - Name: .dynsym
56    Type: SHT_DYNSYM
57    ShFlags: 0x000000004
58  - Name: .dynstr
59    Type: SHT_STRTAB
60    ShFlags: 0x000000005
61## Check we can override flags for regular sections.
62  - Name: .regular.os
63    Type: SHT_PROGBITS
64    ShFlags: 0x0AB00000
65  - Name: .regular.proc
66    Type: SHT_PROGBITS
67    ShFlags: 0xC0000000
68  - Name: .regular.all
69    Type: SHT_PROGBITS
70    ShFlags: 0xFFFFFFFF
71
72## ShFlags is used when we want to work around the flag values validation.
73## It does not make sense to allow both ShFlags and Flags in the document.
74
75# RUN: not yaml2obj --docnum=2 %s 2>&1 | FileCheck %s --check-prefix=ERR
76
77# ERR: error: ShFlags and Flags cannot be used together
78
79--- !ELF
80FileHeader:
81  Class: ELFCLASS64
82  Data:  ELFDATA2LSB
83  Type:  ET_REL
84Sections:
85  - Name: .symtab
86    Type: SHT_SYMTAB
87    Flags: [ SHF_ALLOC ]
88    ShFlags: 0x1
89