From 06e175204105f46c23ea7ef5ce9743846524929f Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Mon, 2 Nov 2015 23:42:05 +0000 Subject: [PATCH] =?utf8?q?Allow=20llvm-nm=E2=80=99s=20single=20letter=20co?= =?utf8?q?mmand=20line=20flags=20to=20be=20grouped.=20Which=20is=20needed?= =?utf8?q?=20if=20we=20want=20to=20replace=20darwin=E2=80=99s=20nm(1)=20wi?= =?utf8?q?th=20llvm-nm=20as=20there=20are=20many=20uses=20of=20grouped=20f?= =?utf8?q?lags.=20=20The=20added=20test=20case=20is=20one=20specific=20cas?= =?utf8?q?e=20that=20is=20in=20real=20use.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit rdar://23337419 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251864 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/tools/llvm-nm/X86/groupingflags.test | 5 +++ tools/llvm-nm/llvm-nm.cpp | 40 +++++++++++++---------- 2 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 test/tools/llvm-nm/X86/groupingflags.test diff --git a/test/tools/llvm-nm/X86/groupingflags.test b/test/tools/llvm-nm/X86/groupingflags.test new file mode 100644 index 00000000000..a1a258506e9 --- /dev/null +++ b/test/tools/llvm-nm/X86/groupingflags.test @@ -0,0 +1,5 @@ +# RUN: llvm-nm -gjp %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s + +# CHECK: _main +# CHECK: _main.eh +# CHECK: _printf diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index 9d0cc575843..5cf6b4fb2ce 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -65,27 +65,30 @@ cl::list InputFilenames(cl::Positional, cl::desc(""), cl::opt UndefinedOnly("undefined-only", cl::desc("Show only undefined symbols")); cl::alias UndefinedOnly2("u", cl::desc("Alias for --undefined-only"), - cl::aliasopt(UndefinedOnly)); + cl::aliasopt(UndefinedOnly), cl::Grouping); cl::opt DynamicSyms("dynamic", cl::desc("Display the dynamic symbols instead " "of normal symbols.")); cl::alias DynamicSyms2("D", cl::desc("Alias for --dynamic"), - cl::aliasopt(DynamicSyms)); + cl::aliasopt(DynamicSyms), cl::Grouping); cl::opt DefinedOnly("defined-only", cl::desc("Show only defined symbols")); cl::alias DefinedOnly2("U", cl::desc("Alias for --defined-only"), - cl::aliasopt(DefinedOnly)); + cl::aliasopt(DefinedOnly), cl::Grouping); cl::opt ExternalOnly("extern-only", cl::desc("Show only external symbols")); cl::alias ExternalOnly2("g", cl::desc("Alias for --extern-only"), - cl::aliasopt(ExternalOnly)); + cl::aliasopt(ExternalOnly), cl::Grouping); -cl::opt BSDFormat("B", cl::desc("Alias for --format=bsd")); -cl::opt POSIXFormat("P", cl::desc("Alias for --format=posix")); -cl::opt DarwinFormat("m", cl::desc("Alias for --format=darwin")); +cl::opt BSDFormat("B", cl::desc("Alias for --format=bsd"), + cl::Grouping); +cl::opt POSIXFormat("P", cl::desc("Alias for --format=posix"), + cl::Grouping); +cl::opt DarwinFormat("m", cl::desc("Alias for --format=darwin"), + cl::Grouping); static cl::list ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"), @@ -97,32 +100,33 @@ cl::opt PrintFileName( cl::desc("Precede each symbol with the object file it came from")); cl::alias PrintFileNameA("A", cl::desc("Alias for --print-file-name"), - cl::aliasopt(PrintFileName)); + cl::aliasopt(PrintFileName), cl::Grouping); cl::alias PrintFileNameo("o", cl::desc("Alias for --print-file-name"), - cl::aliasopt(PrintFileName)); + cl::aliasopt(PrintFileName), cl::Grouping); cl::opt DebugSyms("debug-syms", cl::desc("Show all symbols, even debugger only")); cl::alias DebugSymsa("a", cl::desc("Alias for --debug-syms"), - cl::aliasopt(DebugSyms)); + cl::aliasopt(DebugSyms), cl::Grouping); cl::opt NumericSort("numeric-sort", cl::desc("Sort symbols by address")); cl::alias NumericSortn("n", cl::desc("Alias for --numeric-sort"), - cl::aliasopt(NumericSort)); + cl::aliasopt(NumericSort), cl::Grouping); cl::alias NumericSortv("v", cl::desc("Alias for --numeric-sort"), - cl::aliasopt(NumericSort)); + cl::aliasopt(NumericSort), cl::Grouping); cl::opt NoSort("no-sort", cl::desc("Show symbols in order encountered")); -cl::alias NoSortp("p", cl::desc("Alias for --no-sort"), cl::aliasopt(NoSort)); +cl::alias NoSortp("p", cl::desc("Alias for --no-sort"), cl::aliasopt(NoSort), + cl::Grouping); cl::opt ReverseSort("reverse-sort", cl::desc("Sort in reverse order")); cl::alias ReverseSortr("r", cl::desc("Alias for --reverse-sort"), - cl::aliasopt(ReverseSort)); + cl::aliasopt(ReverseSort), cl::Grouping); cl::opt PrintSize("print-size", cl::desc("Show symbol size instead of address")); cl::alias PrintSizeS("S", cl::desc("Alias for --print-size"), - cl::aliasopt(PrintSize)); + cl::aliasopt(PrintSize), cl::Grouping); cl::opt SizeSort("size-sort", cl::desc("Sort symbols by size")); @@ -131,12 +135,12 @@ cl::opt WithoutAliases("without-aliases", cl::Hidden, cl::opt ArchiveMap("print-armap", cl::desc("Print the archive map")); cl::alias ArchiveMaps("M", cl::desc("Alias for --print-armap"), - cl::aliasopt(ArchiveMap)); + cl::aliasopt(ArchiveMap), cl::Grouping); 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)); + cl::aliasopt(JustSymbolName), cl::Grouping); // FIXME: This option takes exactly two strings and should be allowed anywhere // on the command line. Such that "llvm-nm -s __TEXT __text foo.o" would work. @@ -148,7 +152,7 @@ cl::list SegSect("s", cl::Positional, cl::ZeroOrMore, "and section name, Mach-O only")); cl::opt FormatMachOasHex("x", cl::desc("Print symbol entry in hex, " - "Mach-O only")); + "Mach-O only"), cl::Grouping); cl::opt NoLLVMBitcode("no-llvm-bc", cl::desc("Disable LLVM bitcode reader")); -- 2.34.1