aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/tools/llvm-objdump/ELF/verdef-invalid.test
blob: 45f2331eadc34b0869aa1cf7c0741708310fcef6 (plain)
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
69
70
71
72
73
74
75
76
77
## Adapted from test/llvm-readobj/ELF/verdef-invalid.test
## Check that we report a warning when a SHT_GNU_verdef section contains a version definition
## that refers to an auxiliary entry that goes past the end of the section.

# RUN: yaml2obj %s -o %t
# RUN: llvm-objdump -p %t 2>&1 | FileCheck %s --check-prefix=AUX-PAST-END -DFILE=%t

# AUX-PAST-END: warning: '[[FILE]]': invalid SHT_GNU_verdef section with index 1: version definition 1 refers to an auxiliary entry that goes past the end of the section

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_DYN
Sections:
  - Name: .gnu.version_d
    Type: SHT_GNU_verdef
    Entries:
      - Names:
          - FOO
    ## The correct sh_size is 28.
    ShSize: 27
DynamicSymbols:
  - Name: foo

## Check we report a warning when a version definition is not correctly aligned in memory.

# RUN: yaml2obj %s --docnum=2 -o %t2
# RUN: llvm-objdump -p %t2 2>&1 | FileCheck %s --check-prefix=MISALIGNED-DEF -DFILE=%t2

# MISALIGNED-DEF: warning: '[[FILE]]': invalid SHT_GNU_verdef section with index 1: found a misaligned version definition entry at offset 0x0

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_DYN
Sections:
  - Type: Fill
    Size: 0x1
  - Name: .gnu.version_d
    Type: SHT_GNU_verdef
    Link: .dynstr
    Info: 0x1
    Entries:
      - Names:
          - FOO
DynamicSymbols:
  - Name: foo

## Check we report "invalid vda_name" when vda_name = size(.dynstr)

# RUN: yaml2obj %s --docnum=3 -o %t3
# RUN: llvm-objdump -p %t3 2>&1 | FileCheck %s --check-prefix=VDANAME-PAST-END --implicit-check-not=warning:

# VDANAME-PAST-END:      Version definitions:
# VDANAME-PAST-END-NEXT: 0 0x00 0x00000000 V0
# VDANAME-PAST-END-NEXT:         <invalid vda_name: 7>

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_DYN
Sections:
  - Name:  .gnu.version_d
    Type:  SHT_GNU_verdef
    Flags: [ SHF_ALLOC ]
    Link:  .dynstr
    Info:  0x1
## The byte offset to the auxiliary entry is 0x13, i.e. it is not correctly aligned in memory.
    Content: "010000000000020000000000140000000000000004000000080000000700000000000000"
DynamicSymbols:
  - Name:    V1
    Binding: STB_GLOBAL
  - Name:    V0
    Binding: STB_GLOBAL