345 lines · plain
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.3 4# RUN: yaml2obj --docnum=1 -DFLAG=0x0002 %s -o %t1.o5# RUN: yaml2obj --docnum=2 -DFLAG=0x0002 %s -o %t2.o6# RUN: yaml2obj --docnum=2 -DFLAG=0x0002 -DSECT=26 %s -o %t2_invalid.o7 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={{.}}13 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={{.}}16 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={{.}}19 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={{.}}22 23# COMMON: 023__24# COMMON-NEXT: __02325# COMMON-NEXT: __02er02__26# COMMON-NEXT: ____27# RSRC-NEXT: __rsrc28# COMMON-NEXT: __rsrc export29# COMMON-NEXT: __tf2value30# COMMON-NEXT: export_protected_var export31# COMMON-NEXT: export_protected_var protected32# OBJ2-NEXT: export_var_in_sec_obj export33# COMMON-NEXT: protected_var protected34# OBJ2-NEXT: protected_var_in_sec_obj protected35# COMMON-NEXT: tf1value36# COMMON-NEXT: tf9value37# OBJ2-NEXT: var1_in_sec_obj38# WEAK-NEXT: weak_func39 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 %s43 44# INVALID: llvm-nm{{(\.exe)?}}: warning: [[FILE]]: for symbol with index 8: the section index (26) is invalid45# INVALID-NEXT: export_protected_var export46# INVALID-NEXT: export_protected_var protected47# INVALID-NEXT: protected_var_in_sec_obj protected48# INVALID-NEXT: var1_in_sec_obj49 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.o53# RUN: llvm-nm --export-symbols %t_shared.o | count 054 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.txt57# RUN: llvm-nm --export-symbols %t_imp.txt 2>&1 | count 058 59--- !XCOFF60FileHeader:61 MagicNumber: 0x1DF62 Flags: [[FLAG]]63AuxiliaryHeader:64 Magic: 0x10B65 Version: 0x266Sections:67 - Name: .text68 Flags: [ STYP_TEXT ]69 - Name: .data70 Flags: [ STYP_DATA ]71 - Name: .bss72 Flags: [ STYP_DATA ]73 - Name: .debug74 Flags: [ STYP_DEBUG ]75Symbols:76 - Name: export_protected_var77 Section: .data78## Exported visibility.79 Type: 0x400080 StorageClass: C_EXT81 AuxEntries:82 - Type: AUX_CSECT83 SymbolAlignmentAndType: 0x0984 StorageMappingClass: XMC_RW85 - Name: export_protected_var86 Section: .data87## Protected visibility.88 Type: 0x300089 StorageClass: C_EXT90 AuxEntries:91 - Type: AUX_CSECT92 SymbolAlignmentAndType: 0x0993 StorageMappingClass: XMC_RW94 - Name: __rsrc95 Section: .data96## No visibility.97 Type: 0x098 StorageClass: C_EXT99 AuxEntries:100 - Type: AUX_CSECT101 SymbolAlignmentAndType: 0x09102 StorageMappingClass: XMC_RW103 SectionOrLength: 0x4104 - Name: __sinit105 Section: .data106 Type: 0x0107 StorageClass: C_EXT108 AuxEntries:109 - Type: AUX_CSECT110 SymbolAlignmentAndType: 0x9111 StorageMappingClass: XMC_RW112 SectionOrLength: 0xC113 - Name: __sterm114 Section: .data115 Type: 0x0116 StorageClass: C_EXT117 AuxEntries:118 - Type: AUX_CSECT119 SymbolAlignmentAndType: 0x09120 StorageMappingClass: XMC_RW121 SectionOrLength: 0xC122 - Name: .func123 Section: .text124 Type: 0x20125 StorageClass: C_EXT126 AuxEntries:127 - Type: AUX_CSECT128 SymbolAlignmentAndType: 0x02129 StorageMappingClass: XMC_PR130 - Name: (func)131 Section: .data132 Type: 0x0133 StorageClass: C_EXT134 AuxEntries:135 - Type: AUX_CSECT136 SymbolAlignmentAndType: 0x09137 StorageMappingClass: XMC_RW138 SectionOrLength: 0xC139 - Name: __023__140 Section: .data141 Type: 0x0142 StorageClass: C_EXT143 AuxEntries:144 - Type: AUX_CSECT145 SymbolAlignmentAndType: 0x09146 StorageMappingClass: XMC_RW147 SectionOrLength: 0x4148 - Name: __tf1_tf1value149 Section: .text150 Type: 0x00151 StorageClass: C_EXT152 AuxEntries:153 - Type: AUX_CSECT154 SymbolAlignmentAndType: 0x09155 StorageMappingClass: XMC_RO156 - Name: __tf9_12345678tf9value157 Section: .data158 Type: 0x0159 StorageClass: C_EXT160 AuxEntries:161 - Type: AUX_CSECT162 SymbolAlignmentAndType: 0x09163 StorageMappingClass: XMC_RW164 - Name: __tf2value165 Section: .data166 Type: 0x0167 StorageClass: C_HIDEXT168 AuxEntries:169 - Type: AUX_CSECT170 SymbolAlignmentAndType: 0x21171 StorageMappingClass: XMC_TC172 - Name: __tf2value173 Section: .data174 Type: 0x0175 StorageClass: C_EXT176 AuxEntries:177 - Type: AUX_CSECT178 SymbolAlignmentAndType: 0x09179 StorageMappingClass: XMC_RW180 - Name: weak_func181 Section: .data182 Type: 0x0183 StorageClass: C_WEAKEXT184 AuxEntries:185 - Type: AUX_CSECT186 SymbolAlignmentAndType: 0x09187 StorageMappingClass: XMC_RW188 - Name: protected_var189 Section: .bss190 Type: 0x3000191 StorageClass: C_EXT192 AuxEntries:193 - Type: AUX_CSECT194 SymbolAlignmentAndType: 0x02195 StorageMappingClass: XMC_RW196 - Name: hidden_var197 Section: .data198## Hidden visibility.199 Type: 0x2000200 StorageClass: C_EXT201 AuxEntries:202 - Type: AUX_CSECT203 SymbolAlignmentAndType: 0x09204 StorageMappingClass: XMC_RW205 - Name: internal_var206 Section: .data207## Internal visibility.208 Type: 0x1000209 StorageClass: C_EXT210 AuxEntries:211 - Type: AUX_CSECT212 SymbolAlignmentAndType: 0x09213 StorageMappingClass: XMC_RW214## A symbol that is neither text, nor data, nor bss.215 - Name: debug216 Section: .debug217## Empty symbol name.218 - Name: ""219 Section: .data220 StorageClass: C_EXT221 AuxEntries:222 - Type: AUX_CSECT223 SymbolAlignmentAndType: 0x09224 StorageMappingClass: XMC_TC225 - Name: undef_var226 SectionIndex: 0227 AuxEntries:228 - Type: AUX_CSECT229 SymbolAlignmentAndType: 0x20230 StorageMappingClass: XMC_UA231## Do not export not global symbol.232 - Name: hidext_var233 Section: .data234## Protected visibility.235 Type: 0x3000236 StorageClass: C_HIDEXT237 AuxEntries:238 - Type: AUX_CSECT239 SymbolAlignmentAndType: 0x09240 StorageMappingClass: XMC_RW241## Symbol should not be filtered out by option --no-rsrc.242 - Name: __tf1___rsrc243 Section: .data244 Type: 0x4000245 StorageClass: C_EXT246 AuxEntries:247 - Type: AUX_CSECT248 SymbolAlignmentAndType: 0x09249 StorageMappingClass: XMC_RW250 SectionOrLength: 0x4251## Following symbols should not be filtered out by regular expression "^__[0-9]+__".252 - Name: __023253 Section: .data254 Type: 0x0255 StorageClass: C_EXT256 AuxEntries:257 - Type: AUX_CSECT258 SymbolAlignmentAndType: 0x09259 StorageMappingClass: XMC_RW260 SectionOrLength: 0x4261 - Name: 023__262 Section: .data263 Type: 0x0264 StorageClass: C_EXT265 AuxEntries:266 - Type: AUX_CSECT267 SymbolAlignmentAndType: 0x09268 StorageMappingClass: XMC_RW269 SectionOrLength: 0x4270 - Name: ____271 Section: .data272 Type: 0x0273 StorageClass: C_EXT274 AuxEntries:275 - Type: AUX_CSECT276 SymbolAlignmentAndType: 0x09277 StorageMappingClass: XMC_RW278 SectionOrLength: 0x4279 - Name: __02er02__280 Section: .data281 Type: 0x0282 StorageClass: C_EXT283 AuxEntries:284 - Type: AUX_CSECT285 SymbolAlignmentAndType: 0x09286 StorageMappingClass: XMC_RW287 SectionOrLength: 0x4288 289--- !XCOFF290FileHeader:291 MagicNumber: 0x1DF292 Flags: [[FLAG]]293AuxiliaryHeader:294 Magic: 0x10B295 Version: 0x2296 TextSectionSize: 0x280297 DataSectionSize: 0x90298Sections:299 - Name: .text300 Flags: [ STYP_TEXT ]301 - Name: .data302 Flags: [ STYP_DATA ]303Symbols:304 - Name: export_protected_var305 Section: .data306 Type: 0x4000307 StorageClass: C_EXT308 AuxEntries:309 - Type: AUX_CSECT310 SymbolAlignmentAndType: 0x09311 StorageMappingClass: XMC_RW312 - Name: export_protected_var313 Section: .data314 Type: 0x3000315 StorageClass: C_EXT316 AuxEntries:317 - Type: AUX_CSECT318 SymbolAlignmentAndType: 0x09319 StorageMappingClass: XMC_RW320 - Name: var1_in_sec_obj321 Section: .data322 Type: 0x0323 StorageClass: C_EXT324 AuxEntries:325 - Type: AUX_CSECT326 SymbolAlignmentAndType: 0x09327 StorageMappingClass: XMC_RW328 SectionOrLength: 0x4329 - Name: protected_var_in_sec_obj330 Section: .data331 Type: 0x3000332 StorageClass: C_EXT333 AuxEntries:334 - Type: AUX_CSECT335 SymbolAlignmentAndType: 0x09336 StorageMappingClass: XMC_RW337 - Name: export_var_in_sec_obj338 SectionIndex: [[SECT=2]]339 Type: 0x4000340 StorageClass: C_EXT341 AuxEntries:342 - Type: AUX_CSECT343 SymbolAlignmentAndType: 0x09344 StorageMappingClass: XMC_RW345