1 ## Test the "--export-symbols" option.
2 ## The option merges all the output of input files, sorts and prints out unique symbols from the input files.
4 # RUN: yaml2obj --docnum=1 -DFLAG=0x0002 %s -o %t1.o
5 # RUN: yaml2obj --docnum=2 -DFLAG=0x0002 %s -o %t2.o
6 # RUN: yaml2obj --docnum=2 -DFLAG=0x0002 -DSECT=26 %s -o %t2_invalid.o
8 ## Test the following cases:
9 ## Do not export global symbols beginning with "__sinit" , "__sterm" , "." , "(". or regular expression "^__[0-9]+__".
10 ## Do not export hidden and internal symbols.
11 ## Remove name prefixes of global symbols beginning with "__tf1" and "__tf9".
12 # RUN: llvm-nm --export-symbols %t1.o | FileCheck %s --check-prefixes=COMMON,WEAK,RSRC --implicit-check-not={{.}}
14 ## Show that weak symbols are not exported when using the "--no-weak" option.
15 # RUN: llvm-nm --export-symbols --no-weak %t1.o | FileCheck --check-prefixes=COMMON,RSRC %s --implicit-check-not={{.}}
17 ## Show that only unique symbols (with a different name or visibility) are exported.
18 ## RUN: llvm-nm --export-symbols %t1.o %t2.o | FileCheck --check-prefixes=COMMON,WEAK,OBJ2,RSRC %s --implicit-check-not={{.}}
20 ## Show that __rsrc symbols are not exported when using the "--no-rsrc" option.
21 # RUN: llvm-nm --export-symbols --no-rsrc %t1.o | FileCheck --check-prefixes=COMMON,WEAK %s --implicit-check-not={{.}}
25 # COMMON-NEXT: __02er02__
28 # COMMON-NEXT: __rsrc export
29 # COMMON-NEXT: __tf2value
30 # COMMON-NEXT: export_protected_var export
31 # COMMON-NEXT: export_protected_var protected
32 # OBJ2-NEXT: export_var_in_sec_obj export
33 # COMMON-NEXT: protected_var protected
34 # OBJ2-NEXT: protected_var_in_sec_obj protected
35 # COMMON-NEXT: tf1value
36 # COMMON-NEXT: tf9value
37 # OBJ2-NEXT: var1_in_sec_obj
38 # WEAK-NEXT: weak_func
40 ## Test the behavior of the symbol reference section.
41 # RUN: llvm-nm --export-symbols --no-rsrc %t2_invalid.o 2>&1 | \
42 # RUN: FileCheck -DFILE=%t2_invalid.o --check-prefixes=INVALID %s
44 # INVALID: llvm-nm{{(\.exe)?}}: warning: [[FILE]]: for symbol with index 8: the section index (26) is invalid
45 # INVALID-NEXT: export_protected_var export
46 # INVALID-NEXT: export_protected_var protected
47 # INVALID-NEXT: protected_var_in_sec_obj protected
48 # INVALID-NEXT: var1_in_sec_obj
50 ## Show that symbols in shared object files are not exported.
51 ## Generate XCOFF shared object file.
52 # RUN: yaml2obj -DFLAG=0x2000 --docnum=2 %s -o %t_shared.o
53 # RUN: llvm-nm --export-symbols %t_shared.o | count 0
55 ## Test that llvm-nm ignores AIX linker import files when using --export-symbols. These start with "#!".
56 # RUN: echo -e "#!\n bar\n foo " > %t_imp.txt
57 # RUN: llvm-nm --export-symbols %t_imp.txt 2>&1 | count 0
76 - Name: export_protected_var
78 ## Exported visibility.
83 SymbolAlignmentAndType: 0x09
84 StorageMappingClass: XMC_RW
85 - Name: export_protected_var
87 ## Protected visibility.
92 SymbolAlignmentAndType: 0x09
93 StorageMappingClass: XMC_RW
101 SymbolAlignmentAndType: 0x09
102 StorageMappingClass: XMC_RW
110 SymbolAlignmentAndType: 0x9
111 StorageMappingClass: XMC_RW
119 SymbolAlignmentAndType: 0x09
120 StorageMappingClass: XMC_RW
128 SymbolAlignmentAndType: 0x02
129 StorageMappingClass: XMC_PR
136 SymbolAlignmentAndType: 0x09
137 StorageMappingClass: XMC_RW
145 SymbolAlignmentAndType: 0x09
146 StorageMappingClass: XMC_RW
148 - Name: __tf1_tf1value
154 SymbolAlignmentAndType: 0x09
155 StorageMappingClass: XMC_RO
156 - Name: __tf9_12345678tf9value
162 SymbolAlignmentAndType: 0x09
163 StorageMappingClass: XMC_RW
167 StorageClass: C_HIDEXT
170 SymbolAlignmentAndType: 0x21
171 StorageMappingClass: XMC_TC
178 SymbolAlignmentAndType: 0x09
179 StorageMappingClass: XMC_RW
183 StorageClass: C_WEAKEXT
186 SymbolAlignmentAndType: 0x09
187 StorageMappingClass: XMC_RW
188 - Name: protected_var
194 SymbolAlignmentAndType: 0x02
195 StorageMappingClass: XMC_RW
198 ## Hidden visibility.
203 SymbolAlignmentAndType: 0x09
204 StorageMappingClass: XMC_RW
207 ## Internal visibility.
212 SymbolAlignmentAndType: 0x09
213 StorageMappingClass: XMC_RW
214 ## A symbol that is neither text, nor data, nor bss.
217 ## Empty symbol name.
223 SymbolAlignmentAndType: 0x09
224 StorageMappingClass: XMC_TC
229 SymbolAlignmentAndType: 0x20
230 StorageMappingClass: XMC_UA
231 ## Do not export not global symbol.
234 ## Protected visibility.
236 StorageClass: C_HIDEXT
239 SymbolAlignmentAndType: 0x09
240 StorageMappingClass: XMC_RW
241 ## Symbol should not be filtered out by option --no-rsrc.
248 SymbolAlignmentAndType: 0x09
249 StorageMappingClass: XMC_RW
251 ## Following symbols should not be filtered out by regular expression "^__[0-9]+__".
258 SymbolAlignmentAndType: 0x09
259 StorageMappingClass: XMC_RW
267 SymbolAlignmentAndType: 0x09
268 StorageMappingClass: XMC_RW
276 SymbolAlignmentAndType: 0x09
277 StorageMappingClass: XMC_RW
285 SymbolAlignmentAndType: 0x09
286 StorageMappingClass: XMC_RW
296 TextSectionSize: 0x280
297 DataSectionSize: 0x90
304 - Name: export_protected_var
310 SymbolAlignmentAndType: 0x09
311 StorageMappingClass: XMC_RW
312 - Name: export_protected_var
318 SymbolAlignmentAndType: 0x09
319 StorageMappingClass: XMC_RW
320 - Name: var1_in_sec_obj
326 SymbolAlignmentAndType: 0x09
327 StorageMappingClass: XMC_RW
329 - Name: protected_var_in_sec_obj
335 SymbolAlignmentAndType: 0x09
336 StorageMappingClass: XMC_RW
337 - Name: export_var_in_sec_obj
338 SectionIndex: [[SECT=2]]
343 SymbolAlignmentAndType: 0x09
344 StorageMappingClass: XMC_RW