llvm.org GIT mirror llvm / master test / tools / llvm-readobj / elf-addrsig.test
master

Tree @master (Download .tar.gz)

elf-addrsig.test @masterraw · history · blame

## Show that llvm-readobj can dump SHT_LLVM_ADDRSIG sections.

# RUN: yaml2obj --docnum=1 %s -o %t1.o
# RUN: llvm-readobj --addrsig %t1.o | FileCheck -DFILE=%t1.o %s --check-prefix LLVM
# RUN: not llvm-readelf --addrsig %t1.o 2>&1 | FileCheck -DFILE=%t1.o %s --check-prefix GNU

# LLVM:      Addrsig [
# LLVM-NEXT:   Sym: foo (1)
# LLVM-NEXT:   Sym: bar (2)
# LLVM-NEXT: ]

# GNU: error: '[[FILE]]': --addrsig: not implemented

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_DYN
  Machine: EM_X86_64
Sections:
  - Name: .llvm_addrsig
    Type: SHT_LLVM_ADDRSIG
    Symbols:
      - Name: foo
      - Name: bar
Symbols:
  - Name: foo
  - Name: bar

## Check that llvm-readobj dumps any SHT_LLVM_ADDRSIG section when --all
## is specified for LLVM style, but not for GNU style.
## TODO: Refine the llvm-readelf check when GNU-style dumping is implemented.

# RUN: llvm-readobj --all %t1.o | FileCheck %s --check-prefix LLVM
# RUN: llvm-readelf --all %t1.o 2>&1 | FileCheck %s --implicit-check-not=warning --implicit-check-not=error

## Check we report a warning when SHT_LLVM_ADDRSIG is broken (e.g. contains a malformed uleb128).

# RUN: yaml2obj --docnum=2 %s -o %t2.o
# RUN: llvm-readobj --addrsig %t2.o 2>&1 | FileCheck %s -DFILE=%t2.o --check-prefix=MALFORMED

# MALFORMED: warning: '[[FILE]]': malformed uleb128, extends past end

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

## Check we report a warning when SHT_LLVM_ADDRSIG references a symbol that can't be
## dumped (e.g. the index value is larger than the number of symbols in .symtab).

# RUN: yaml2obj --docnum=3 %s -o %t3.o
# RUN: llvm-readobj --addrsig %t3.o 2>&1 | FileCheck %s -DFILE=%t3.o --check-prefix=INVALID-INDEX

# INVALID-INDEX:       Addrsig [
# INVALID-INDEX-NEXT:    Sym: foo (1)
# INVALID-INDEX-EMPTY:
# INVALID-INDEX-NEXT:    warning: '[[FILE]]': unable to get symbol from section [index 2]: invalid symbol index (255)
# INVALID-INDEX-NEXT:    Sym: <?> (255)
# INVALID-INDEX-NEXT:    Sym: bar (2)
# INVALID-INDEX-NEXT:  ]

--- !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: 255
      - Index: 2
Symbols:
  - Name: foo
  - Name: bar