Implement more alias cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115699 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp
index 7336258..d790291 100644
--- a/lib/MC/ELFObjectWriter.cpp
+++ b/lib/MC/ELFObjectWriter.cpp
@@ -807,9 +807,20 @@
     MSD.SymbolData = it;
     MSD.StringIndex = Entry;
 
+    // FIXME: There is duplicated code with the local case.
     if (it->isCommon()) {
       MSD.SectionIndex = ELF::SHN_COMMON;
       ExternalSymbolData.push_back(MSD);
+    } else if (Symbol.isVariable()) {
+      const MCExpr *Value = Symbol.getVariableValue();
+      assert (Value->getKind() == MCExpr::SymbolRef && "Unimplemented");
+      const MCSymbolRefExpr *Ref = static_cast<const MCSymbolRefExpr*>(Value);
+      const MCSymbol &RefSymbol = Ref->getSymbol();
+      if (RefSymbol.isDefined()) {
+        MSD.SectionIndex = SectionIndexMap.lookup(&RefSymbol.getSection());
+        assert(MSD.SectionIndex && "Invalid section index!");
+        ExternalSymbolData.push_back(MSD);
+      }
     } else if (Symbol.isUndefined()) {
       MSD.SectionIndex = ELF::SHN_UNDEF;
       // FIXME: Undefined symbols are global, but this is the first place we