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@gmail.com>
Reviewers: enderby, rupprecht
Reviewed By: rupprecht
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D56063
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351347
91177308-0d34-0410-b5e6-
96231b3b80d8
--- /dev/null
+# 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
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());