[llvm] r351347 - [llvm-nm] Allow --size-sort to print symbols with only Symbol size
Saurabh Badhwar via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 16 06:38:22 PST 2019
Author: h4xr
Date: Wed Jan 16 06:38:22 2019
New Revision: 351347
URL: http://llvm.org/viewvc/llvm-project?rev=351347&view=rev
Log:
[llvm-nm] Allow --size-sort to print symbols with only Symbol size
Summary:
When llvm-nm is passed only the --size-sort option for an object file, there is no output generated.
The commit modifies the behavior to print the symbols sorted and their size which is also inline with
the output of the GNU nm tool.
Signed-off-by: Saurabh Badhwar <sbsaurabhbadhwar9 at gmail.com>
Reviewers: enderby, rupprecht
Reviewed By: rupprecht
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D56063
Added:
llvm/trunk/test/tools/llvm-nm/X86/size-sort.test
Modified:
llvm/trunk/tools/llvm-nm/llvm-nm.cpp
Added: llvm/trunk/test/tools/llvm-nm/X86/size-sort.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-nm/X86/size-sort.test?rev=351347&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-nm/X86/size-sort.test (added)
+++ llvm/trunk/test/tools/llvm-nm/X86/size-sort.test Wed Jan 16 06:38:22 2019
@@ -0,0 +1,12 @@
+# RUN: llvm-nm --size-sort %p/Inputs/hello.obj.elf-x86_64 | FileCheck --check-prefix=SIZE-SORT-NO-ADDR %s
+# RUN: llvm-nm --size-sort -S %p/Inputs/hello.obj.elf-x86_64 | FileCheck --check-prefix=SIZE-SORT-PRINT-ADDR %s
+# RUN: llvm-nm -S %p/Inputs/hello.obj.elf-x86_64 | FileCheck --check-prefix=NO-SIZE-SORT-PRINT-ADDR %s
+
+# SIZE-SORT-NO-ADDR: U puts
+# SIZE-SORT-NO-ADDR: 0000000000000015 T main
+
+# SIZE-SORT-PRINT-ADDR: U puts
+# SIZE-SORT-PRINT-ADDR: 0000000000000000 0000000000000015 T main
+
+# NO-SIZE-SORT-PRINT-ADDR: 0000000000000000 0000000000000015 T main
+# NO-SIZE-SORT-PRINT-ADDR: U puts
Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=351347&r1=351346&r2=351347&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Wed Jan 16 06:38:22 2019
@@ -798,8 +798,7 @@ static void sortAndPrintSymbolList(Symbo
bool Global = SymFlags & SymbolRef::SF_Global;
bool Weak = SymFlags & SymbolRef::SF_Weak;
if ((!Undefined && UndefinedOnly) || (Undefined && DefinedOnly) ||
- (!Global && ExternalOnly) || (SizeSort && !PrintAddress) ||
- (Weak && NoWeakSymbols))
+ (!Global && ExternalOnly) || (Weak && NoWeakSymbols))
continue;
if (PrintFileName)
writeFileName(outs());
More information about the llvm-commits
mailing list