override-shflags.yaml 2.29 KB
## Check we are able to set custom sh_flags field
## for different sections.

# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readobj --sections %t1 | FileCheck %s --check-prefix=UPDATE-FLAGS

# UPDATE-FLAGS:      Name: .symtab
# UPDATE-FLAGS-NEXT: Type: SHT_SYMTAB
# UPDATE-FLAGS-NEXT: Flags [ (0x1)

# UPDATE-FLAGS:      Name: .strtab
# UPDATE-FLAGS-NEXT: Type: SHT_STRTAB
# UPDATE-FLAGS-NEXT: Flags [ (0x2)

# UPDATE-FLAGS:      Name: .shstrtab
# UPDATE-FLAGS-NEXT: Type: SHT_STRTAB
# UPDATE-FLAGS-NEXT: Flags [ (0x3)

# UPDATE-FLAGS:      Name: .dynsym
# UPDATE-FLAGS-NEXT: Type: SHT_DYNSYM
# UPDATE-FLAGS-NEXT: Flags [ (0x4)

# UPDATE-FLAGS:      Name: .dynstr
# UPDATE-FLAGS-NEXT: Type: SHT_STRTAB
# UPDATE-FLAGS-NEXT: Flags [ (0x5)

# UPDATE-FLAGS:      Name: .regular.os
# UPDATE-FLAGS-NEXT: Type: SHT_PROGBITS
# UPDATE-FLAGS-NEXT: Flags [ (0xAB00000)

# UPDATE-FLAGS:      Name: .regular.proc
# UPDATE-FLAGS-NEXT: Type: SHT_PROGBITS
# UPDATE-FLAGS-NEXT: Flags [ (0xC0000000)

# UPDATE-FLAGS:      Name: .regular.all
# UPDATE-FLAGS-NEXT: Type: SHT_PROGBITS
# UPDATE-FLAGS-NEXT: Flags [ (0xFFFFFFFF)

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_X86_64
Sections:
## Check we can override flags for implicit sections.
  - Name: .symtab
    Type: SHT_SYMTAB
    ShFlags: 0x000000001
  - Name: .strtab
    Type: SHT_STRTAB
    ShFlags: 0x000000002
  - Name: .shstrtab
    Type: SHT_STRTAB
    ShFlags: 0x000000003
  - Name: .dynsym
    Type: SHT_DYNSYM
    ShFlags: 0x000000004
  - Name: .dynstr
    Type: SHT_STRTAB
    ShFlags: 0x000000005
## Check we can override flags for regular sections.
  - Name: .regular.os
    Type: SHT_PROGBITS
    ShFlags: 0x0AB00000
  - Name: .regular.proc
    Type: SHT_PROGBITS
    ShFlags: 0xC0000000
  - Name: .regular.all
    Type: SHT_PROGBITS
    ShFlags: 0xFFFFFFFF

## ShFlags is used when we want to work around the flag values validation.
## It does not make sense to allow both ShFlags and Flags in the document.

# RUN: not yaml2obj --docnum=2 %s 2>&1 | FileCheck %s --check-prefix=ERR

# ERR: error: ShFlags and Flags cannot be used together

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_X86_64
Sections:
  - Name: .symtab
    Type: SHT_SYMTAB
    Flags: [ SHF_ALLOC ]
    ShFlags: 0x1