[PATCH] D56063: [llvm-nm] Allow --size-sort to print symbols with only Symbol size

Saurabh Badhwar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 28 23:37:01 PST 2018


h4xr updated this revision to Diff 179678.
h4xr added a comment.

Improve test cases for the --size-sort option and check for the output with --print-address enabled


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56063/new/

https://reviews.llvm.org/D56063

Files:
  test/tools/llvm-nm/X86/size-sort.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
@@ -796,8 +796,7 @@
     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());
@@ -830,7 +829,7 @@
         strcpy(SymbolAddrStr, printDashes);
       else if(MachO && I->TypeChar == 'I')
         strcpy(SymbolAddrStr, printBlanks);
-      else
+      else if(PrintAddress)
         format(printFormat, I->Address)
           .print(SymbolAddrStr, sizeof(SymbolAddrStr));
       format(printFormat, I->Size).print(SymbolSizeStr, sizeof(SymbolSizeStr));
Index: test/tools/llvm-nm/X86/size-sort.test
===================================================================
--- /dev/null
+++ test/tools/llvm-nm/X86/size-sort.test
@@ -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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56063.179678.patch
Type: text/x-patch
Size: 1842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181229/60af9101/attachment.bin>


More information about the llvm-commits mailing list