File: export-symbols.test

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (340 lines) | stat: -rw-r--r-- 11,160 bytes parent folder | download | duplicates (5)
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
## Test the "--export-symbols" option.
## The option merges all the output of input files, sorts and prints out unique symbols from the input files.

# RUN: yaml2obj --docnum=1 -DFLAG=0x0002 %s -o %t1.o
# RUN: yaml2obj --docnum=2 -DFLAG=0x0002 %s -o %t2.o
# RUN: yaml2obj --docnum=2 -DFLAG=0x0002 -DSECT=26 %s -o %t2_invalid.o

## Test the following cases:
## Do not export global symbols beginning with "__sinit" , "__sterm" , "." , "(". or regular expression "^__[0-9]+__".
## Do not export hidden and internal symbols.
## Remove name prefixes of global symbols beginning with "__tf1" and "__tf9".
# RUN: llvm-nm --export-symbols %t1.o | FileCheck %s --check-prefixes=COMMON,WEAK,RSRC --implicit-check-not={{.}}

## Show that weak symbols are not exported when using the "--no-weak" option.
# RUN: llvm-nm --export-symbols --no-weak %t1.o | FileCheck --check-prefixes=COMMON,RSRC  %s --implicit-check-not={{.}}

## Show that only unique symbols (with a different name or visibility) are exported.
## RUN: llvm-nm --export-symbols %t1.o %t2.o | FileCheck --check-prefixes=COMMON,WEAK,OBJ2,RSRC %s --implicit-check-not={{.}}

## Show that __rsrc symbols are not exported when using the "--no-rsrc" option.
# RUN: llvm-nm --export-symbols --no-rsrc %t1.o  | FileCheck --check-prefixes=COMMON,WEAK %s --implicit-check-not={{.}}

# COMMON:      023__
# COMMON-NEXT: __023
# COMMON-NEXT: __02er02__
# COMMON-NEXT: ____
# RSRC-NEXT:   __rsrc
# COMMON-NEXT: __rsrc export
# COMMON-NEXT: __tf2value
# COMMON-NEXT: export_protected_var export
# COMMON-NEXT: export_protected_var protected
# OBJ2-NEXT:   export_var_in_sec_obj export
# COMMON-NEXT: protected_var protected
# OBJ2-NEXT:   protected_var_in_sec_obj protected
# COMMON-NEXT: tf1value
# COMMON-NEXT: tf9value
# OBJ2-NEXT:   var1_in_sec_obj
# WEAK-NEXT:   weak_func

## Test the behavior of the symbol reference section.
# RUN: llvm-nm --export-symbols --no-rsrc %t2_invalid.o 2>&1 | \
# RUN:   FileCheck -DFILE=%t2_invalid.o --check-prefixes=INVALID %s

# INVALID:      llvm-nm{{(\.exe)?}}: warning: [[FILE]]: for symbol with index 8: the section index (26) is invalid
# INVALID-NEXT: export_protected_var export
# INVALID-NEXT: export_protected_var protected
# INVALID-NEXT: protected_var_in_sec_obj protected
# INVALID-NEXT: var1_in_sec_obj

## Show that symbols in shared object files are not exported.
## Generate XCOFF shared object file.
# RUN: yaml2obj -DFLAG=0x2000 --docnum=2 %s -o %t_shared.o
# RUN: llvm-nm --export-symbols %t_shared.o | count 0

--- !XCOFF
FileHeader:
  MagicNumber:       0x1DF
  Flags:             [[FLAG]]
AuxiliaryHeader:
  Magic:                 0x10B
  Version:               0x2
Sections:
  - Name:            .text
    Flags:           [ STYP_TEXT ]
  - Name:            .data
    Flags:           [ STYP_DATA ]
  - Name:            .bss
    Flags:           [ STYP_DATA ]
  - Name:            .debug
    Flags:           [ STYP_DEBUG ]
Symbols:
  - Name:            export_protected_var
    Section:         .data
## Exported visibility.
    Type:            0x4000
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
  - Name:            export_protected_var
    Section:         .data
## Protected visibility.
    Type:            0x3000
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
  - Name:            __rsrc
    Section:         .data
## No visibility.
    Type:            0x0
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
       SectionOrLength:        0x4
  - Name:            __sinit
    Section:         .data
    Type:            0x0
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x9
       StorageMappingClass:    XMC_RW
       SectionOrLength:        0xC
  - Name:            __sterm
    Section:         .data
    Type:            0x0
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
       SectionOrLength:        0xC
  - Name:            .func
    Section:         .text
    Type:            0x20
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x02
       StorageMappingClass:    XMC_PR
  - Name:            (func)
    Section:         .data
    Type:            0x0
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
       SectionOrLength:        0xC
  - Name:            __023__
    Section:         .data
    Type:            0x0
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
       SectionOrLength:        0x4
  - Name:            __tf1_tf1value
    Section:         .text
    Type:            0x00
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RO
  - Name:            __tf9_12345678tf9value
    Section:         .data
    Type:            0x0
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
  - Name:            __tf2value
    Section:         .data
    Type:            0x0
    StorageClass:    C_HIDEXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x21
       StorageMappingClass:    XMC_TC
  - Name:            __tf2value
    Section:         .data
    Type:            0x0
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
  - Name:            weak_func
    Section:         .data
    Type:            0x0
    StorageClass:    C_WEAKEXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
  - Name:            protected_var
    Section:         .bss
    Type:            0x3000
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x02
       StorageMappingClass:    XMC_RW
  - Name:            hidden_var
    Section:         .data
## Hidden visibility.
    Type:            0x2000
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
  - Name:            internal_var
    Section:         .data
## Internal visibility.
    Type:            0x1000
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
## A symbol that is neither text, nor data, nor bss.
  - Name:            debug
    Section:         .debug
## Empty symbol name.
  - Name:            ""
    Section:         .data
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_TC
  - Name:            undef_var
    SectionIndex:    0
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x20
       StorageMappingClass:    XMC_UA
## Do not export not global symbol.
  - Name:            hidext_var
    Section:         .data
## Protected visibility.
    Type:            0x3000
    StorageClass:    C_HIDEXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
## Symbol should not be filtered out by option --no-rsrc.
  - Name:            __tf1___rsrc
    Section:         .data
    Type:            0x4000
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
       SectionOrLength:        0x4
## Following symbols should not be filtered out by regular expression "^__[0-9]+__".
  - Name:            __023
    Section:         .data
    Type:            0x0
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
       SectionOrLength:        0x4
  - Name:            023__
    Section:         .data
    Type:            0x0
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
       SectionOrLength:        0x4
  - Name:            ____
    Section:         .data
    Type:            0x0
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
       SectionOrLength:        0x4
  - Name:            __02er02__
    Section:         .data
    Type:            0x0
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
       SectionOrLength:        0x4

--- !XCOFF
FileHeader:
  MagicNumber:       0x1DF
  Flags:             [[FLAG]]
AuxiliaryHeader:
  Magic:                 0x10B
  Version:               0x2
  TextSectionSize:       0x280
  DataSectionSize:       0x90
Sections:
  - Name:            .text
    Flags:           [ STYP_TEXT ]
  - Name:            .data
    Flags:           [ STYP_DATA ]
Symbols:
  - Name:            export_protected_var
    Section:         .data
    Type:            0x4000
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
  - Name:            export_protected_var
    Section:         .data
    Type:            0x3000
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
  - Name:            var1_in_sec_obj
    Section:         .data
    Type:            0x0
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
       SectionOrLength:        0x4
  - Name:            protected_var_in_sec_obj
    Section:         .data
    Type:            0x3000
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW
  - Name:            export_var_in_sec_obj
    SectionIndex:    [[SECT=2]]
    Type:            0x4000
    StorageClass:    C_EXT
    AuxEntries:
     - Type:                   AUX_CSECT
       SymbolAlignmentAndType: 0x09
       StorageMappingClass:    XMC_RW