elf-stack-sizes.yaml 2.47 KB
## Check how obj2yaml produces YAML .stack_sizes descriptions.

## Check that obj2yaml uses the "Entries" tag to describe a .stack_sizes section
## when it can extract <address, size> pairs.

# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: obj2yaml %t1 | FileCheck %s --check-prefix=VALID

# VALID:      --- !ELF
# VALID-NEXT: FileHeader:
# VALID-NEXT:   Class:   ELFCLASS64
# VALID-NEXT:   Data:    ELFDATA2LSB
# VALID-NEXT:   Type:    ET_EXEC
# VALID-NEXT:   Machine: EM_X86_64
# VALID-NEXT: Sections:
# VALID-NEXT:   - Name: .stack_sizes
# VALID-NEXT:     Type: SHT_PROGBITS
# VALID-NEXT:     Entries:
# VALID-NEXT:       - Address: 0x0000000000000010
# VALID-NEXT:         Size:    0x0000000000000020
# VALID-NEXT:       - Address: 0x0000000000000030
# VALID-NEXT:         Size:    0x0000000000000040

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_EXEC
  Machine: EM_X86_64
Sections:
  - Name:    .stack_sizes
    Type:    SHT_PROGBITS
    Content: "100000000000000020300000000000000040"

## Check that obj2yaml uses the "Content" tag to describe a .stack_sizes section
## when it can't extract the entries, for example, when section data is truncated.

# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: obj2yaml %t2 | FileCheck %s --check-prefix=INVALID

# INVALID:      --- !ELF
# INVALID-NEXT: FileHeader:
# INVALID-NEXT:   Class:   ELFCLASS64
# INVALID-NEXT:   Data:    ELFDATA2LSB
# INVALID-NEXT:   Type:    ET_EXEC
# INVALID-NEXT:   Machine: EM_X86_64
# INVALID-NEXT: Sections:
# INVALID-NEXT:   - Name:    .stack_sizes
# INVALID-NEXT:     Type:    SHT_PROGBITS
# INVALID-NEXT:     Content: '1000000000000000203000000000000000'

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_EXEC
  Machine: EM_X86_64
Sections:
  - Name:    .stack_sizes
    Type:    SHT_PROGBITS
    Content: "1000000000000000203000000000000000"

## Check obj2yaml can dump empty .stack_sizes.

# RUN: yaml2obj --docnum=3 %s -o %t3
# RUN: obj2yaml %t3 | FileCheck %s --check-prefix=EMPTY

# EMPTY:      --- !ELF
# EMPTY-NEXT: FileHeader:
# EMPTY-NEXT:   Class:   ELFCLASS64
# EMPTY-NEXT:   Data:    ELFDATA2LSB
# EMPTY-NEXT:   Type:    ET_EXEC
# EMPTY-NEXT:   Machine: EM_X86_64
# EMPTY-NEXT: Sections:
# EMPTY-NEXT:   - Name:    .stack_sizes
# EMPTY-NEXT:     Type:    SHT_PROGBITS
# EMPTY-NEXT:     Content: ''

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_EXEC
  Machine: EM_X86_64
Sections:
  - Name:    .stack_sizes
    Type:    SHT_PROGBITS
    Content: ""