From 0fd8aac5dae2fe529e51a6b4db7eb32ce3922158 Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Thu, 3 Jul 2014 21:51:07 +0000 Subject: [PATCH] =?UTF-8?q?Add=20the=20-just-symbol-name=20(aka=20-j)=20fl?= =?UTF-8?q?ag=20to=20llvm-nm=20to=20just=20print=20the=20symbol=E2=80=99s?= =?UTF-8?q?=20name.=20=20On=20darwin=20the=20-j=20flag=20is=20used=20(ofte?= =?UTF-8?q?n=20in=20combinations=20with=20other=20flags)=20to=20produce=20?= =?UTF-8?q?a=20complete=20list=20of=20symbol=20names=20which=20than=20can?= =?UTF-8?q?=20then=20be=20reorder=20and=20used=20with=20ld(1)=E2=80=99s=20?= =?UTF-8?q?-order=5Ffile.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit llvm-svn: 212294 --- llvm/test/Object/nm-trivial-object.test | 8 ++++++++ llvm/tools/llvm-nm/llvm-nm.cpp | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/llvm/test/Object/nm-trivial-object.test b/llvm/test/Object/nm-trivial-object.test index 09642e1c688d..656d6b00cd3d 100644 --- a/llvm/test/Object/nm-trivial-object.test +++ b/llvm/test/Object/nm-trivial-object.test @@ -18,6 +18,8 @@ RUN: llvm-nm %p/Inputs/trivial-object-test.macho-x86-64 \ 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 diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp index 3f9ce24471a9..d3918547d84d 100644 --- a/llvm/tools/llvm-nm/llvm-nm.cpp +++ b/llvm/tools/llvm-nm/llvm-nm.cpp @@ -131,6 +131,11 @@ cl::opt WithoutAliases("without-aliases", cl::Hidden, cl::opt ArchiveMap("print-armap", cl::desc("Print the archive map")); cl::alias ArchiveMaps("s", cl::desc("Alias for --print-armap"), cl::aliasopt(ArchiveMap)); + +cl::opt 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(SymbolicFile *Obj, bool printName) { continue; if (SizeSort && !PrintAddress && I->Size == UnknownAddressOrSize) continue; + if (JustSymbolName) { + outs() << I->Name << "\n"; + continue; + } char SymbolAddrStr[18] = ""; char SymbolSizeStr[18] = "";