366 lines · plain
1# RUN: yaml2obj %p/Inputs/COFF/i386.yaml | llvm-nm -a -S - \2# RUN: | FileCheck %s -check-prefix COFF323 4# COFF32: 00000000 d .data5# COFF32-NEXT: 00000000 t .text6# COFF32-NEXT: 00000000 d L_.str7# COFF32-NEXT: U _SomeOtherFunction8# COFF32-NEXT: 00000000 T _main9# COFF32-NEXT: U _puts10 11# RUN: yaml2obj %p/Inputs/COFF/x86-64.yaml | llvm-nm -a -S - \12# RUN: | FileCheck %s -check-prefix COFF6413 14# COFF64: 00000000 d .data15# COFF64-NEXT: 00000000 t .text16# COFF64-NEXT: 00000000 r ??__Ex@@YAXXZ17# COFF64-NEXT: 00000000 d L.str18# COFF64-NEXT: U SomeOtherFunction19# COFF64-NEXT: 00000000 T main20# COFF64-NEXT: U puts21 22# RUN: llvm-nm %p/Inputs/trivial-object-test.wasm \23# RUN: | FileCheck %s -check-prefix WASM24 25# WASM: 00000000 d .L.str26# WASM-NEXT: 00000019 t .LSomeOtherFunction_bitcast27# WASM-NEXT: U SomeOtherFunction28# WASM-NEXT: 00000001 T main29# WASM-NEXT: U puts30# WASM-NEXT: 00000010 D var31 32# RUN: yaml2obj --docnum=1 %s -o %t.elf-i38633 34--- !ELF35FileHeader:36 Class: ELFCLASS3237 Data: ELFDATA2LSB38 Type: ET_REL39 Machine: EM_38640Sections:41 - Name: .text42 Type: SHT_PROGBITS43 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]44Symbols:45 - Name: main46 Type: STT_FUNC47 Section: .text48 Binding: STB_GLOBAL49 Size: 0x000000000000002450 - Name: SomeOtherFunction51 Binding: STB_GLOBAL52 - Name: puts53 Binding: STB_GLOBAL54 55# RUN: llvm-nm %t.elf-i386 | FileCheck %s -check-prefix=ELF56 57# ELF-NOT: U58# ELF: U SomeOtherFunction59# ELF: 00000000 T main60# ELF: U puts61 62# RUN: llvm-nm -o %t.elf-i386 | FileCheck %s -DFILE=%t.elf-i386 -check-prefix=ELF-o63 64# RUN: llvm-nm %t.elf-i386 -S | FileCheck %s -check-prefix ELF-SIZE65 66# ELF-SIZE: U SomeOtherFunction67# ELF-SIZE-NEXT: 00000000 00000024 T main68# ELF-SIZE-NEXT: U puts69 70# ELF-o-NOT: U71# ELF-o: [[FILE]]: U SomeOtherFunction72# ELF-o: [[FILE]]: 00000000 T main73# ELF-o: [[FILE]]: U puts74 75# RUN: llvm-nm -u %t.elf-i386 | FileCheck %s -check-prefix ELF-u76 77# ELF-u: U SomeOtherFunction78# ELF-u: U puts79 80## Test different ELF symbols for 64-bit platform.81 82# RUN: yaml2obj --docnum=2 %s -o %t.elf-x86-6483# RUN: llvm-nm %t.elf-x86-64 | FileCheck %s -check-prefix ELF6484 85# ELF64: U SomeOtherFunction86# ELF64: 0000000000000123 a absSym187# ELF64: 0000000000000123 A absSym288# ELF64: 0000000000002000 D dataSym189# ELF64: 0000000000002004 D dataSym290# ELF64: 0000000000001000 T textSym191# ELF64: 0000000000001004 T textSym292# ELF64: U undefinedSym93# ELF64: v weakObject194# ELF64: 0000000000001000 V weakObject295# ELF64: w weakSym196# ELF64: 0000000000001000 W weakSym297 98--- !ELF99FileHeader:100 Class: ELFCLASS64101 Data: ELFDATA2LSB102 Type: ET_REL103 Machine: EM_X86_64104Sections:105 - Name: .text106 Type: SHT_PROGBITS107 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]108 Address: 0x1000109 - Name: .data110 Type: SHT_PROGBITS111 Flags: [ SHF_ALLOC, SHF_WRITE ]112 Address: 0x2000113Symbols:114 - Name: absSym1115 Index: SHN_ABS116 Value: 0x0000000000000123117 - Name: absSym2118 Index: SHN_ABS119 Binding: STB_GLOBAL120 Value: 0x0000000000000123121 - Name: SomeOtherFunction122 Binding: STB_GLOBAL123 - Name: undefinedSym124 Binding: STB_GLOBAL125 - Name: weakObject1126 Type: STT_OBJECT127 Binding: STB_WEAK128 - Name: weakObject2129 Type: STT_OBJECT130 Section: .text131 Binding: STB_WEAK132 - Name: weakSym1133 Binding: STB_WEAK134 - Name: weakSym2135 Section: .text136 Binding: STB_WEAK137 - Name: dataSym1138 Type: STT_OBJECT139 Section: .data140 Binding: STB_GLOBAL141 Value: 0x0000000000000000142 - Name: dataSym2143 Type: STT_OBJECT144 Section: .data145 Binding: STB_GLOBAL146 Value: 0x0000000000000004147 - Name: textSym1148 Type: STT_FUNC149 Section: .text150 Binding: STB_GLOBAL151 Value: 0x0000000000000000152 - Name: textSym2153 Type: STT_FUNC154 Section: .text155 Binding: STB_GLOBAL156 Value: 0x0000000000000004157 158## Test llvm-nm shows all symbols with -a.159 160# RUN: yaml2obj --docnum=3 %s -o %t-a.elf-x86-64161# RUN: llvm-nm -a %t-a.elf-x86-64 | FileCheck %s -check-prefix ELF64-a162 163# ELF64-a: 00000000 b .bss164# ELF64-a-NEXT: 00000000 n .comment165# ELF64-a-NEXT: 00000000 d .data166# ELF64-a-NEXT: 00000000 N .debug_sec167# ELF64-a-NEXT: 00000000 t .text168# ELF64-a-NEXT: 00000000 a fileSym169# ELF64-a-NEXT: 00000014 T regularSym170# ELF64-a-NEXT: U undefSym171 172--- !ELF173FileHeader:174 Class: ELFCLASS32175 Data: ELFDATA2LSB176 Type: ET_REL177 Machine: EM_386178Sections:179 - Name: .rodata180 Type: SHT_PROGBITS181 Flags: [ SHF_ALLOC ] 182 - Name: .text183 Type: SHT_PROGBITS184 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]185 - Name: .data186 Type: SHT_PROGBITS187 Flags: [ SHF_WRITE, SHF_ALLOC ]188 - Name: .bss189 Type: SHT_NOBITS190 Flags: [ SHF_WRITE, SHF_ALLOC ]191 - Name: .debug_sec192 Type: SHT_PROGBITS193 - Name: .comment194 Type: SHT_PROGBITS195Symbols:196 - Name: fileSym197 Type: STT_FILE198 Index: SHN_ABS199 - Name: .text200 Type: STT_SECTION201 Section: .text202 - Name: .data203 Type: STT_SECTION204 Section: .data205 - Name: .bss206 Type: STT_SECTION207 Section: .bss208 - Name: .debug_sec209 Type: STT_SECTION210 Section: .debug_sec211 - Name: .comment212 Type: STT_SECTION213 Section: .comment214 - Name: undefSym215 Binding: STB_GLOBAL216 - Name: regularSym217 Type: STT_FUNC218 Section: .text219 Binding: STB_GLOBAL220 Value: 0x0000000000000014221 222## Test that we drop the thumb bit only from function addresses.223 224# RUN: yaml2obj --docnum=4 %s -o %t.elf-arm32225# RUN: llvm-nm %t.elf-arm32 | FileCheck %s -check-prefix ELF-THUMB226 227# ELF-THUMB: 00000000 t func228# ELF-THUMB: 00000003 t sym229 230--- !ELF231FileHeader:232 Class: ELFCLASS32233 Data: ELFDATA2LSB234 Type: ET_REL235 Machine: EM_ARM236Sections:237 - Name: .text238 Type: SHT_PROGBITS239 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]240Symbols:241 - Name: func242 Type: STT_FUNC243 Section: .text244 Value: 0x0000000000000001245 - Name: sym246 Section: .text247 Value: 0x0000000000000003248 249# RUN: llvm-nm %p/Inputs/trivial-object-test.macho-i386 \250# RUN: | FileCheck %s -check-prefix macho251 252# macho: U _SomeOtherFunction253# macho: 00000000 T _main254# macho: U _puts255 256# RUN: llvm-nm -U %p/Inputs/trivial-object-test.macho-i386 \257# RUN: | FileCheck %s -check-prefix macho-U258 259# macho-U-NOT: U _SomeOtherFunction260# macho-U: 00000000 T _main261# macho-U-NOT: U _puts262 263# RUN: llvm-nm %p/Inputs/trivial-object-test.macho-x86-64 \264# RUN: | FileCheck %s -check-prefix macho64265 266# macho64: 0000000000000028 s L_.str267# macho64: U _SomeOtherFunction268# macho64: 0000000000000000 T _main269# macho64: U _puts270 271# RUN: llvm-nm %p/Inputs/macho-text-data-bss.macho-x86_64 \272# RUN: | FileCheck %s -check-prefix macho-tdb273 274# macho-tdb: 0000000000000030 s EH_frame0275# macho-tdb: 0000000000000070 b _b276# macho-tdb: 000000000000000c D _d277# macho-tdb: 0000000000000000 T _t278# macho-tdb: 0000000000000048 S _t.eh279 280# RUN: llvm-nm -j %p/Inputs/macho-text-data-bss.macho-x86_64 \281# RUN: | FileCheck %s -check-prefix macho-j282 283# macho-j: EH_frame0284# macho-j: _b285# macho-j: _d286# macho-j: _t287# macho-j: _t.eh288 289# RUN: llvm-nm -r %p/Inputs/macho-text-data-bss.macho-x86_64 \290# RUN: | FileCheck %s -check-prefix macho-r291 292# macho-r: 0000000000000048 S _t.eh293# macho-r-NEXT: 0000000000000000 T _t294# macho-r-NEXT: 000000000000000c D _d295# macho-r-NEXT: 0000000000000070 b _b296# macho-r-NEXT: 0000000000000030 s EH_frame0297 298# RUN: llvm-nm %p/Inputs/macho-text-data-bss.macho-x86_64 -s __DATA __data \299# RUN: | FileCheck %s -check-prefix macho-s300 301# macho-s: 000000000000000c D _d302# macho-s-NOT: 0000000000000048 S _t.eh303# macho-s-NOT: 0000000000000000 T _t304# macho-s-NOT: 0000000000000070 b _b305# macho-s-NOT: 0000000000000030 s EH_frame0306 307# RUN: llvm-nm -x %p/Inputs/macho-text-data-bss.macho-x86_64 \308# RUN: | FileCheck %s -check-prefix macho-x309 310# macho-x: 0000000000000030 0e 05 0000 00000010 EH_frame0311# macho-x: 0000000000000070 0e 03 0000 0000000d _b312# macho-x: 000000000000000c 0f 02 0000 00000004 _d313# macho-x: 0000000000000000 0f 01 0000 00000001 _t314# macho-x: 0000000000000048 0f 05 0000 00000007 _t.eh315 316# RUN: llvm-nm -o %p/Inputs/macho-text-data-bss.macho-x86_64 \317# RUN: | FileCheck %s -check-prefix macho-o318 319# macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000030 s EH_frame0320# macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000070 b _b321# macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 000000000000000c D _d322# macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000000 T _t323# macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000048 S _t.eh324 325# RUN: llvm-nm -p -a %p/Inputs/macho-hello-g.macho-x86_64 \326# RUN: | FileCheck %s -check-prefix macho-pa327 328# macho-pa: 0000000000000000 - 00 0000 SO /Volumes/SandBox/329# macho-pa: 0000000000000000 - 00 0000 SO hello.c330# macho-pa: 0000000053c8408d - 03 0001 OSO /Volumes/SandBox/hello.o331# macho-pa: 0000000100000f30 - 01 0000 BNSYM332# macho-pa: 0000000100000f30 - 01 0000 FUN _main333# macho-pa: 000000000000003b - 00 0000 FUN334# macho-pa: 000000000000003b - 01 0000 ENSYM335# macho-pa: 0000000000000000 - 01 0000 SO336# macho-pa: 0000000100000000 T __mh_execute_header337# macho-pa: 0000000100000f30 T _main338# macho-pa: U _printf339# macho-pa: U dyld_stub_binder340 341# RUN: llvm-nm -u %p/Inputs/macho-hello-g.macho-x86_64 \342# RUN: | FileCheck %s -check-prefix macho-u343 344# macho-u: _printf345# macho-u: dyld_stub_binder346 347# RUN: llvm-nm -S -a %p/Inputs/common.coff-i386 \348# RUN: | FileCheck %s -check-prefix COFF-COMMON349 350# COFF-COMMON: 00000000 b .bss351# COFF-COMMON-NEXT: 00000000 d .data352# COFF-COMMON-NEXT: 00000000 d .drectve353# COFF-COMMON-NEXT: 00000000 n .file354# COFF-COMMON-NEXT: 00000000 r .rdata$zzz355# COFF-COMMON-NEXT: 00000000 t .text356# COFF-COMMON-NEXT: C _a357 358# RUN: mkdir -p %t359# RUN: cd %t360# RUN: cp %p/Inputs/trivial-object-test.macho-i386 a.out361# RUN: llvm-nm a.out | FileCheck %s -check-prefix A-OUT362 363# A-OUT: U _SomeOtherFunction364# A-OUT: 00000000 T _main365# A-OUT: U _puts366