reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
## Test that we are able to dump section headers even if the
## .dynsym section's sh_link field is broken.

## Case 1: sh_link is set to 0.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readobj -S %t1 2>&1 | FileCheck %s -DFILE=%t1 --check-prefixes=LLVM,ERR
# RUN: llvm-readelf -S %t1 2>&1 | FileCheck %s -DFILE=%t1 --check-prefixes=GNU,ERR

# ERR: warning: '[[FILE]]': invalid sh_type for string table section [index 0]: expected SHT_STRTAB, but got SHT_NULL

# LLVM:      Name: .dynsym
# LLVM-NEXT:  Type: SHT_DYNSYM
# LLVM-NEXT:  Flags [
# LLVM-NEXT:    SHF_ALLOC
# LLVM-NEXT:  ]
# LLVM-NEXT:  Address: 0x0
# LLVM-NEXT:  Offset: 0x40
# LLVM-NEXT:  Size: 24
# LLVM-NEXT:  Link: 0

# GNU:      Section Headers:
# GNU-NEXT:  [Nr] Name    Type   Address          Off    Size   ES Flg Lk
# GNU-NEXT:  [ 0]         NULL   0000000000000000 000000 000000 00 0   0
# GNU-NEXT:  [ 1] .dynsym DYNSYM 0000000000000000 000040 000018 18 A   0

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_DYN
  Machine: EM_X86_64
Sections:
  - Name: .dynsym
    Type: SHT_DYNSYM

## Case 2: sh_link is set to 255, which is larger than the number of the sections.
# RUN: yaml2obj --docnum=2 %s -o %t2

# RUN: llvm-readobj -S %t2 2>&1 | FileCheck -DFILE=%t2 %s --check-prefixes=LLVM2,ERR2
# RUN: llvm-readelf -S %t2 2>&1 | FileCheck -DFILE=%t2 %s --check-prefixes=GNU2,ERR2

# ERR2: warning: '[[FILE]]': invalid section index

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_DYN
  Machine: EM_X86_64
Sections:
  - Name: .dynsym
    Type: SHT_DYNSYM
    Link: 255

# LLVM2:      Name: .dynsym
# LLVM2-NEXT:  Type: SHT_DYNSYM
# LLVM2-NEXT:  Flags [
# LLVM2-NEXT:    SHF_ALLOC
# LLVM2-NEXT:  ]
# LLVM2-NEXT:  Address: 0x0
# LLVM2-NEXT:  Offset: 0x40
# LLVM2-NEXT:  Size: 24
# LLVM2-NEXT:  Link: 255

# GNU2:      Section Headers:
# GNU2-NEXT:  [Nr] Name    Type   Address          Off    Size   ES Flg Lk
# GNU2-NEXT:  [ 0]         NULL   0000000000000000 000000 000000 00 0   0
# GNU2-NEXT:  [ 1] .dynsym DYNSYM 0000000000000000 000040 000018 18 A   255