--- /dev/null
+;; Show that llvm-nm prints dashes for the symbol value of symbols in values.
+;; Also show that the --no-llvm-bc option prevents loading bitcode files.
+; RUN: llvm-as %s -o %t.bc
+
+; RUN: llvm-nm %t.bc | FileCheck %s --check-prefix=RECOGNISED
+; RUN: not llvm-nm %t.bc --no-llvm-bc 2>&1 | FileCheck %s --check-prefix=UNRECOGNISED -DFILE=%t.bc
+
+; RECOGNISED: ---------------- T foo
+; UNRECOGNISED: error: [[FILE]]: The file was not recognized as a valid object file
+
+target triple = "x86_64-unknown-linux-gnu"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @foo() {
+ ret void
+}
--- /dev/null
+## Show that the --defined-only option omits undefined symbols.
+
+# RUN: yaml2obj %s -o %t.o
+# RUN: llvm-nm %t.o --defined-only > %t.defonly.txt
+# RUN: llvm-nm %t.o -U > %t.U.txt
+
+# RUN: cmp %t.defonly.txt %t.U.txt
+
+# RUN: FileCheck %s --input-file=%t.defonly.txt --implicit-check-not={{.}}
+
+# CHECK: 0000000000000000 T defined
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+Symbols:
+ - Name: defined
+ Section: .text
+ Binding: STB_GLOBAL
+ - Name: undefined
+ Binding: STB_GLOBAL
--- /dev/null
+## --format-bsd is the default output format of llvm-nm. Show that the default
+## and bsd output (including its aliases) match to confirm this.
+
+# RUN: yaml2obj %s -o %t.o
+# RUN: llvm-nm %t.o --format=bsd > %t.formatbsd.txt
+# RUN: llvm-nm %t.o -f=bsd > %t.fbsd.txt
+# RUN: llvm-nm %t.o -B > %t.b.txt
+# RUN: llvm-nm %t.o > %t.default.txt
+
+# RUN: cmp %t.formatbsd.txt %t.default.txt
+# RUN: cmp %t.formatbsd.txt %t.fbsd.txt
+# RUN: cmp %t.formatbsd.txt %t.b.txt
+
+## Sanity check that some output is actually printed.
+# RUN: FileCheck %s --input-file=%t.default.txt
+
+# CHECK: 0000000000000000 T sym1
+# CHECK-NEXT: 0000000000000000 W sym2
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+Symbols:
+ - Name: sym1
+ Section: .text
+ Binding: STB_GLOBAL
+ - Name: sym2
+ Section: .text
+ Binding: STB_WEAK
--- /dev/null
+## Show that the -j/--just-symbol-name prints only the the symbol name (except
+## in posix output).
+
+# RUN: yaml2obj %s -o %t.o
+
+# RUN: llvm-nm --just-symbol-name %t.o > %t.bsd.txt
+# RUN: llvm-nm -j %t.o > %t.j.txt
+# RUN: cmp %t.bsd.txt %t.j.txt
+
+# RUN: FileCheck %s --input-file=%t.bsd.txt --implicit-check-not={{.}} --check-prefix=COMMON
+# RUN: llvm-nm -j %t.o --format=sysv | \
+# RUN: FileCheck %s --implicit-check-not={{.}} --check-prefixes=COMMON,SYSV -DFILE=%t.o
+# RUN: llvm-nm -j %t.o --format=posix | FileCheck %s --implicit-check-not={{.}} --check-prefix=POSIX
+
+# SYSV: Symbols from [[FILE]]:
+# SYSV-EMPTY:
+# SYSV-NEXT: Name Value Class Type Size Line Section
+# COMMON: {{^}}defined{{$}}
+# COMMON-NEXT: {{^}}undefined{{$}}
+
+# POSIX: defined T 0 0
+# POSIX-NEXT: undefined U 0 0
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+Symbols:
+ - Name: defined
+ Section: .text
+ Binding: STB_GLOBAL
+ - Name: undefined
+ Binding: STB_GLOBAL
--- /dev/null
+## Show that the --reverse-sort option reverses the selected sort order.
+# RUN: yaml2obj %s -o %t.o
+# RUN: llvm-nm %t.o --reverse-sort | FileCheck %s --check-prefix=SORTED
+# RUN: llvm-nm %t.o --reverse-sort --numeric-sort | FileCheck %s --check-prefix=SORTED
+# RUN: llvm-nm %t.o --reverse-sort --size-sort | FileCheck %s --check-prefix=SORTED
+# RUN: llvm-nm %t.o --reverse-sort --no-sort | FileCheck %s --check-prefix=UNSORTED
+
+# SORTED: third
+# SORTED-NEXT: second
+# SORTED-NEXT: first
+
+# UNSORTED: second
+# UNSORTED-NEXT: third
+# UNSORTED-NEXT: first
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+Symbols:
+ - Name: second
+ Section: .text
+ Value: 2
+ Size: 2
+ - Name: third
+ Section: .text
+ Value: 3
+ Size: 3
+ - Name: first
+ Section: .text
+ Value: 1
+ Size: 1