llvm.org GIT mirror llvm / f892f69
Revert [tools] [llvm-nm] Default to reading from stdin not a.out This reverts r365889 (git commit 60c81354b1d3fced1bd284d334f118d2d792ab4b) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366219 91177308-0d34-0410-b5e6-96231b3b80d8 Alex Brachet a month ago
3 changed file(s) with 4 addition(s) and 43 deletion(s). Raw diff Collapse all Expand all
1212
1313 The :program:`llvm-nm` utility lists the names of symbols from LLVM bitcode
1414 files, object files, and archives. Each symbol is listed along with some simple
15 information about its provenance. If no filename is specified, or *-* is used as
16 a filename, :program:`llvm-nm` will read a file from its standard input stream.
15 information about its provenance. If no filename is specified, *a.out* is used
16 as the input. If *-* is used as a filename, :program:`llvm-nm` will read a file
17 from its standard input stream.
1718
1819 :program:`llvm-nm`'s default output format is the traditional BSD :program:`nm`
1920 output format. Each such output record consists of an (optional) 8-digit
+0
-33
test/tools/llvm-nm/stdin.test less more
None ## Test llvm-nm when using stdin both explicitly (using '-' as a filename)
1 ## and implicitly (not specifying any filename).
2
3 # RUN: yaml2obj %s -o %t.o
4
5 ## Pass an explicit filename to produce a baseline output. llvm-nm should
6 ## have the same behavior when opening a file itself and when reading that
7 ## file from its standard input stream.
8 # RUN: llvm-nm %t.o > %t.base 2> %t.err
9
10 ## Make sure there is no warning message about no file redirected to stdin.
11 # RUN: FileCheck %s --input-file=%t.err --allow-empty --implicit-check-not={{.}}
12
13 # RUN: llvm-nm - < %t.o > %t.explicit 2> %t.err
14 # RUN: FileCheck %s --input-file=%t.err --allow-empty --implicit-check-not={{.}}
15 # RUN: cmp %t.base %t.explicit
16
17 # RUN: llvm-nm < %t.o > %t.implicit 2> %t.err
18 # RUN: FileCheck %s --input-file=%t.err --allow-empty --implicit-check-not={{.}}
19 # RUN: cmp %t.base %t.implicit
20
21 !ELF
22 FileHeader:
23 Class: ELFCLASS64
24 Data: ELFDATA2LSB
25 Type: ET_REL
26 Machine: EM_X86_64
27 Sections:
28 - Name: .text
29 Type: SHT_PROGBITS
30 Symbols:
31 - Name: symbol_a
32 Section: .text
3333 #include "llvm/Support/Format.h"
3434 #include "llvm/Support/InitLLVM.h"
3535 #include "llvm/Support/MemoryBuffer.h"
36 #include "llvm/Support/Process.h"
3736 #include "llvm/Support/Program.h"
3837 #include "llvm/Support/Signals.h"
3938 #include "llvm/Support/TargetSelect.h"
17511750 }
17521751
17531752 static void dumpSymbolNamesFromFile(std::string &Filename) {
1754 if (Filename == "-" && sys::Process::StandardInIsUserInput()) {
1755 WithColor::warning(errs(), ToolName) << "can't read from terminal\n";
1756 cl::PrintHelpMessage();
1757 HadError = true;
1758 return;
1759 }
17601753 ErrorOr> BufferOrErr =
17611754 MemoryBuffer::getFileOrSTDIN(Filename);
17621755 if (error(BufferOrErr.getError(), Filename))
20882081 if (OutputFormat == sysv || SizeSort)
20892082 PrintSize = true;
20902083 if (InputFilenames.empty())
2091 InputFilenames.push_back("-");
2084 InputFilenames.push_back("a.out");
20922085 if (InputFilenames.size() > 1)
20932086 MultipleFiles = true;
20942087