# RUN: yaml2obj %p/Inputs/COFF/i386.yaml | llvm-nm -a -S - \ # RUN: | FileCheck %s -check-prefix COFF32 # COFF32: 00000000 d .data # COFF32-NEXT: 00000000 t .text # COFF32-NEXT: 00000000 d L_.str # COFF32-NEXT: U _SomeOtherFunction # COFF32-NEXT: 00000000 T _main # COFF32-NEXT: U _puts # RUN: yaml2obj %p/Inputs/COFF/x86-64.yaml | llvm-nm -a -S - \ # RUN: | FileCheck %s -check-prefix COFF64 # COFF64: 00000000 d .data # COFF64-NEXT: 00000000 t .text # COFF64-NEXT: 00000000 r ??__Ex@@YAXXZ # COFF64-NEXT: 00000000 d L.str # COFF64-NEXT: U SomeOtherFunction # COFF64-NEXT: 00000000 T main # COFF64-NEXT: U puts # RUN: llvm-nm %p/Inputs/trivial-object-test.wasm \ # RUN: | FileCheck %s -check-prefix WASM # WASM: 00000000 d .L.str # WASM-NEXT: 00000019 t .LSomeOtherFunction_bitcast # WASM-NEXT: U SomeOtherFunction # WASM-NEXT: 00000001 T main # WASM-NEXT: U puts # WASM-NEXT: 00000010 D var # RUN: yaml2obj -docnum=1 %s > %t.elf-i386 --- !ELF FileHeader: Class: ELFCLASS32 Data: ELFDATA2LSB Type: ET_REL Machine: EM_386 Sections: - Name: .text Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_EXECINSTR ] Symbols: - Name: main Type: STT_FUNC Section: .text Binding: STB_GLOBAL Size: 0x0000000000000024 - Name: SomeOtherFunction Binding: STB_GLOBAL - Name: puts Binding: STB_GLOBAL # RUN: llvm-nm %t.elf-i386 | FileCheck %s -check-prefix=ELF # ELF-NOT: U # ELF: U SomeOtherFunction # ELF: 00000000 T main # ELF: U puts # RUN: llvm-nm -o %t.elf-i386 | FileCheck %s -DFILE=%t.elf-i386 -check-prefix=ELF-o # RUN: llvm-nm %t.elf-i386 -S | FileCheck %s -check-prefix ELF-SIZE # ELF-SIZE: U SomeOtherFunction # ELF-SIZE-NEXT: 00000000 00000024 T main # ELF-SIZE-NEXT: U puts # ELF-o-NOT: U # ELF-o: [[FILE]]: U SomeOtherFunction # ELF-o: [[FILE]]: 00000000 T main # ELF-o: [[FILE]]: U puts # RUN: llvm-nm -u %t.elf-i386 | FileCheck %s -check-prefix ELF-u # ELF-u: U SomeOtherFunction # ELF-u: U puts ## Test different ELF symbols for 64-bit platform. # RUN: yaml2obj -docnum=2 %s > %t.elf-x86-64 # RUN: llvm-nm %t.elf-x86-64 | FileCheck %s -check-prefix ELF64 # ELF64: U SomeOtherFunction # ELF64: 0000000000000123 a absSym1 # ELF64: 0000000000000123 A absSym2 # ELF64: 0000000000002000 D dataSym1 # ELF64: 0000000000002004 D dataSym2 # ELF64: 0000000000001000 T textSym1 # ELF64: 0000000000001004 T textSym2 # ELF64: U undefinedSym # ELF64: v weakObject1 # ELF64: 0000000000001000 V weakObject2 # ELF64: w weakSym1 # ELF64: 0000000000001000 W weakSym2 --- !ELF FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB Type: ET_REL Machine: EM_X86_64 Sections: - Name: .text Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_EXECINSTR ] Address: 0x1000 - Name: .data Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_WRITE ] Address: 0x2000 Symbols: - Name: absSym1 Index: SHN_ABS Value: 0x0000000000000123 - Name: absSym2 Index: SHN_ABS Binding: STB_GLOBAL Value: 0x0000000000000123 - Name: SomeOtherFunction Binding: STB_GLOBAL - Name: undefinedSym Binding: STB_GLOBAL - Name: weakObject1 Type: STT_OBJECT Binding: STB_WEAK - Name: weakObject2 Type: STT_OBJECT Section: .text Binding: STB_WEAK - Name: weakSym1 Binding: STB_WEAK - Name: weakSym2 Section: .text Binding: STB_WEAK - Name: dataSym1 Type: STT_OBJECT Section: .data Binding: STB_GLOBAL Value: 0x0000000000000000 - Name: dataSym2 Type: STT_OBJECT Section: .data Binding: STB_GLOBAL Value: 0x0000000000000004 - Name: textSym1 Type: STT_FUNC Section: .text Binding: STB_GLOBAL Value: 0x0000000000000000 - Name: textSym2 Type: STT_FUNC Section: .text Binding: STB_GLOBAL Value: 0x0000000000000004 ## Test llvm-nm shows all symbols with -a. # RUN: yaml2obj -docnum=3 %s > %t-a.elf-x86-64 # RUN: llvm-nm -a %t-a.elf-x86-64 | FileCheck %s -check-prefix ELF64-a # ELF64-a: 00000000 b .bss # ELF64-a-NEXT: 00000000 n .comment # ELF64-a-NEXT: 00000000 d .data # ELF64-a-NEXT: 00000000 N .debug_sec # ELF64-a-NEXT: 00000000 t .text # ELF64-a-NEXT: 00000000 a fileSym # ELF64-a-NEXT: 00000014 T regularSym # ELF64-a-NEXT: U undefSym --- !ELF FileHeader: Class: ELFCLASS32 Data: ELFDATA2LSB Type: ET_REL Machine: EM_386 Sections: - Name: .rodata Type: SHT_PROGBITS Flags: [ SHF_ALLOC ] - Name: .text Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - Name: .data Type: SHT_PROGBITS Flags: [ SHF_WRITE, SHF_ALLOC ] - Name: .bss Type: SHT_NOBITS Flags: [ SHF_WRITE, SHF_ALLOC ] - Name: .debug_sec Type: SHT_PROGBITS - Name: .comment Type: SHT_PROGBITS Symbols: - Name: fileSym Type: STT_FILE Index: SHN_ABS - Name: .text Type: STT_SECTION Section: .text - Name: .data Type: STT_SECTION Section: .data - Name: .bss Type: STT_SECTION Section: .bss - Name: .debug_sec Type: STT_SECTION Section: .debug_sec - Name: .comment Type: STT_SECTION Section: .comment - Name: undefSym Binding: STB_GLOBAL - Name: regularSym Type: STT_FUNC Section: .text Binding: STB_GLOBAL Value: 0x0000000000000014 ## Test that we drop the thumb bit only from function addresses. # RUN: yaml2obj -docnum=4 %s > %t.elf-arm32 # RUN: llvm-nm %t.elf-arm32 | FileCheck %s -check-prefix ELF-THUMB # ELF-THUMB: 00000000 t func # ELF-THUMB: 00000003 t sym --- !ELF FileHeader: Class: ELFCLASS32 Data: ELFDATA2LSB Type: ET_REL Machine: EM_ARM Sections: - Name: .text Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_EXECINSTR ] Symbols: - Name: func Type: STT_FUNC Section: .text Value: 0x0000000000000001 - Name: sym Section: .text Value: 0x0000000000000003 # RUN: llvm-nm %p/Inputs/trivial-object-test.macho-i386 \ # RUN: | FileCheck %s -check-prefix macho # macho: U _SomeOtherFunction # macho: 00000000 T _main # macho: U _puts # RUN: llvm-nm -U %p/Inputs/trivial-object-test.macho-i386 \ # RUN: | FileCheck %s -check-prefix macho-U # macho-U-NOT: U _SomeOtherFunction # macho-U: 00000000 T _main # macho-U-NOT: U _puts # RUN: llvm-nm %p/Inputs/trivial-object-test.macho-x86-64 \ # RUN: | FileCheck %s -check-prefix macho64 # macho64: 0000000000000028 s L_.str # macho64: U _SomeOtherFunction # macho64: 0000000000000000 T _main # macho64: U _puts # RUN: llvm-nm %p/Inputs/macho-text-data-bss.macho-x86_64 \ # RUN: | FileCheck %s -check-prefix macho-tdb # macho-tdb: 0000000000000030 s EH_frame0 # macho-tdb: 0000000000000070 b _b # macho-tdb: 000000000000000c D _d # macho-tdb: 0000000000000000 T _t # macho-tdb: 0000000000000048 S _t.eh # RUN: llvm-nm -j %p/Inputs/macho-text-data-bss.macho-x86_64 \ # RUN: | FileCheck %s -check-prefix macho-j # macho-j: EH_frame0 # macho-j: _b # macho-j: _d # macho-j: _t # macho-j: _t.eh # RUN: llvm-nm -r %p/Inputs/macho-text-data-bss.macho-x86_64 \ # RUN: | FileCheck %s -check-prefix macho-r # macho-r: 0000000000000048 S _t.eh # macho-r-NEXT: 0000000000000000 T _t # macho-r-NEXT: 000000000000000c D _d # macho-r-NEXT: 0000000000000070 b _b # macho-r-NEXT: 0000000000000030 s EH_frame0 # RUN: llvm-nm %p/Inputs/macho-text-data-bss.macho-x86_64 -s __DATA __data \ # RUN: | FileCheck %s -check-prefix macho-s # macho-s: 000000000000000c D _d # macho-s-NOT: 0000000000000048 S _t.eh # macho-s-NOT: 0000000000000000 T _t # macho-s-NOT: 0000000000000070 b _b # macho-s-NOT: 0000000000000030 s EH_frame0 # RUN: llvm-nm -x %p/Inputs/macho-text-data-bss.macho-x86_64 \ # RUN: | FileCheck %s -check-prefix macho-x # macho-x: 0000000000000030 0e 05 0000 00000010 EH_frame0 # macho-x: 0000000000000070 0e 03 0000 0000000d _b # macho-x: 000000000000000c 0f 02 0000 00000004 _d # macho-x: 0000000000000000 0f 01 0000 00000001 _t # macho-x: 0000000000000048 0f 05 0000 00000007 _t.eh # RUN: llvm-nm -o %p/Inputs/macho-text-data-bss.macho-x86_64 \ # RUN: | FileCheck %s -check-prefix macho-o # macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000030 s EH_frame0 # macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000070 b _b # macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 000000000000000c D _d # macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000000 T _t # macho-o: {{.*}}/macho-text-data-bss.macho-x86_64: 0000000000000048 S _t.eh # RUN: llvm-nm -p -a %p/Inputs/macho-hello-g.macho-x86_64 \ # RUN: | FileCheck %s -check-prefix macho-pa # macho-pa: 0000000000000000 - 00 0000 SO /Volumes/SandBox/ # macho-pa: 0000000000000000 - 00 0000 SO hello.c # macho-pa: 0000000053c8408d - 03 0001 OSO /Volumes/SandBox/hello.o # macho-pa: 0000000100000f30 - 01 0000 BNSYM # macho-pa: 0000000100000f30 - 01 0000 FUN _main # macho-pa: 000000000000003b - 00 0000 FUN # macho-pa: 000000000000003b - 01 0000 ENSYM # macho-pa: 0000000000000000 - 01 0000 SO # macho-pa: 0000000100000000 T __mh_execute_header # macho-pa: 0000000100000f30 T _main # macho-pa: U _printf # macho-pa: U dyld_stub_binder # RUN: llvm-nm -u %p/Inputs/macho-hello-g.macho-x86_64 \ # RUN: | FileCheck %s -check-prefix macho-u # macho-u: _printf # macho-u: dyld_stub_binder # RUN: llvm-nm -S -a %p/Inputs/common.coff-i386 \ # RUN: | FileCheck %s -check-prefix COFF-COMMON # COFF-COMMON: 00000000 b .bss # COFF-COMMON-NEXT: 00000000 d .data # COFF-COMMON-NEXT: 00000000 d .drectve # COFF-COMMON-NEXT: 00000000 n .file # COFF-COMMON-NEXT: 00000000 r .rdata$zzz # COFF-COMMON-NEXT: 00000000 t .text # COFF-COMMON-NEXT: C _a # RUN: mkdir -p %t # RUN: cd %t # RUN: cp %p/Inputs/trivial-object-test.macho-i386 a.out # RUN: llvm-nm a.out | FileCheck %s -check-prefix A-OUT # A-OUT: U _SomeOtherFunction # A-OUT: 00000000 T _main # A-OUT: U _puts