From 7da07d7834e7dea96d1b89aa1bdeb2420e9ce7b8 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 5 Sep 2014 04:15:00 +0000 Subject: [PATCH] MC: correct DWARF header for PE/COFF assembly input 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 | 8 ++++---- test/DebugInfo/X86/dbg-asm.s | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/MC/MCDwarf.cpp b/lib/MC/MCDwarf.cpp index a592c094655..5bc0e43f59d 100644 --- a/lib/MC/MCDwarf.cpp +++ b/lib/MC/MCDwarf.cpp @@ -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 diff --git a/test/DebugInfo/X86/dbg-asm.s b/test/DebugInfo/X86/dbg-asm.s index 66a0292461d..de4e8e4a97b 100644 --- a/test/DebugInfo/X86/dbg-asm.s +++ b/test/DebugInfo/X86/dbg-asm.s @@ -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: ] -- 2.34.1