[PATCH] D48751: nm: Add -no-weak flag for hiding weak symbols
Keith Smiley via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 28 15:08:57 PDT 2018
keith created this revision.
keith added a reviewer: kastiglione.
This adds a new -no-weak flag to nm to hide weak symbols in its output.
This also adds a -W alias for this which is analogous to -U.
Repository:
rL LLVM
https://reviews.llvm.org/D48751
Files:
test/tools/llvm-nm/X86/weak.test
tools/llvm-nm/llvm-nm.cpp
Index: tools/llvm-nm/llvm-nm.cpp
===================================================================
--- tools/llvm-nm/llvm-nm.cpp
+++ tools/llvm-nm/llvm-nm.cpp
@@ -81,6 +81,11 @@
cl::aliasopt(ExternalOnly), cl::Grouping,
cl::ZeroOrMore);
+cl::opt<bool> NoWeakSymbols("no-weak",
+ cl::desc("Don't show weak symbols"));
+cl::alias NoWeakSymbols2("W", cl::desc("Alias for --no-weak"),
+ cl::aliasopt(NoWeakSymbols), cl::Grouping);
+
cl::opt<bool> BSDFormat("B", cl::desc("Alias for --format=bsd"),
cl::Grouping);
cl::opt<bool> POSIXFormat("P", cl::desc("Alias for --format=posix"),
@@ -768,8 +773,10 @@
bool Undefined = SymFlags & SymbolRef::SF_Undefined;
bool Global = SymFlags & SymbolRef::SF_Global;
+ bool Weak = SymFlags & SymbolRef::SF_Weak;
if ((!Undefined && UndefinedOnly) || (Undefined && DefinedOnly) ||
- (!Global && ExternalOnly) || (SizeSort && !PrintAddress))
+ (!Global && ExternalOnly) || (SizeSort && !PrintAddress) ||
+ (Weak && NoWeakSymbols))
continue;
if (PrintFileName) {
if (!ArchitectureName.empty())
Index: test/tools/llvm-nm/X86/weak.test
===================================================================
--- test/tools/llvm-nm/X86/weak.test
+++ test/tools/llvm-nm/X86/weak.test
@@ -1,6 +1,12 @@
-# RUN: llvm-nm -B -S %p/Inputs/weak.obj.elf-x86_64 | FileCheck --match-full-lines %s
+# RUN: llvm-nm -B -S %p/Inputs/weak.obj.elf-x86_64 | FileCheck --match-full-lines %s --check-prefix=WEAK
+# RUN: llvm-nm -W -B -S %p/Inputs/weak.obj.elf-x86_64 | FileCheck --allow-empty --match-full-lines %s --check-prefix=NOWEAK
-CHECK: w weak_extern_func
-CHECK: w weak_extern_var
-CHECK: 0000000000000000 0000000000000011 W weak_func
-CHECK: 0000000000000000 0000000000000004 V weak_var
+WEAK: w weak_extern_func
+WEAK: w weak_extern_var
+WEAK: 0000000000000000 0000000000000011 W weak_func
+WEAK: 0000000000000000 0000000000000004 V weak_var
+
+NOWEAK-NOT: w weak_extern_func
+NOWEAK-NOT: w weak_extern_var
+NOWEAK-NOT: 0000000000000000 0000000000000011 W weak_func
+NOWEAK-NOT: 0000000000000000 0000000000000004 V weak_var
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48751.153414.patch
Type: text/x-patch
Size: 2332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180628/0f7c113e/attachment.bin>
More information about the llvm-commits
mailing list