[llvm-commits] [llvm] r117735 - in /llvm/trunk: lib/MC/ELFObjectWriter.cpp test/MC/ELF/alias.s test/MC/ELF/size.s test/MC/ELF/undef.s

Rafael Espindola rafael.espindola at gmail.com
Fri Oct 29 16:09:32 PDT 2010


Author: rafael
Date: Fri Oct 29 18:09:31 2010
New Revision: 117735

URL: http://llvm.org/viewvc/llvm-project?rev=117735&view=rev
Log:
Be more strict on when we produce an undefined reference. In gas a file with
just

.type   foo, at object

will produce an undefined reference to foo. On the other hand, a file with
just

.weakref bar, foo

will not. It is somewhat hard to support both in MC since both statements
should create the symbols. It should be possible if we really need to by
adding to the flags, but hopefully that is not necessary.

With this patch we do not produce a undefined reference in any of those cases.
The assembly file needs an actual use for the undefined reference to be
present.

This is in preparation for a patch implementing .weakref.

Modified:
    llvm/trunk/lib/MC/ELFObjectWriter.cpp
    llvm/trunk/test/MC/ELF/alias.s
    llvm/trunk/test/MC/ELF/size.s
    llvm/trunk/test/MC/ELF/undef.s

Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=117735&r1=117734&r2=117735&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Fri Oct 29 18:09:31 2010
@@ -868,8 +868,11 @@
 
   const MCSymbol &Symbol = Data.getSymbol();
 
+  if (Symbol.getName() == "_GLOBAL_OFFSET_TABLE_")
+    return true;
+
   const MCSymbol &A = AliasedSymbol(Symbol);
-  if (&A != &Symbol && A.isUndefined())
+  if (!A.isVariable() && A.isUndefined() && !Data.isCommon())
     return false;
 
   if (!Asm.isSymbolLinkerVisible(Symbol) && !Symbol.isUndefined())

Modified: llvm/trunk/test/MC/ELF/alias.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/alias.s?rev=117735&r1=117734&r2=117735&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/alias.s (original)
+++ llvm/trunk/test/MC/ELF/alias.s Fri Oct 29 18:09:31 2010
@@ -15,6 +15,7 @@
 foo4:
 bar4 = foo4
 
+        .long foo2
 // CHECK:       # Symbol 0x00000001
 // CHECK-NEXT:  (('st_name', 0x00000005) # 'bar'
 // CHECK-NEXT:   ('st_bind', 0x00000000)

Modified: llvm/trunk/test/MC/ELF/size.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/size.s?rev=117735&r1=117734&r2=117735&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/size.s (original)
+++ llvm/trunk/test/MC/ELF/size.s Fri Oct 29 18:09:31 2010
@@ -6,4 +6,5 @@
 // CHECK-NEXT:    (('st_name', 0x00000001) # 'foo'
 // CHECK-NEXT:     ('st_bind', 0x00000001)
 
-	.size	foo, .Lbar-foo
+	.size foo, .Lbar-foo
+        .long foo

Modified: llvm/trunk/test/MC/ELF/undef.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/undef.s?rev=117735&r1=117734&r2=117735&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/undef.s (original)
+++ llvm/trunk/test/MC/ELF/undef.s Fri Oct 29 18:09:31 2010
@@ -10,6 +10,7 @@
 
 	.type	.Lsym5, at object
         .type   sym6, at object
+        .long sym6
 
 	.section	.rodata.str1.1,"aMS", at progbits,1
 .Lsym7:





More information about the llvm-commits mailing list