From 05f3dabc64b6920a5e334c9edbc2d7298713e18c Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Fri, 30 Oct 2015 19:55:32 +0000 Subject: [PATCH] =?utf8?q?Implemented=20the=20code=20to=20make=20llvm-nm?= =?utf8?q?=E2=80=99s=20-g=20option=20work.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit While llvm-nm parses the -g option and has help that describes it as: -extern-only - Show only external symbols There is no code in the program to use the boolean valve it sets from the command line. rdar://23261095 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251718 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../llvm-nm/X86/Inputs/hello.obj.macho-x86_64 | Bin 0 -> 844 bytes test/tools/llvm-nm/X86/externalonly.test | 4 ++++ test/tools/llvm-nm/lit.local.cfg | 2 ++ tools/llvm-nm/llvm-nm.cpp | 3 +++ 4 files changed, 9 insertions(+) create mode 100644 test/tools/llvm-nm/X86/Inputs/hello.obj.macho-x86_64 create mode 100644 test/tools/llvm-nm/X86/externalonly.test create mode 100644 test/tools/llvm-nm/lit.local.cfg diff --git a/test/tools/llvm-nm/X86/Inputs/hello.obj.macho-x86_64 b/test/tools/llvm-nm/X86/Inputs/hello.obj.macho-x86_64 new file mode 100644 index 0000000000000000000000000000000000000000..2b59a1cfc63b05797c8a012aed7da860c610a434 GIT binary patch literal 844 zcmaJY5S`QbfnT}8LP7Bg!A8a2M$v->EkqKqktHM-6G$!+FC+*;KoGAG{27*( zS}Vj(e}saCLP`-)-{fX7#*cxyH*aU=?cVI(zCOSA5n0`Y51g^dfdhw)!;hK&VP~># zcSV8W&?NSl<7`0CC1?9ZIBa5ASMrT;^ zYjQrJk)|O)=#`4QsdS(#el_oBv|e9rOOq1f2yQ`-XLSRV@qF7sYcHp>hRjxzEWPHP;#oJav?Losg}t-{5Z;}U_|3MZ@i2<1yia-;Z!O41Y~IV!x}L}TBUeS2yuiJm{_0#J literal 0 HcmV?d00001 diff --git a/test/tools/llvm-nm/X86/externalonly.test b/test/tools/llvm-nm/X86/externalonly.test new file mode 100644 index 00000000000..c3741298786 --- /dev/null +++ b/test/tools/llvm-nm/X86/externalonly.test @@ -0,0 +1,4 @@ +# RUN: llvm-nm -g %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s + +# CHECK-NOT: EH_frame0 +# CHECK: _main diff --git a/test/tools/llvm-nm/lit.local.cfg b/test/tools/llvm-nm/lit.local.cfg new file mode 100644 index 00000000000..c8625f4d9d2 --- /dev/null +++ b/test/tools/llvm-nm/lit.local.cfg @@ -0,0 +1,2 @@ +if not 'X86' in config.root.targets: + config.unsupported = True diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index a0b5e9b4eaa..9d0cc575843 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -529,6 +529,9 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName, continue; if (Undefined && DefinedOnly) continue; + bool Global = SymFlags & SymbolRef::SF_Global; + if (!Global && ExternalOnly) + continue; if (SizeSort && !PrintAddress) continue; if (PrintFileName) { -- 2.34.1