[llvm] r212294 - Add the -just-symbol-name (aka -j) flag to llvm-nm to just print the
Kevin Enderby
enderby at apple.com
Thu Jul 3 14:51:07 PDT 2014
Author: enderby
Date: Thu Jul 3 16:51:07 2014
New Revision: 212294
URL: http://llvm.org/viewvc/llvm-project?rev=212294&view=rev
Log:
Add the -just-symbol-name (aka -j) flag to llvm-nm to just print the
symbol’s name. On darwin the -j flag is used (often in combinations
with other flags) to produce a complete list of symbol names which
than can then be reorder and used with ld(1)’s -order_file.
Modified:
llvm/trunk/test/Object/nm-trivial-object.test
llvm/trunk/tools/llvm-nm/llvm-nm.cpp
Modified: llvm/trunk/test/Object/nm-trivial-object.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/nm-trivial-object.test?rev=212294&r1=212293&r2=212294&view=diff
==============================================================================
--- llvm/trunk/test/Object/nm-trivial-object.test (original)
+++ llvm/trunk/test/Object/nm-trivial-object.test Thu Jul 3 16:51:07 2014
@@ -18,6 +18,8 @@ RUN: llvm-nm %p/Inputs/trivial-object-te
RUN: | FileCheck %s -check-prefix macho64
RUN: llvm-nm %p/Inputs/macho-text-data-bss.macho-x86_64 \
RUN: | FileCheck %s -check-prefix macho-tdb
+RUN: llvm-nm -j %p/Inputs/macho-text-data-bss.macho-x86_64 \
+RUN: | FileCheck %s -check-prefix macho-j
RUN: llvm-nm -r %p/Inputs/macho-text-data-bss.macho-x86_64 \
RUN: | FileCheck %s -check-prefix macho-r
RUN: llvm-nm %p/Inputs/common.coff-i386 \
@@ -85,6 +87,12 @@ macho-tdb: 000000000000000c D _d
macho-tdb: 0000000000000000 T _t
macho-tdb: 0000000000000048 S _t.eh
+macho-j: EH_frame0
+macho-j: _b
+macho-j: _d
+macho-j: _t
+macho-j: _t.eh
+
macho-r: 0000000000000048 S _t.eh
macho-r-NEXT: 0000000000000000 T _t
macho-r-NEXT: 000000000000000c D _d
Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=212294&r1=212293&r2=212294&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Thu Jul 3 16:51:07 2014
@@ -131,6 +131,11 @@ cl::opt<bool> WithoutAliases("without-al
cl::opt<bool> ArchiveMap("print-armap", cl::desc("Print the archive map"));
cl::alias ArchiveMaps("s", cl::desc("Alias for --print-armap"),
cl::aliasopt(ArchiveMap));
+
+cl::opt<bool> JustSymbolName("just-symbol-name",
+ cl::desc("Print just the symbol's name"));
+cl::alias JustSymbolNames("j", cl::desc("Alias for --just-symbol-name"),
+ cl::aliasopt(JustSymbolName));
bool PrintAddress = true;
bool MultipleFiles = false;
@@ -446,6 +451,10 @@ static void sortAndPrintSymbolList(Symbo
continue;
if (SizeSort && !PrintAddress && I->Size == UnknownAddressOrSize)
continue;
+ if (JustSymbolName) {
+ outs() << I->Name << "\n";
+ continue;
+ }
char SymbolAddrStr[18] = "";
char SymbolSizeStr[18] = "";
More information about the llvm-commits
mailing list