File: string-table.yaml

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (292 lines) | stat: -rw-r--r-- 11,161 bytes parent folder | download | duplicates (18)
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
## Check that yaml2obj is able to customize the string table.
## `ContentSize`, `Length`, `Strings` and/or `RawContent` can be specified in
##  YAML. Here we test the behaviour in various cases.

## Case 1: yaml2obj writes the default content (i.e. long symbol names in
##         XCOFF32 or any symbol names in XCOFF64) when no StringTable field
##         is specified.
# RUN: yaml2obj --docnum=1 %s -DSYMNAME='nameInStrTbl' -o %t1
# RUN: llvm-readobj %t1 --string-table | FileCheck %s --check-prefix=CASE1

# CASE1:      StringTable {
# CASE1-NEXT:   Length: 17
# CASE1-NEXT:   [     4]   nameInStrTbl
# CASE1-NEXT: }

--- !XCOFF
FileHeader:
  MagicNumber: 0x1DF
Symbols:
  - Name: [[SYMNAME=<none>]]
  - Name: [[SYMNAME2=<none>]]
StringTable:
  ContentSize: [[CONTENTSIZE=<none>]]
  Length: [[LENGTHVALUE=<none>]]
  RawContent: [[RAWCONTENT=<none>]]

## We can specify `ContentSize` only when the value is equal to or greater
## than the content size. For greater cases, zeros are added as padding.
## Cases 2-6 are trying to check this.

## Case 2: produce a string table with a specified `ContentSize`. In this case,
##         there is no default content and the content is filled with zeroes.
# RUN: yaml2obj --docnum=1 %s -DCONTENTSIZE=20 -o %t2
# RUN: llvm-readobj %t2 -s --string-table | FileCheck %s --check-prefix=CASE2

# CASE2:      StringTable {
# CASE2-NEXT:   Length: 20
# CASE2-NEXT: }

## Case 3: if the value of `ContentSize` is greater than the content size,
##         yaml2obj adds zeros as padding after the default content.
# RUN: yaml2obj --docnum=1 %s -DSYMNAME='nameInStrTbl' -DCONTENTSIZE=20 -o %t3
# RUN: llvm-readobj %t3 --string-table | FileCheck %s --check-prefix=CASE3

# CASE3:      StringTable {
# CASE3-NEXT:   Length: 20
# CASE3-NEXT:   [     4]   nameInStrTbl
# CASE3-NEXT: }

## Case 4: the value of `ContentSize` matches the actual content size.
# RUN: yaml2obj --docnum=1 %s -DSYMNAME='nameInStrTbl' -DCONTENTSIZE=17 -o %t4
# RUN: llvm-readobj %t4 --string-table | FileCheck %s --check-prefix=CASE4

# CASE4:      StringTable {
# CASE4-NEXT:   Length: 17
# CASE4-NEXT:   [     4]   nameInStrTbl
# CASE4-NEXT: }

## Case 5: an error is reported when the value of "ContentSize" is less than
##         the content size.
# RUN: not yaml2obj --docnum=1 %s -DSYMNAME='nameInStrTbl' -DCONTENTSIZE=16 \
# RUN:   -o %t5 2>&1 | FileCheck %s --check-prefix=CASE5

# CASE5: error: specified ContentSize (16) is less than the size of the data that would otherwise be written (17)

## Case 6: an error is reported when `ContentSize` is less than 4 without
##         `RawContent`.
# RUN: not yaml2obj --docnum=1 %s -DCONTENTSIZE=3 -o %t6 2>&1 \
# RUN:   | FileCheck %s --check-prefix=CASE6

# CASE6: error: ContentSize shouldn't be less than 4 without RawContent

## We can specify `Strings` for a string table. Default contents (ie. symbol
## names in string table) will be overwritten by specified values. Cases 7-9
## are trying to check this function.

## Case 7: produce a string table with specified `Strings` directly. In this
##         case, there is no default content.
# RUN: yaml2obj --docnum=2 %s -o %t7
# RUN: llvm-readobj %t7 --string-table | FileCheck %s --check-prefix=CASE7

# CASE7:      StringTable {
# CASE7-NEXT:   Length: 8
# CASE7-NEXT:   [     4]   b
# CASE7-NEXT:   [     6]   a
# CASE7-NEXT: }

--- !XCOFF
FileHeader:
  MagicNumber: 0x1DF
Symbols:
  - Name: [[SYMNAME=<none>]]
  - Name: [[SYMNAME2=<none>]]
  - Name: [[SYMNAME3=<none>]]
StringTable:
  ContentSize: [[CONTENTSIZE=<none>]]
  Length: [[LENGTHVALUE=<none>]]
  RawContent: [[RAWCONTENT=<none>]]
  Strings:
    - a
    - b

## Case 8: if the number of `Strings` is greater than or equal to the number
##         of default strings, all default strings will be overwritten by
##         specified ones.
# RUN: yaml2obj --docnum=2 %s -DSYMNAME='nameInStrTbl' -o %t8
# RUN: llvm-readobj %t8 -s --string-table | FileCheck %s --check-prefix=CASE8

# CASE8:      Symbols [
# CASE8-NEXT:   Symbol {
# CASE8-NEXT:     Index: 0
# CASE8-NEXT:     Name: a
# CASE8-NEXT:     Value: 0x0
# CASE8-NEXT:     Section: N_UNDEF
# CASE8-NEXT:     Type: 0x0
# CASE8-NEXT:     StorageClass: C_NULL (0x0)
# CASE8-NEXT:     NumberOfAuxEntries: 0
# CASE8-NEXT:   }
# CASE8-NEXT:   Symbol {
# CASE8-NEXT:     Index: 1
# CASE8-NEXT:     Name: <none>
# CASE8-NEXT:     Value: 0x0
# CASE8-NEXT:     Section: N_UNDEF
# CASE8-NEXT:     Type: 0x0
# CASE8-NEXT:     StorageClass: C_NULL (0x0)
# CASE8-NEXT:     NumberOfAuxEntries: 0
# CASE8-NEXT:   }
# CASE8-NEXT:   Symbol {
# CASE8-NEXT:     Index: 2
# CASE8-NEXT:     Name: <none>
# CASE8-NEXT:     Value: 0x0
# CASE8-NEXT:     Section: N_UNDEF
# CASE8-NEXT:     Type: 0x0
# CASE8-NEXT:     StorageClass: C_NULL (0x0)
# CASE8-NEXT:     NumberOfAuxEntries: 0
# CASE8-NEXT:   }
# CASE8-NEXT: ]
# CASE8-NEXT: StringTable {
# CASE8-NEXT:   Length: 8
# CASE8-NEXT:   [     4]   b
# CASE8-NEXT:   [     6]   a
# CASE8-NEXT: }

## Case 9: if the number of `Strings` is less than the number of default
##         strings, default strings will be partially overwritten. The
##         remaining strings will still be stored after the specified strings
##         in the string table.
# RUN: yaml2obj --docnum=2 %s -DSYMNAME='nameInStrTbl' \
# RUN:   -DSYMNAME2='name2InStrTbl' -DSYMNAME3='name3InStrTbl' -o %t9
# RUN: llvm-readobj %t9 -s --string-table | FileCheck %s --check-prefix=CASE9

# CASE9:      Symbols [
# CASE9-NEXT:   Symbol {
# CASE9-NEXT:     Index: 0
# CASE9-NEXT:     Name: a
# CASE9-NEXT:     Value: 0x0
# CASE9-NEXT:     Section: N_UNDEF
# CASE9-NEXT:     Type: 0x0
# CASE9-NEXT:     StorageClass: C_NULL (0x0)
# CASE9-NEXT:     NumberOfAuxEntries: 0
# CASE9-NEXT:   }
# CASE9-NEXT:   Symbol {
# CASE9-NEXT:     Index: 1
# CASE9-NEXT:     Name: b
# CASE9-NEXT:     Value: 0x0
# CASE9-NEXT:     Section: N_UNDEF
# CASE9-NEXT:     Type: 0x0
# CASE9-NEXT:     StorageClass: C_NULL (0x0)
# CASE9-NEXT:     NumberOfAuxEntries: 0
# CASE9-NEXT:   }
# CASE9-NEXT:   Symbol {
# CASE9-NEXT:     Index: 2
# CASE9-NEXT:     Name: name3InStrTbl
# CASE9-NEXT:     Value: 0x0
# CASE9-NEXT:     Section: N_UNDEF
# CASE9-NEXT:     Type: 0x0
# CASE9-NEXT:     StorageClass: C_NULL (0x0)
# CASE9-NEXT:     NumberOfAuxEntries: 0
# CASE9-NEXT:   }
# CASE9-NEXT: ]
# CASE9-NEXT: StringTable {
# CASE9-NEXT:   Length: 22
# CASE9-NEXT:   [     4]   name3InStrTbl
# CASE9-NEXT:   [    12]   b
# CASE9-NEXT:   [    14]   a
# CASE9-NEXT: }

## We can specify both `ContentSize` and `Strings` when `ContentSize` is equal
## to or greater than the content size. Cases 10-12 are trying to check this.

## Case 10: produce a string table with specified `ContentSize` and `Strings`
##          when the value is greater than the size of specified strings.
##          In this case, there is no default content.
# RUN: yaml2obj --docnum=2 %s -DCONTENTSIZE=20 -o %t10
# RUN: llvm-readobj %t10 --string-table | FileCheck %s --check-prefix=CASE10

# CASE10:      StringTable {
# CASE10-NEXT:   Length: 20
# CASE10-NEXT:   [     4]   b
# CASE10-NEXT:   [     6]   a
# CASE10-NEXT: }

## Case 11: for a string table with default contents, we can specify
##          `ContentSize` and `Strings` when the `ContentSize` is greater
##          than the data that would otherwise be written.
# RUN: yaml2obj --docnum=2 %s -DCONTENTSIZE=30 -DSYMNAME='nameInStrTbl' \
# RUN:   -DSYMNAME2='name2InStrTbl' -DSYMNAME3='name3InStrTbl' -o %t11
# RUN: llvm-readobj %t11 --string-table | FileCheck %s --check-prefix=CASE11

# CASE11:      StringTable {
# CASE11-NEXT:   Length: 30
# CASE11-NEXT:   [     4]   name3InStrTbl
# CASE11-NEXT:   [    12]   b
# CASE11-NEXT:   [    14]   a
# CASE11-NEXT: }

## Case 12: an error is reported when the value of `ContentSize` is less
##          than the final content size. None of `ContentSize`, `Strings` or
##          default contents is empty in this case.
# RUN: not yaml2obj --docnum=2 %s  -DCONTENTSIZE=10 -DSYMNAME='nameInStrTbl' \
# RUN:   -DSYMNAME2='name2InStrTbl' -DSYMNAME3='name3InStrTbl' -o %t12 2>&1 \
# RUN:   | FileCheck %s --check-prefix=CASE12

# CASE12: error: specified ContentSize (10) is less than the size of the data that would otherwise be written (22)

## We can use `RawContent` to generate a string table. Cases 13-16 are trying to
## check the `RawContent`.

## Case 13: if `RawContent` is specified and no `ContentSize` is specified.
##          Write the `RawContent` data.
# RUN: yaml2obj --docnum=1 %s -DRAWCONTENT="000000090062006300" -o %t13
# RUN: llvm-readobj %t13 --string-table | FileCheck %s --check-prefix=CASE13

# CASE13:      StringTable {
# CASE13-NEXT:   Length: 9
# CASE13-NEXT:   [     5]   b
# CASE13-NEXT:   [     7]   c
# CASE13-NEXT: }

## Case 14: if `RawContent` is specified and `ContentSize` matches the size
##          of the `RawContent` data. Write the `RawContent` data.
# RUN: yaml2obj --docnum=1 %s -DRAWCONTENT="000000090062006300" -DCONTENTSIZE=9 -o %t14
# RUN: llvm-readobj %t14 --string-table | FileCheck %s --check-prefix=CASE14

# CASE14:      StringTable {
# CASE14-NEXT:   Length: 9
# CASE14-NEXT:   [     5]   b
# CASE14-NEXT:   [     7]   c
# CASE14-NEXT: }

## Case 15: an error is reported when `ContentSize` is less than the `RawContent`
##          data size.
# RUN: not yaml2obj --docnum=1 %s -DRAWCONTENT="000000090062006300" -DCONTENTSIZE=6 \
# RUN:   -o %t15 2>&1 | FileCheck %s --check-prefix=CASE15

# CASE15: error: specified ContentSize (6) is less than the RawContent data size (9)

## Case 16: if `RawContent` is specified and `ContentSize` is greater than the
##          `RawContent` data size, pad the RawContent with trailing zeroes.
# RUN: yaml2obj --docnum=1 %s -DRAWCONTENT="000000090062006300" -DCONTENTSIZE=11 -o %t16
# RUN: llvm-readobj %t16 --string-table | FileCheck %s --check-prefix=CASE16

# CASE16:      StringTable {
# CASE16-NEXT:   Length: 9
# CASE16-NEXT:   [     5]   b
# CASE16-NEXT:   [     7]   c
# CASE16-NEXT: }

## We can specify `Length`. Use the value of the `Length` field for the first
## 4 bytes of the table. The value may not make sense for the data that is
## being written. Cases 17-20 are trying to check this.

## Case 17: report an error if the `Length` is specified as well as `RawContent`.
# RUN: not yaml2obj --docnum=1 %s -DRAWCONTENT="0062006300" -DLENGTHVALUE=9 \
# RUN:    -o %t17 2>&1 | FileCheck %s --check-prefix=CASE17

# CASE17: error: can't specify Strings or Length when RawContent is specified

## Case 18: report an error if both `RawContent` and `Strings` are specified.
# RUN: not yaml2obj --docnum=2 %s -DRAWCONTENT="0062006300" -o %t18 2>&1 \
# RUN:   | FileCheck %s --check-prefix=CASE18

# CASE18: error: can't specify Strings or Length when RawContent is specified

## Case 19: use the value of the `Length` field for the first 4 bytes of the
##          table. We dump the string table from the offset of 0x38.
# RUN: yaml2obj --docnum=1 %s -DSYMNAME='nameInStrTbl' -DLENGTHVALUE=20 -o %t19
# RUN: od -A n -t x1 -v -j 0x38 %t19 \
# RUN:   | FileCheck %s --ignore-case --check-prefix=CASE19

# CASE19:      00 00 00 14 6e 61 6d 65 49 6e 53 74 72 54 62 6c
# CASE19-NEXT: 00