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
This commit is contained in:
Rafael Espindola 2015-05-22 13:28:35 +00:00
parent c6174adb16
commit 05f7d4f508
2 changed files with 24 additions and 17 deletions

View File

@ -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

View File

@ -932,7 +932,7 @@ static void dumpSymbolNamesFromObject(SymbolicFile &Obj, bool printName,
NMSymbol S;
S.Size = UnknownAddressOrSize;
S.Address = UnknownAddressOrSize;
if ((PrintSize || SizeSort) && isa<ObjectFile>(Obj)) {
if (PrintSize && isa<ELFObjectFileBase>(Obj)) {
symbol_iterator SymI = I;
if (error(SymI->getSize(S.Size)))
break;