[llvm-commits] [llvm] r115795 - in /llvm/trunk: lib/MC/ELFObjectWriter.cpp lib/MC/MCELFStreamer.cpp test/MC/ELF/weak.s

Rafael Espindola rafael.espindola at gmail.com
Wed Oct 6 09:47:31 PDT 2010


Author: rafael
Date: Wed Oct  6 11:47:31 2010
New Revision: 115795

URL: http://llvm.org/viewvc/llvm-project?rev=115795&view=rev
Log:
Make sure weak symbols are listed after the local ones.

Modified:
    llvm/trunk/lib/MC/ELFObjectWriter.cpp
    llvm/trunk/lib/MC/MCELFStreamer.cpp
    llvm/trunk/test/MC/ELF/weak.s

Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=115795&r1=115794&r2=115795&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Wed Oct  6 11:47:31 2010
@@ -512,8 +512,9 @@
   for (unsigned i = 0, e = ExternalSymbolData.size(); i != e; ++i) {
     ELFSymbolData &MSD = ExternalSymbolData[i];
     MCSymbolData &Data = *MSD.SymbolData;
-    assert((Data.getFlags() & ELF_STB_Global) &&
-           "External symbol requires STB_GLOBAL flag");
+    assert(((Data.getFlags() & ELF_STB_Global) ||
+            (Data.getFlags() & ELF_STB_Weak)) &&
+           "External symbol requires STB_GLOBAL or STB_WEAK flag");
     WriteSymbol(F, MSD, Layout);
     if (GetBinding(Data) == ELF::STB_LOCAL)
       LastLocalSymbolIndex++;

Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=115795&r1=115794&r2=115795&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCELFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCELFStreamer.cpp Wed Oct  6 11:47:31 2010
@@ -272,6 +272,7 @@
   case MCSA_WeakReference:
   case MCSA_Weak:
     SetBinding(SD, ELF::STB_WEAK);
+    SD.setExternal(true);
     BindingExplicitlySet.insert(Symbol);
     break;
 

Modified: llvm/trunk/test/MC/ELF/weak.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/weak.s?rev=115795&r1=115794&r2=115795&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/weak.s (original)
+++ llvm/trunk/test/MC/ELF/weak.s Wed Oct  6 11:47:31 2010
@@ -5,6 +5,20 @@
 	.weak	foo
         .long   foo
 
+// And that bar is after all local symbols
+        .weak bar
+bar:
+
+//CHECK:        # Symbol 4
+//CHECK-NEXT:   (('st_name', 5) # 'bar'
+//CHECK-NEXT:    ('st_bind', 2)
+//CHECK-NEXT:    ('st_type', 0)
+//CHECK-NEXT:    ('st_other', 0)
+//CHECK-NEXT:    ('st_shndx', 1)
+//CHECK-NEXT:    ('st_value', 0)
+//CHECK-NEXT:    ('st_size', 0)
+//CHECK-NEXT:   ),
+//CHECK-NEXT:   # Symbol 5
 //CHECK:       (('st_name', 1) # 'foo'
 //CHECK-NEXT:   ('st_bind', 2)
 //CHECK-NEXT:   ('st_type', 0)
@@ -12,3 +26,5 @@
 //CHECK-NEXT:   ('st_shndx', 0)
 //CHECK-NEXT:   ('st_value', 0)
 //CHECK-NEXT:   ('st_size', 0)
+//CHECK-NEXT:  ),
+//CHECK-NEXT: ])





More information about the llvm-commits mailing list