arm-exidx-section.yaml 3.15 KB
## Check how obj2yaml dumps the SHT_ARM_EXIDX section.

## For a valid section, obj2yaml emits the "Entries" key.
## This checks that we respect data endianness and recognize the
## EXIDX_CANTUNWIND (0x1) special value properly.

# RUN: yaml2obj --docnum=1 -DENCODE=LSB %s -o %t.le.so
# RUN: obj2yaml %t.le.so | FileCheck %s --check-prefix=LE
# RUN: yaml2obj --docnum=1 -DENCODE=MSB %s -o %t.be.so
# RUN: obj2yaml %t.be.so | FileCheck %s --check-prefix=BE

# LE:      - Name: .ARM.exidx
# LE-NEXT:   Type: SHT_ARM_EXIDX
# LE-NEXT:   Entries:
# LE-NEXT:     - Offset: 0xDDCCBBAA
# LE-NEXT:       Value:  0x01000000
# LE-NEXT:     - Offset: 0x9988FFEE
# LE-NEXT:       Value:  EXIDX_CANTUNWIND
# LE-NEXT: ...

# BE:      - Name: .ARM.exidx
# BE-NEXT:   Type: SHT_ARM_EXIDX
# BE-NEXT:   Entries:
# BE-NEXT:     - Offset: 0xAABBCCDD
# BE-NEXT:       Value:  EXIDX_CANTUNWIND
# BE-NEXT:     - Offset: 0xEEFF8899
# BE-NEXT:       Value:  0x01000000
# BE-NEXT: ...

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2[[ENCODE=LSB]]
  Type:    ET_DYN
  Machine: EM_ARM
Sections:
  - Name:    .ARM.exidx
    Type:    SHT_ARM_EXIDX
## 4 words: <arbitrary>, EXIDX_CANTUNWIND in big-endian,
##          <arbitrary> and EXIDX_CANTUNWIND in little-endian.
    Content: "AABBCCDD00000001EEFF889901000000"
    Size:    [[SIZE=<none>]]

## Check that we dump the content of a truncated SHT_ARM_EXIDX section
## using the "Content" key.
# RUN: yaml2obj --docnum=1 -DSIZE=17 %s -o %t.invalid-size.so
# RUN: obj2yaml %t.invalid-size.so | FileCheck %s --check-prefix=INVALID-SIZE

# INVALID-SIZE:      - Name:    .ARM.exidx
# INVALID-SIZE-NEXT:   Type:    SHT_ARM_EXIDX
# INVALID-SIZE-NEXT:   Content: AABBCCDD00000001EEFF88990100000000
# INVALID-SIZE-NEXT: ...

## Check how we dump an empty SHT_ARM_EXIDX section.
# RUN: yaml2obj --docnum=2 %s -o %t.empty.so
# RUN: obj2yaml %t.empty.so | FileCheck %s --check-prefix=EMPTY

# EMPTY:      - Name: .ARM.exidx
# EMPTY-NEXT:     Type:    SHT_ARM_EXIDX
# EMPTY-NEXT:     Entries: []
# EMPTY-NEXT: ...

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_DYN
  Machine: EM_ARM
Sections:
  - Name: .ARM.exidx
    Type: SHT_ARM_EXIDX

## Check how we dump the SHT_ARM_EXIDX (0x70000001) section when
## the machine type is not EM_ARM. It is dumped as a regular
## section of an unknown type.

# RUN: yaml2obj --docnum=3 %s -o %t.not-arm.so
# RUN: obj2yaml %t.not-arm.so | FileCheck %s --check-prefix=NOT-ARM

# RUN: yaml2obj --docnum=3 -DMACHINE=EM_ARM %s -o %t.arm.so
# RUN: obj2yaml %t.arm.so | FileCheck %s --check-prefix=ARM

# NOT-ARM:      Sections:
# NOT-ARM-NEXT:   - Name:    .ARM.exidx
# NOT-ARM-NEXT:     Type:    0x70000001
# NOT-ARM-NEXT:     Content: AABBCCDD11223344
# NOT-ARM-NEXT: ...

# ARM:      - Name: .ARM.exidx
# ARM-NEXT:   Type: SHT_ARM_EXIDX
# ARM-NEXT:   Entries:
# ARM-NEXT:     - Offset: 0xDDCCBBAA
# ARM-NEXT:       Value:  0x44332211
# ARM-NEXT: ...

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_DYN
  Machine: [[MACHINE=<none>]]
Sections:
  - Name:    .ARM.exidx
    Type:    SHT_PROGBITS
    ShType:  0x70000001 ## SHT_ARM_EXIDX
## An arbitrary valid content.
    Content: "AABBCCDD11223344"