[llvm] r241587 - Common symbols are not undefined, at least for ObjectFile.

Rafael Espindola rafael.espindola at gmail.com
Tue Jul 7 07:26:39 PDT 2015


Author: rafael
Date: Tue Jul  7 09:26:39 2015
New Revision: 241587

URL: http://llvm.org/viewvc/llvm-project?rev=241587&view=rev
Log:
Common symbols are not undefined, at least for ObjectFile.

They are implemented like that in some object formats, but for the interface
provided by lib/Object, SF_Undefined and SF_Common are different things.

This matches the ELF and COFF implementation and fixes llvm-nm for MachO.

Added:
    llvm/trunk/test/Object/X86/nm-macho.s
Modified:
    llvm/trunk/lib/Object/MachOObjectFile.cpp

Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=241587&r1=241586&r2=241587&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Tue Jul  7 09:26:39 2015
@@ -418,9 +418,6 @@ uint32_t MachOObjectFile::getSymbolFlags
 
   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
     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))

Added: llvm/trunk/test/Object/X86/nm-macho.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/X86/nm-macho.s?rev=241587&view=auto
==============================================================================
--- llvm/trunk/test/Object/X86/nm-macho.s (added)
+++ llvm/trunk/test/Object/X86/nm-macho.s Tue Jul  7 09:26:39 2015
@@ -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





More information about the llvm-commits mailing list