<div dir="ltr">On Sat, Jul 19, 2014 at 2:18 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">source level debug info does this (in DwarfUnit.cpp) with this:<br>
<br>
 Asm->EmitSectionOffset(ASectionSym, ASectionSym);<br>
<br>
should we just do the same thing for asm debug info?</blockquote><div><br></div><div>I don't immediately see how we could immediately sink that functionality into the MC layer.  That is emitted as utility functions in the AsmPrinter, emitting labels at the appropriate locations and then constructing the appropriate MCExpr statements corresponding section relative differences.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
On Sat, Jul 19, 2014 at 2:11 PM, Saleem Abdulrasool<br>
<<a href="mailto:compnerd@compnerd.org">compnerd@compnerd.org</a>> wrote:<br>
> On Thu, Jul 17, 2014 at 11:05 AM, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>><br>
> wrote:<br>
>><br>
>> On Thu, Jul 17, 2014 at 9:27 AM, Saleem Abdulrasool<br>
>> <<a href="mailto:compnerd@compnerd.org">compnerd@compnerd.org</a>> wrote:<br>
>> > Author: compnerd<br>
>> > Date: Thu Jul 17 11:27:44 2014<br>
>> > New Revision: 213275<br>
>> ><br>
>> > URL: <a href="http://llvm.org/viewvc/llvm-project?rev=213275&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=213275&view=rev</a><br>
>> > Log:<br>
>> > MC: correct DWARF header for PE/COFF assembly input<br>
>> ><br>
>> > The header contains an offset to the DWARF abbreviations for the CU.<br>
>> > The offset<br>
>> > must be section relative for COFF and absolute for others.  The<br>
>> > non-assembly<br>
>> > code path for the DWARF header generation already had the correct<br>
>> > emission for<br>
>> > the headers.  This corrects just the assembly path.  Due to the invalid<br>
>> > relocation, processing of the debug information would halt previously on<br>
>> > the<br>
>> > first assembly input as the associated abbreviations would be out of<br>
>> > range as<br>
>> > they would have the location increased by image base and the section<br>
>> > offset.<br>
>> ><br>
>> > This address PR20332.<br>
>> ><br>
>> > Added:<br>
>> >     llvm/trunk/test/DebugInfo/X86/dbg-asm.s<br>
>> > Modified:<br>
>> >     llvm/trunk/lib/MC/MCDwarf.cpp<br>
>> ><br>
>> > Modified: llvm/trunk/lib/MC/MCDwarf.cpp<br>
>> > URL:<br>
>> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=213275&r1=213274&r2=213275&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=213275&r1=213274&r2=213275&view=diff</a><br>

>> ><br>
>> > ==============================================================================<br>
>> > --- llvm/trunk/lib/MC/MCDwarf.cpp (original)<br>
>> > +++ llvm/trunk/lib/MC/MCDwarf.cpp Thu Jul 17 11:27:44 2014<br>
>> > @@ -657,11 +657,12 @@ static void EmitGenDwarfInfo(MCStreamer<br>
>> ><br>
>> >    // The 4 byte offset to the debug abbrevs from the start of the<br>
>> > .debug_abbrev,<br>
>> >    // it is at the start of that section so this is zero.<br>
>> > -  if (AbbrevSectionSymbol) {<br>
>> > -    MCOS->EmitSymbolValue(AbbrevSectionSymbol, 4);<br>
>> > -  } else {<br>
>> > +  if (AbbrevSectionSymbol == nullptr)<br>
>> >      MCOS->EmitIntValue(0, 4);<br>
>> > -  }<br>
>> > +  else if (context.getAsmInfo()->needsDwarfSectionOffsetDirective())<br>
>> > +    MCOS->EmitCOFFSecRel32(AbbrevSectionSymbol);<br>
>> > +  else<br>
>> > +    MCOS->EmitSymbolValue(AbbrevSectionSymbol, 4);<br>
>> ><br>
>><br>
>> Having the explicit COFF call in here is a bit weird. Can you abstract<br>
>> this out a bit?<br>
><br>
><br>
> As discussed offline, this is indeed less than ideal.  Addressed in SVN<br>
> r213463.  Sorry about the delay.<br>
><br>
>><br>
>> Thanks!<br>
>><br>
>> -eric<br>
>><br>
>> >    const MCAsmInfo *asmInfo = context.getAsmInfo();<br>
>> >    int AddrSize = asmInfo->getPointerSize();<br>
>> ><br>
>> > Added: llvm/trunk/test/DebugInfo/X86/dbg-asm.s<br>
>> > URL:<br>
>> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dbg-asm.s?rev=213275&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dbg-asm.s?rev=213275&view=auto</a><br>

>> ><br>
>> > ==============================================================================<br>
>> > --- llvm/trunk/test/DebugInfo/X86/dbg-asm.s (added)<br>
>> > +++ llvm/trunk/test/DebugInfo/X86/dbg-asm.s Thu Jul 17 11:27:44 2014<br>
>> > @@ -0,0 +1,22 @@<br>
>> > +# RUN: llvm-mc -triple i686-windows-gnu -g %s -filetype obj -o - \<br>
>> > +# RUN:   | llvm-readobj -r - | FileCheck -check-prefix CHECK-COFF %s<br>
>> > +# RUN: llvm-mc -triple i686-windows-itanium -g %s -filetype obj -o - \<br>
>> > +# RUN:   | llvm-readobj -r - | FileCheck -check-prefix CHECK-COFF %s<br>
>> > +# RUN: llvm-mc -triple i686-linux-gnu -g %s -filetype obj -o - \<br>
>> > +# RUN:   | llvm-readobj -r - | FileCheck -check-prefix CHECK-ELF %s<br>
>> > +<br>
>> > +_a:<br>
>> > +       movl $65, %eax<br>
>> > +       ret<br>
>> > +<br>
>> > +# CHECK-COFF: Relocations [<br>
>> > +# CHECK-COFF:   Section {{.*}} .debug_info {<br>
>> > +# CHECK-COFF:     0x6 IMAGE_REL_I386_SECREL .debug_abbrev<br>
>> > +# CHECK-COFF:   }<br>
>> > +# CHECK-COFF: ]<br>
>> > +<br>
>> > +# CHECK-ELF: Relocations [<br>
>> > +# CHECK-ELF:   Section {{.*}} .rel.debug_info {<br>
>> > +# CHECK-ELF:     0x6 R_386_32 .debug_abbrev<br>
>> > +# CHECK-ELF:   }<br>
>> > +# CHECK-ELF: ]<br>
>> ><br>
>> ><br>
>> > _______________________________________________<br>
>> > llvm-commits mailing list<br>
>> > <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
>> > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
><br>
><br>
><br>
> --<br>
> Saleem Abdulrasool<br>
> compnerd (at) compnerd (dot) org<br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org
</div></div>