Fix for ARM weak symbols, patch by Lauro Ramos Venancio!
[oota-llvm.git] / lib / Target / ARM / ARMAsmPrinter.cpp
index d4c6634214a0c6cfb9d748a83c6f6234d0397c33..653d5007ab98cfb0acbdf45153c440e7d7ebebd5 100644 (file)
@@ -111,6 +111,20 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   // Print out constants referenced by the function
   EmitConstantPool(MF.getConstantPool());
 
+  const std::vector<MachineConstantPoolEntry>
+    &CP = MF.getConstantPool()->getConstants();
+  for (unsigned i = 0, e = CP.size(); i != e; ++i) {
+    MachineConstantPoolEntry CPE = CP[i];
+    if (!CPE.isMachineConstantPoolEntry()){
+      Constant *CV = CPE.Val.ConstVal;
+      if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) {
+        if (GV->hasExternalWeakLinkage()) {
+          ExtWeakSymbols.insert(GV);
+        }
+      }
+    }
+  }
+
   // Print out jump tables referenced by the function
   EmitJumpTableInfo(MF.getJumpTableInfo(), MF);