[llvm] r213275 - MC: correct DWARF header for PE/COFF assembly input

Saleem Abdulrasool compnerd at compnerd.org
Sat Jul 19 14:11:19 PDT 2014


On Thu, Jul 17, 2014 at 11:05 AM, Eric Christopher <echristo at gmail.com>
wrote:

> On Thu, Jul 17, 2014 at 9:27 AM, Saleem Abdulrasool
> <compnerd at compnerd.org> wrote:
> > Author: compnerd
> > Date: Thu Jul 17 11:27:44 2014
> > New Revision: 213275
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=213275&view=rev
> > Log:
> > MC: correct DWARF header for PE/COFF assembly input
> >
> > The header contains an offset to the DWARF abbreviations 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 had the correct
> emission for
> > the headers.  This corrects just the assembly path.  Due to the invalid
> > relocation, processing of the debug information would halt previously on
> the
> > first assembly input as the associated abbreviations would be out of
> range as
> > they would have the location increased by image base and the section
> offset.
> >
> > This address PR20332.
> >
> > Added:
> >     llvm/trunk/test/DebugInfo/X86/dbg-asm.s
> > Modified:
> >     llvm/trunk/lib/MC/MCDwarf.cpp
> >
> > Modified: llvm/trunk/lib/MC/MCDwarf.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=213275&r1=213274&r2=213275&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/MC/MCDwarf.cpp (original)
> > +++ llvm/trunk/lib/MC/MCDwarf.cpp Thu Jul 17 11:27:44 2014
> > @@ -657,11 +657,12 @@ static void EmitGenDwarfInfo(MCStreamer
> >
> >    // The 4 byte offset to the debug abbrevs from the start of the
> .debug_abbrev,
> >    // it is at the start of that section so this is zero.
> > -  if (AbbrevSectionSymbol) {
> > -    MCOS->EmitSymbolValue(AbbrevSectionSymbol, 4);
> > -  } else {
> > +  if (AbbrevSectionSymbol == nullptr)
> >      MCOS->EmitIntValue(0, 4);
> > -  }
> > +  else if (context.getAsmInfo()->needsDwarfSectionOffsetDirective())
> > +    MCOS->EmitCOFFSecRel32(AbbrevSectionSymbol);
> > +  else
> > +    MCOS->EmitSymbolValue(AbbrevSectionSymbol, 4);
> >
>
> Having the explicit COFF call in here is a bit weird. Can you abstract
> this out a bit?
>

As discussed offline, this is indeed less than ideal.  Addressed in SVN
r213463.  Sorry about the delay.


> Thanks!
>
> -eric
>
> >    const MCAsmInfo *asmInfo = context.getAsmInfo();
> >    int AddrSize = asmInfo->getPointerSize();
> >
> > Added: llvm/trunk/test/DebugInfo/X86/dbg-asm.s
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dbg-asm.s?rev=213275&view=auto
> >
> ==============================================================================
> > --- llvm/trunk/test/DebugInfo/X86/dbg-asm.s (added)
> > +++ llvm/trunk/test/DebugInfo/X86/dbg-asm.s Thu Jul 17 11:27:44 2014
> > @@ -0,0 +1,22 @@
> > +# RUN: llvm-mc -triple i686-windows-gnu -g %s -filetype obj -o - \
> > +# RUN:   | llvm-readobj -r - | FileCheck -check-prefix CHECK-COFF %s
> > +# RUN: llvm-mc -triple i686-windows-itanium -g %s -filetype obj -o - \
> > +# RUN:   | llvm-readobj -r - | FileCheck -check-prefix CHECK-COFF %s
> > +# RUN: llvm-mc -triple i686-linux-gnu -g %s -filetype obj -o - \
> > +# RUN:   | llvm-readobj -r - | FileCheck -check-prefix CHECK-ELF %s
> > +
> > +_a:
> > +       movl $65, %eax
> > +       ret
> > +
> > +# CHECK-COFF: Relocations [
> > +# CHECK-COFF:   Section {{.*}} .debug_info {
> > +# CHECK-COFF:     0x6 IMAGE_REL_I386_SECREL .debug_abbrev
> > +# CHECK-COFF:   }
> > +# CHECK-COFF: ]
> > +
> > +# CHECK-ELF: Relocations [
> > +# CHECK-ELF:   Section {{.*}} .rel.debug_info {
> > +# CHECK-ELF:     0x6 R_386_32 .debug_abbrev
> > +# CHECK-ELF:   }
> > +# CHECK-ELF: ]
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140719/662a303a/attachment.html>


More information about the llvm-commits mailing list