diff --git a/test/Object/X86/nm-print-size.s b/test/Object/X86/nm-print-size.s index b833601969c..4aed80257ea 100644 --- a/test/Object/X86/nm-print-size.s +++ b/test/Object/X86/nm-print-size.s @@ -3,6 +3,7 @@ // CHECK: 0000000000000000 ffffffffffffffff n a // CHECK: 0000000000000000 0000000000000000 N b +// CHECK: 0000000000000004 0000000000000004 C c .section foo a: @@ -10,3 +11,5 @@ a: .global b b: + + .comm c,4,8 diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index cf674610995..4edb4efa8d0 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -901,10 +901,15 @@ static void dumpSymbolNamesFromObject(SymbolicFile &Obj, bool printName, S.Size = ELFSymbolRef(Sym).getSize(); } if (PrintAddress && isa(Obj)) { - ErrorOr AddressOrErr = SymbolRef(Sym).getAddress(); - if (error(AddressOrErr.getError())) - break; - S.Address = *AddressOrErr; + SymbolRef SymRef(Sym); + if (SymFlags & SymbolRef::SF_Common) { + S.Address = SymRef.getCommonSize(); + } else { + ErrorOr AddressOrErr = SymRef.getAddress(); + if (error(AddressOrErr.getError())) + break; + S.Address = *AddressOrErr; + } } S.TypeChar = getNMTypeChar(Obj, Sym); if (error(Sym.printName(OS)))