xref: /llvm-project/llvm/test/tools/llvm-nm/just-symbols.test (revision 1a4d1315650b7b2d18b1de56d2d6e3a1a0d632d3)
1## Show that the -j/--just-symbol-name/--format=just-symbols prints only the the
2## symbol name.
3
4# RUN: yaml2obj %s -o %t.o
5
6# RUN: llvm-nm -j %t.o > %t.txt
7# RUN: llvm-nm --just-symbol-name %t.o | diff %t.txt -
8# RUN: llvm-nm --format=just-symbols %t.o | diff %t.txt -
9# RUN: llvm-nm --format=sysv -j %t.o | diff %t.txt -
10# RUN: llvm-nm -j --format=posix %t.o | not diff %t.txt -
11
12# RUN: FileCheck %s --input-file=%t.txt --implicit-check-not={{.}} --check-prefix=COMMON
13
14# COMMON:      {{^}}defined{{$}}
15# COMMON-NEXT: {{^}}undefined{{$}}
16
17# RUN: llvm-nm -j %t.o %t.o | FileCheck %s --check-prefix=MULTI1 -DFILE=%t.o
18
19# MULTI1-NOT:   {{.}}
20# MULTI1:       {{^$}}
21# MULTI1-NEXT:  [[FILE]]:
22# MULTI1-NEXT:  defined
23# MULTI1-NEXT:  undefined
24# MULTI1-EMPTY:
25# MULTI1-NEXT:  [[FILE]]:
26# MULTI1-NEXT:  defined
27# MULTI1-NEXT:  undefined
28# MULTI1-NOT:   {{.}}
29
30# RUN: llvm-nm -j --print-file-name %t.o %t.o | FileCheck %s --check-prefix=MULTI2 -DFILE=%t.o
31
32# MULTI2-NOT:   {{.}}
33# MULTI2:       [[FILE]]: defined
34# MULTI2-NEXT:  [[FILE]]: undefined
35# MULTI2-NEXT:  [[FILE]]: defined
36# MULTI2-NEXT:  [[FILE]]: undefined
37# MULTI2-NOT:   {{.}}
38
39--- !ELF
40FileHeader:
41  Class:   ELFCLASS64
42  Data:    ELFDATA2LSB
43  Type:    ET_REL
44Sections:
45  - Name:  .text
46    Type:  SHT_PROGBITS
47    Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
48Symbols:
49  - Name:    defined
50    Section: .text
51    Binding: STB_GLOBAL
52  - Name:    undefined
53    Binding: STB_GLOBAL
54