symtab-implicit-sections-size-content.yaml
5.23 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
## For implicit symbol table sections, `Size` and/or `Content` fields can also
## be specified in YAML. Here we test the behavior in different cases.
## When no `Size` or `Content` is specified for a symbol table section,
## yaml2obj writes the default content.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readelf %t1 -s | FileCheck %s --check-prefix=CASE1
# CASE1: Symbol table '.symtab' contains 2 entries:
# CASE1-NEXT: Num: Value Size Type Bind Vis Ndx Name
# CASE1-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
# CASE1-NEXT: 1: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND foo
# CASE1-EMPTY:
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .symtab
Type: SHT_SYMTAB
Symbols:
- Name: foo
## Specifying both `Size` and symbols at the same time is not allowed.
# RUN: not yaml2obj --docnum=2 %s -o %t2 2>&1 | FileCheck %s --check-prefix=CASE2
# RUN: not yaml2obj --docnum=3 %s -o %t2 2>&1 | FileCheck %s --check-prefix=CASE2
# CASE2: error: cannot specify both `Size` and `Symbols` for symbol table section '.symtab'
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .symtab
Type: SHT_SYMTAB
Size: 0x100
Symbols:
- Name: foo
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .symtab
Type: SHT_SYMTAB
Size: 0x100
Symbols: []
## Specifying both `Content` and symbols at the same time is not allowed.
# RUN: not yaml2obj --docnum=4 %s -o %t3 2>&1 | FileCheck %s --check-prefix=CASE3
# RUN: not yaml2obj --docnum=5 %s -o %t3 2>&1 | FileCheck %s --check-prefix=CASE3
# CASE3: error: cannot specify both `Content` and `Symbols` for symbol table section '.symtab'
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .symtab
Type: SHT_SYMTAB
Content: "00"
Symbols:
- Name: foo
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .symtab
Type: SHT_SYMTAB
Content: "00"
Symbols: []
## Check we can use just `Content` to emit custom data in the symbol table section.
# RUN: yaml2obj --docnum=6 %s -o %t4
# RUN: llvm-readobj --section-data -S %t4 | FileCheck %s --check-prefix=CASE4
# CASE4: Name: .symtab
# CASE4-NEXT: Type: SHT_SYMTAB
# CASE4-NEXT: Flags [ (0x0)
# CASE4-NEXT: ]
# CASE4-NEXT: Address: 0x0
# CASE4-NEXT: Offset: 0x40
# CASE4-NEXT: Size: 2
# CASE4-NEXT: Link: 2
# CASE4-NEXT: Info: 1
# CASE4-NEXT: AddressAlignment: 0
# CASE4-NEXT: EntrySize: 24
# CASE4-NEXT: SectionData (
# CASE4-NEXT: 0000: 0123
# CASE4-NEXT: )
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .symtab
Type: SHT_SYMTAB
Content: "0123"
## Check we can use just `Size` to emit custom data filled with zeroes
## in the symbol table section.
# RUN: yaml2obj --docnum=7 %s -o %t5
# RUN: llvm-readobj --section-data -S %t5 | FileCheck %s --check-prefix=CASE5
# CASE5: Name: .symtab (19)
# CASE5-NEXT: Type: SHT_SYMTAB (0x2)
# CASE5-NEXT: Flags [ (0x0)
# CASE5-NEXT: ]
# CASE5-NEXT: Address: 0x0
# CASE5-NEXT: Offset: 0x40
# CASE5-NEXT: Size: 5
# CASE5-NEXT: Link: 2
# CASE5-NEXT: Info: 1
# CASE5-NEXT: AddressAlignment: 0
# CASE5-NEXT: EntrySize: 24
# CASE5-NEXT: SectionData (
# CASE5-NEXT: 0000: 00000000 00
# CASE5-NEXT: )
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .symtab
Type: SHT_SYMTAB
Size: 5
## Check we can specify both `Size` and `Content` when size is greater
## than content size. In this case zeroes are added as padding
## after the specified content.
# RUN: yaml2obj --docnum=8 %s -o %t6
# RUN: llvm-readobj %t6 --section-data -S | FileCheck %s --check-prefix=CASE6
# CASE6: Name: .symtab
# CASE6-NEXT: Type: SHT_SYMTAB
# CASE6-NEXT: Flags [
# CASE6-NEXT: ]
# CASE6-NEXT: Address: 0x0
# CASE6-NEXT: Offset: 0x40
# CASE6-NEXT: Size: 4
# CASE6-NEXT: Link: 2
# CASE6-NEXT: Info: 1
# CASE6-NEXT: AddressAlignment: 0
# CASE6-NEXT: EntrySize: 24
# CASE6-NEXT: SectionData (
# CASE6-NEXT: 0000: 01230000
# CASE6-NEXT: )
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .symtab
Type: SHT_SYMTAB
Content: "0123"
Size: 4
## Check we can specify both `Size` and `Content` when size is
## equal to content size.
# RUN: yaml2obj --docnum=9 %s -o %t7
# RUN: llvm-readobj --section-data -S %t7 | FileCheck %s --check-prefix=CASE7
# CASE7: Name: .symtab
# CASE7-NEXT: Type: SHT_SYMTAB
# CASE7-NEXT: Flags [
# CASE7-NEXT: ]
# CASE7-NEXT: Address: 0x0
# CASE7-NEXT: Offset: 0x40
# CASE7-NEXT: Size: 2
# CASE7-NEXT: Link: 2
# CASE7-NEXT: Info: 1
# CASE7-NEXT: AddressAlignment: 0
# CASE7-NEXT: EntrySize: 24
# CASE7-NEXT: SectionData (
# CASE7-NEXT: 0000: 0123
# CASE7-NEXT: )
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .symtab
Type: SHT_SYMTAB
Content: "0123"
Size: 2