From 05f7d4f508d4a5cc690e029bd468c2af48b6a6e1 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 22 May 2015 13:28:35 +0000 Subject: [PATCH] Fix llvm-nm -S option. It is explicitly documented to have no effect on object formats where symbols don't have sizes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238019 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Object/nm-trivial-object.test | 39 ++++++++++++++++++------------ tools/llvm-nm/llvm-nm.cpp | 2 +- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/test/Object/nm-trivial-object.test b/test/Object/nm-trivial-object.test index 6e39a450670..def6549d656 100644 --- a/test/Object/nm-trivial-object.test +++ b/test/Object/nm-trivial-object.test @@ -4,6 +4,8 @@ RUN: yaml2obj %p/Inputs/COFF/x86-64.yaml | llvm-nm -a -S - \ RUN: | FileCheck %s -check-prefix COFF64 RUN: llvm-nm %p/Inputs/trivial-object-test.elf-i386 \ RUN: | FileCheck %s -check-prefix ELF +RUN: llvm-nm %p/Inputs/trivial-object-test.elf-i386 -S \ +RUN: | FileCheck %s -check-prefix ELF-SIZE RUN: llvm-nm -o %p/Inputs/trivial-object-test.elf-i386 \ RUN: | FileCheck %s -check-prefix ELF-o RUN: llvm-nm -u %p/Inputs/trivial-object-test.elf-i386 \ @@ -48,28 +50,28 @@ RUN: cp %p/Inputs/trivial-object-test.macho-i386 a.out RUN: llvm-nm | FileCheck %s -check-prefix A-OUT -COFF32: 00000000 {{.*}} d .data -COFF32-NEXT: 00000000 {{.*}} t .text -COFF32-NEXT: 00000000 0000000d d L_.str +COFF32: 00000000 d .data +COFF32-NEXT: 00000000 t .text +COFF32-NEXT: 00000000 d L_.str COFF32-NEXT: U _SomeOtherFunction -COFF32-NEXT: 00000000 {{.*}} T _main +COFF32-NEXT: 00000000 T _main COFF32-NEXT: U _puts -COFF64: 00000000 {{.*}} d .data -COFF64-NEXT: 00000000 {{.*}} t .text -COFF64-NEXT: 00000000 00000008 r ??__Ex@@YAXXZ -COFF64-NEXT: 00000000 0000000d d L.str +COFF64: 00000000 d .data +COFF64-NEXT: 00000000 t .text +COFF64-NEXT: 00000000 r ??__Ex@@YAXXZ +COFF64-NEXT: 00000000 d L.str COFF64-NEXT: U SomeOtherFunction -COFF64-NEXT: 00000000 {{.*}} T main +COFF64-NEXT: 00000000 T main COFF64-NEXT: U puts -COFF-COMMON: 00000000 00000000 b .bss -COFF-COMMON-NEXT: 00000000 00000000 d .data -COFF-COMMON-NEXT: 00000000 00000014 d .drectve -COFF-COMMON-NEXT: 00000000 00000000 n .file -COFF-COMMON-NEXT: 00000000 00000014 r .rdata$zzz -COFF-COMMON-NEXT: 00000000 00000000 t .text -COFF-COMMON-NEXT: 00000004 C _a +COFF-COMMON: 00000000 b .bss +COFF-COMMON-NEXT: 00000000 d .data +COFF-COMMON-NEXT: 00000000 d .drectve +COFF-COMMON-NEXT: 00000000 n .file +COFF-COMMON-NEXT: 00000000 r .rdata$zzz +COFF-COMMON-NEXT: 00000000 t .text +COFF-COMMON-NEXT: C _a ELF-NOT: U @@ -77,6 +79,11 @@ ELF: U SomeOtherFunction ELF: 00000000 T main ELF: U puts +FIXME: we should not print the size of undefined symbols. +ELF-SIZE: 00000000 U SomeOtherFunction +ELF-SIZE-NEXT: 00000000 00000024 T main +ELF-SIZE-NEXT: 00000000 U puts + ELF-o: {{.*}}/trivial-object-test.elf-i386: U SomeOtherFunction ELF-o: {{.*}}/trivial-object-test.elf-i386: 00000000 T main ELF-o: {{.*}}/trivial-object-test.elf-i386: U puts diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index b62b5473ae0..f3197bbfd10 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -932,7 +932,7 @@ static void dumpSymbolNamesFromObject(SymbolicFile &Obj, bool printName, NMSymbol S; S.Size = UnknownAddressOrSize; S.Address = UnknownAddressOrSize; - if ((PrintSize || SizeSort) && isa(Obj)) { + if (PrintSize && isa(Obj)) { symbol_iterator SymI = I; if (error(SymI->getSize(S.Size))) break;