OSDN Git Service

MC: correct DWARF header for PE/COFF assembly input
authorSaleem Abdulrasool <compnerd@compnerd.org>
Fri, 5 Sep 2014 04:15:00 +0000 (04:15 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Fri, 5 Sep 2014 04:15:00 +0000 (04:15 +0000)
The header contains an offset to the DWARF line table for the CU.  The offset
must be section relative for COFF and absolute for others.  The non-assembly
code path for the DWARF header generation already has the correct emission for
the headers.  This corrects the assembly input path.

This was identified by BFD objecting to the LLVM generated DWARF information.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217222 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCDwarf.cpp
test/DebugInfo/X86/dbg-asm.s

index a592c09..5bc0e43 100644 (file)
@@ -693,11 +693,11 @@ static void EmitGenDwarfInfo(MCStreamer *MCOS,
 
   // DW_AT_stmt_list, a 4 byte offset from the start of the .debug_line section,
   // which is at the start of that section so this is zero.
-  if (LineSectionSymbol) {
-    MCOS->EmitSymbolValue(LineSectionSymbol, 4);
-  } else {
+  if (LineSectionSymbol)
+    MCOS->EmitSymbolValue(LineSectionSymbol, 4,
+                          AsmInfo.needsDwarfSectionOffsetDirective());
+  else
     MCOS->EmitIntValue(0, 4);
-  }
 
   if (RangesSectionSymbol) {
     // There are multiple sections containing code, so we must use the
index 66a0292..de4e8e4 100644 (file)
@@ -12,11 +12,13 @@ _a:
 # CHECK-COFF: Relocations [
 # CHECK-COFF:   Section {{.*}} .debug_info {
 # CHECK-COFF:     0x6 IMAGE_REL_I386_SECREL .debug_abbrev
+# CHECK-COFF:     0xC IMAGE_REL_I386_SECREL .debug_line
 # CHECK-COFF:   }
 # CHECK-COFF: ]
 
 # CHECK-ELF: Relocations [
 # CHECK-ELF:   Section {{.*}} .rel.debug_info {
 # CHECK-ELF:     0x6 R_386_32 .debug_abbrev
+# CHECK-ELF:     0xC R_386_32 .debug_line
 # CHECK-ELF:   }
 # CHECK-ELF: ]