forked from OSchip/llvm-project
nm: Add -no-weak flag for hiding weak symbols
Summary: 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. Patch by Keith Smiley Reviewers: kastiglione, enderby, compnerd Reviewed By: kastiglione Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D48751 llvm-svn: 336126
This commit is contained in:
parent
35f196c179
commit
d4f77a523b
|
@ -93,6 +93,10 @@ OPTIONS
|
|||
Print only symbols whose definitions are external; that is, accessible
|
||||
from other files.
|
||||
|
||||
.. option:: --no-weak, -W
|
||||
|
||||
Don't print any weak symbols in the output.
|
||||
|
||||
.. option:: --format=format, -f format
|
||||
|
||||
Select an output format; *format* may be *sysv*, *posix*, or *bsd*. The default
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# RUN: llvm-nm -B -S %p/Inputs/weak.obj.elf-x86_64 | FileCheck --match-full-lines %s
|
||||
# RUN: llvm-nm -W -B -S %p/Inputs/weak.obj.elf-x86_64 | count 0
|
||||
|
||||
CHECK: w weak_extern_func
|
||||
CHECK: w weak_extern_var
|
||||
|
|
|
@ -81,6 +81,11 @@ cl::alias ExternalOnly2("g", cl::desc("Alias for --extern-only"),
|
|||
cl::aliasopt(ExternalOnly), cl::Grouping,
|
||||
cl::ZeroOrMore);
|
||||
|
||||
cl::opt<bool> NoWeakSymbols("no-weak",
|
||||
cl::desc("Show only non-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 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName,
|
|||
|
||||
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())
|
||||
|
|
Loading…
Reference in New Issue