elf-llvm-addrsig-section.yaml 2.5 KB
## Check how obj2yaml dumps the SHT_LLVM_ADDRSIG section.

## Check that when possible obj2yaml tries to produce the "Name" tag when
## dumping entries of the SHT_LLVM_ADDRSIG section. It falls back to producing
## the "Index" tag when it can't match a symbol index with a symbol table entry.

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

# NAME:      - Name: .llvm_addrsig
# NAME-NEXT:   Type: SHT_LLVM_ADDRSIG
# NAME-NEXT:   Link: .symtab
# NAME-NEXT:   Symbols:
# NAME-NEXT:     - Name:  foo
# NAME-NEXT:     - Name:  bar
# NAME-NEXT:     - Index: 0x00000003
# NAME-NEXT:     - Index: 0xFFFFFFFF
# NAME:      - Name: .llvm_addrsig_unlinked
# NAME-NEXT:   Type: SHT_LLVM_ADDRSIG
# NAME-NEXT:   Symbols:
# NAME-NEXT:     - Index: 0x00000001
# NAME-NEXT:     - Index: 0x00000002
# NAME-NEXT:     - Index: 0x00000003
# NAME-NEXT:     - Index: 0xFFFFFFFF

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_DYN
  Machine: EM_X86_64
Sections:
  - Name: .llvm_addrsig
    Type: SHT_LLVM_ADDRSIG
    Symbols:
      - Index: 1
      - Index: 2
      - Index: 3
      - Index: 0xFFFFFFFF
  - Name: .llvm_addrsig_unlinked
    Type: SHT_LLVM_ADDRSIG
    Link: 0
    Symbols:
      - Index: 1
      - Index: 2
      - Index: 3
      - Index: 0xFFFFFFFF
Symbols:
  - Name:    foo
    Type:    STT_FUNC
    Binding: STB_GLOBAL
  - Name:    bar
    Type:    STT_FUNC
    Binding: STB_GLOBAL

## Check that obj2yaml dumps the SHT_LLVM_ADDRSIG section
## data using the "Content" tag when at least one of the entries is broken,
## e.g. because the entry contains a malformed uleb128 value.

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

# INVALID-ENTRY:      - Name:    .llvm_addrsig
# INVALID-ENTRY-NEXT:   Type:    SHT_LLVM_ADDRSIG
# INVALID-ENTRY-NEXT:   Content: FFFFFFFFFF

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_DYN
  Machine: EM_X86_64
Sections:
  - Name: .llvm_addrsig
    Type: SHT_LLVM_ADDRSIG
    Content: "FFFFFFFFFF"

## obj2yaml produces a "Symbols" tag when describing an empty SHT_LLVM_ADDRSIG section.

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

# EMPTY:      - Name:    .llvm_addrsig
# EMPTY-NEXT:   Type:    SHT_LLVM_ADDRSIG
# EMPTY-NEXT:   Symbols: []

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_DYN
  Machine: EM_X86_64
Sections:
  - Name: .llvm_addrsig
    Type: SHT_LLVM_ADDRSIG
    Content: ""