Patch to a fix dwarf relocation problem on ARM. One-line fix plus the test where it used to break.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127757 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 15330c2..cb542aef 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -3272,7 +3272,9 @@
     case dwarf::DW_AT_location: {
       if (UseDotDebugLocEntry.count(Die) != 0) {
         DIELabel *L = cast<DIELabel>(Values[i]);
-        Asm->EmitLabelDifference(L->getValue(), DwarfDebugLocSectionSym, 4);
+        // Emitting reference to label directly, so the assembler can
+        // emit the relocations and the offset automatically.
+        Asm->EmitReference(L->getValue(), dwarf::DW_EH_PE_udata4);
       } else
         Values[i]->EmitValue(Asm, Form);
       break;
@@ -3623,6 +3625,7 @@
   if (DotDebugLocEntries.empty())
     return;
 
+  // Group debug entries.
   for (SmallVector<DotDebugLocEntry, 4>::iterator
          I = DotDebugLocEntries.begin(), E = DotDebugLocEntries.end();
        I != E; ++I) {
@@ -3631,7 +3634,7 @@
       Entry.Merge(I+1);
   }
 
-  // Start the dwarf loc section.
+  // Start the dwarf location section.
   Asm->OutStreamer.SwitchSection(
     Asm->getObjFileLowering().getDwarfLocSection());
   unsigned char Size = Asm->getTargetData().getPointerSize();