From: Kevin Enderby Date: Fri, 30 Oct 2015 19:55:32 +0000 (+0000) Subject: Implemented the code to make llvm-nm’s -g option work. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=05f3dabc64b6920a5e334c9edbc2d7298713e18c;p=oota-llvm.git Implemented the code to make llvm-nm’s -g option work. 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 --- 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 00000000000..2b59a1cfc63 Binary files /dev/null and b/test/tools/llvm-nm/X86/Inputs/hello.obj.macho-x86_64 differ 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) {