elf-dynamic-symbols.test
3.14 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
## Test that llvm-objdump can dump dynamic symbols.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-objdump --dynamic-syms %t1 | \
# RUN: FileCheck %s --match-full-lines --strict-whitespace --check-prefix=DYNSYM
# RUN: llvm-objdump -T %t1 | \
# RUN: FileCheck %s --match-full-lines --strict-whitespace --check-prefix=DYNSYM
# DYNSYM:DYNAMIC SYMBOL TABLE:
# DYNSYM-NEXT:0000000000000000 l DO .data 0000000000000000 localsym
# DYNSYM-NEXT:0000000000000000 g DO .data 0000000000000000 globalsym
# DYNSYM-NEXT:0000000000000000 u DO .data 0000000000000000 uniqueglobalsym
# DYNSYM-NEXT:0000000000000000 w DO .data 0000000000000000 weaksym
# DYNSYM-NEXT:0000000000000000 g Df .data 0000000000000000 filesym
# DYNSYM-NEXT:0000000000000000 g DF .data 0000000000000000 funcsym
# DYNSYM-EMPTY:
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_WRITE ]
DynamicSymbols:
- Name: localsym
Type: STT_OBJECT
Section: .data
Binding: STB_LOCAL
- Name: globalsym
Type: STT_OBJECT
Section: .data
Binding: STB_GLOBAL
- Name: uniqueglobalsym
Type: STT_OBJECT
Section: .data
Binding: STB_GNU_UNIQUE
- Name: weaksym
Type: STT_OBJECT
Section: .data
Binding: STB_WEAK
- Name: filesym
Type: STT_FILE
Section: .data
Binding: STB_GLOBAL
- Name: funcsym
Type: STT_FUNC
Section: .data
Binding: STB_GLOBAL
## Test dumping ELF files with no .dynsym section.
# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: llvm-objdump --dynamic-syms %t2 | \
# RUN: FileCheck %s --match-full-lines --strict-whitespace --check-prefix=NODYNSYM
# RUN: llvm-objdump -T %t2 | \
# RUN: FileCheck %s --match-full-lines --strict-whitespace --check-prefix=NODYNSYM
# NODYNSYM:DYNAMIC SYMBOL TABLE:
# NODYNSYM-EMPTY:
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
## Test dumping ELF files with logically empty .dynsym section (only has a 0-index NULL symbol).
# RUN: yaml2obj --docnum=3 %s -o %t3
# RUN: llvm-objdump --dynamic-syms %t3 | \
# RUN: FileCheck %s --match-full-lines --strict-whitespace --check-prefix=ONLY-NULL
# RUN: llvm-objdump -T %t3 | \
# RUN: FileCheck %s --match-full-lines --strict-whitespace --check-prefix=ONLY-NULL
# ONLY-NULL:DYNAMIC SYMBOL TABLE:
# ONLY-NULL-EMPTY:
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
DynamicSymbols: []
## Test dumping ELF files with truly empty .dynsym section (size of .dynsym section is 0).
# RUN: yaml2obj --docnum=4 %s -o %t4
# RUN: llvm-objdump --dynamic-syms %t4 | \
# RUN: FileCheck %s --match-full-lines --strict-whitespace --check-prefix=EMPTY
# RUN: llvm-objdump -T %t4 | \
# RUN: FileCheck %s --match-full-lines --strict-whitespace --check-prefix=EMPTY
# EMPTY:DYNAMIC SYMBOL TABLE:
# EMPTY-EMPTY:
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .dynsym
Type: SHT_DYNSYM
Size: 0