diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp index ce565313455..54e4624af13 100644 --- a/lib/Object/MachOObjectFile.cpp +++ b/lib/Object/MachOObjectFile.cpp @@ -418,9 +418,6 @@ uint32_t MachOObjectFile::getSymbolFlags(DataRefImpl DRI) const { uint32_t Result = SymbolRef::SF_None; - if ((MachOType & MachO::N_TYPE) == MachO::N_UNDF) - Result |= SymbolRef::SF_Undefined; - if ((MachOType & MachO::N_TYPE) == MachO::N_INDR) Result |= SymbolRef::SF_Indirect; @@ -432,6 +429,8 @@ uint32_t MachOObjectFile::getSymbolFlags(DataRefImpl DRI) const { if ((MachOType & MachO::N_TYPE) == MachO::N_UNDF) { if (getNValue(DRI)) Result |= SymbolRef::SF_Common; + else + Result |= SymbolRef::SF_Undefined; } if (!(MachOType & MachO::N_PEXT)) diff --git a/test/Object/X86/nm-macho.s b/test/Object/X86/nm-macho.s new file mode 100644 index 00000000000..7bdfa34ca36 --- /dev/null +++ b/test/Object/X86/nm-macho.s @@ -0,0 +1,9 @@ +// RUN: llvm-mc %s -o %t -filetype=obj -triple=x86_64-apple-darwin +// RUN: llvm-nm -n %t | FileCheck %s +// CHECK: 0000000000000000 t _f +// CHECK: 0000000000000004 C _a + +_f: + retq + + .comm _a,4