<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Dec 20, 2016 at 12:24 PM George Rimar <<a href="mailto:grimar@accesssoftek.com">grimar@accesssoftek.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif" class="gmail_msg">
<p class="gmail_msg"><span style="font-size:12pt" class="gmail_msg">From what I see it is would be very strange if lld change the input file content,</span><br class="gmail_msg">
</p>
<div class="gmail_msg">we use parsers in a very straightforward way:<br class="gmail_msg">
</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg">
<div class="gmail_msg">template <class ELFT></div>
<div class="gmail_msg">GdbIndexBuilder<ELFT>::GdbIndexBuilder(InputSection<ELFT> *DebugInfoSec)</div>
<div class="gmail_msg">    : DebugInfoSec(DebugInfoSec) {</div>
<div class="gmail_msg">  if (Expected<std::unique_ptr<object::ObjectFile>> Obj =</div>
<div class="gmail_msg">          object::ObjectFile::createObjectFile(DebugInfoSec->getFile()->MB))</div>
<div class="gmail_msg">    Dwarf.reset(new DWARFContextInMemory(*Obj.get(), this));</div>
<div class="gmail_msg">  else</div>
<div class="gmail_msg">    error(toString(DebugInfoSec->getFile()) + ": error creating DWARF context");</div>
<div class="gmail_msg">}<br class="gmail_msg">
</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
and when I compare code with/without your patch I just see that<br class="gmail_msg">
</div>
<div class="gmail_msg"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">Dwarf->compile_units()</span>​ starts to return nothing, what is a reason of fail for testcase:<br class="gmail_msg">
</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg">
<div class="gmail_msg">GdbIndexBuilder<ELFT>::readAddressArea(size_t CurrentCU) {</div>
<div class="gmail_msg">...<br class="gmail_msg">
</div>
<div class="gmail_msg">  for (const auto &CU : Dwarf->compile_units()) { // <-- HERE<br class="gmail_msg">
</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg">You wrote "Is this data somehow modified by lld rather than being the raw bytes from the input file ?",<br class="gmail_msg">
</div>
<div class="gmail_msg">I see no reasons for that now. But what I suggest - let me check that all tomorrow,<br class="gmail_msg">
</div>
<div class="gmail_msg">I'll try to debug the details. <br class="gmail_msg"></div></div></div></blockquote><div><br>The way I debugged this was to break on the line in the 'if' that my patch adds. It shows that it's adding 132 or something when run inside lld, but 0 when run in dwarfdump on the object file itself.<br><br>It looks very much like the relocation section provided to the DWARFContextInMemory in lld has adjustments applied already - it doesn't appear to be the same set of relocations as when reading the object file directly in llvm-dwarfdump.<br><br>This is why there are no CUs - they fail to parse because the abbreviations section can't be found at that offset in the input object file (I believe that's the offset in the output instead).<br><br>Rui: Does any of this sound familiar? Are relocations in input object memory buffers modified at some point?<br><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">
</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg">As far I understand is what I need - is just to recheck<br class="gmail_msg">
</div>
<div class="gmail_msg">that we pass the same data to <span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">DWARFConte</span><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">xtInMemory</span>​
<span style="font-size:12pt" class="gmail_msg">that we have in raw objects.</span></div>
</div>
<div class="gmail_msg">I would be surprised if that is not true.<br class="gmail_msg">
</div>
<p class="gmail_msg"><br class="gmail_msg">
</p>
<div id="m_2532856531817468433Signature" class="gmail_msg">
<div class="m_2532856531817468433BodyFragment gmail_msg"><font size="2" class="gmail_msg">
<div class="m_2532856531817468433PlainText gmail_msg">Best regards,<br class="gmail_msg">
George.</div>
</font></div>
</div>
<div dir="ltr" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif" class="gmail_msg">
<hr style="display:inline-block;width:98%" class="gmail_msg">
<div id="m_2532856531817468433divRplyFwdMsg" dir="ltr" class="gmail_msg"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt" class="gmail_msg"><b class="gmail_msg">От:</b> George Rimar<br class="gmail_msg">
<b class="gmail_msg">Отправлено:</b> 20 декабря 2016 г. 21:16<br class="gmail_msg">
<b class="gmail_msg">Кому:</b> David Blaikie<br class="gmail_msg">
<b class="gmail_msg">Копия:</b> Rui Ueyama; <a href="mailto:llvm-commits@lists.llvm.org" class="gmail_msg" target="_blank">llvm-commits@lists.llvm.org</a><br class="gmail_msg">
<b class="gmail_msg">Тема:</b> RE: [llvm] r289961 - Revert "dwarfdump: Support/process relocations on a CU's abbrev_off"</font>
<div class="gmail_msg"> </div>
</div></div></div><div dir="ltr" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif" class="gmail_msg"><div dir="ltr" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif" class="gmail_msg">
<div class="gmail_msg">
<p class="gmail_msg">​Hi David,<br class="gmail_msg">
</p>
<p class="gmail_msg"><br class="gmail_msg">
</p>
<p class="gmail_msg">I'll can apply this patch and take a look on this closer </p>
<p class="gmail_msg">in a next hour or two and will be able to answer then.<br class="gmail_msg">
</p>
<p class="gmail_msg">​<br class="gmail_msg">
</p>
<div id="m_2532856531817468433Signature" class="gmail_msg">
<div class="m_2532856531817468433BodyFragment gmail_msg"><font size="2" class="gmail_msg">
<div class="m_2532856531817468433PlainText gmail_msg">Best regards,<br class="gmail_msg">
George.</div>
</font></div>
</div>
<div style="color:rgb(33,33,33)" class="gmail_msg">
<hr style="display:inline-block;width:98%" class="gmail_msg">
<div id="m_2532856531817468433divRplyFwdMsg" dir="ltr" class="gmail_msg"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt" class="gmail_msg"><b class="gmail_msg">От:</b> David Blaikie <<a href="mailto:dblaikie@gmail.com" class="gmail_msg" target="_blank">dblaikie@gmail.com</a>><br class="gmail_msg">
<b class="gmail_msg">Отправлено:</b> 20 декабря 2016 г. 21:02<br class="gmail_msg">
<b class="gmail_msg">Кому:</b> <a href="mailto:llvm-commits@lists.llvm.org" class="gmail_msg" target="_blank">llvm-commits@lists.llvm.org</a>; George Rimar<br class="gmail_msg">
<b class="gmail_msg">Копия:</b> Rui Ueyama<br class="gmail_msg">
<b class="gmail_msg">Тема:</b> Re: [llvm] r289961 - Revert "dwarfdump: Support/process relocations on a CU's abbrev_off"</font>
<div class="gmail_msg"> </div>
</div>
<div class="gmail_msg">
<div dir="ltr" class="gmail_msg">Hi George,<br class="gmail_msg">
<br class="gmail_msg">
Committing this change broke your gdb-index test in lld.<br class="gmail_msg">
<br class="gmail_msg">
It looks like the info section had a non-zero offset in the relocation pointing to the abbrev section, but the abbrev section in the object has the data at start (& dumping the raw object file from disk shows the relocation has a zero offset)<br class="gmail_msg">
<br class="gmail_msg">
Is this data somehow modified by lld rather than being the raw bytes from the input file? How/why/where?<br class="gmail_msg">
<br class="gmail_msg">
Any idea how to fix this change/lld so it doesn't have this problem?<br class="gmail_msg">
<br class="gmail_msg">
As it is, dwarfdump is crashing on inputs I care about & this change seems like a reasonable fix for it, so I'm guessing we probably want to fix lld in some way?<br class="gmail_msg">
<br class="gmail_msg">
- Dave<br class="gmail_msg">
<br class="gmail_msg">
<div class="gmail_quote gmail_msg">
<div dir="ltr" class="gmail_msg">On Fri, Dec 16, 2016 at 9:20 AM David Blaikie via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="gmail_msg" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br class="gmail_msg">
</div>
<blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: dblaikie<br class="gmail_msg">
Date: Fri Dec 16 11:10:17 2016<br class="gmail_msg">
New Revision: 289961<br class="gmail_msg">
<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=289961&view=rev" rel="noreferrer" class="gmail_msg" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=289961&view=rev</a><br class="gmail_msg">
Log:<br class="gmail_msg">
Revert "dwarfdump: Support/process relocations on a CU's abbrev_off"<br class="gmail_msg">
<br class="gmail_msg">
Reverting because this breaks lld's gdb_index support - it's probably<br class="gmail_msg">
double counting the abbrev relocation offset.<br class="gmail_msg">
<br class="gmail_msg">
This reverts commit r289954.<br class="gmail_msg">
<br class="gmail_msg">
Removed:<br class="gmail_msg">
    llvm/trunk/test/DebugInfo/Inputs/dwarfdump-abbrev-off.elf-x86-64<br class="gmail_msg">
    llvm/trunk/test/DebugInfo/dwarfdump-abbrev-off.test<br class="gmail_msg">
Modified:<br class="gmail_msg">
    llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=289961&r1=289960&r2=289961&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=289961&r1=289960&r2=289961&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp (original)<br class="gmail_msg">
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp Fri Dec 16 11:10:17 2016<br class="gmail_msg">
@@ -87,10 +87,7 @@ bool DWARFUnit::getStringOffsetSectionIt<br class="gmail_msg">
 bool DWARFUnit::extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) {<br class="gmail_msg">
   Length = debug_info.getU32(offset_ptr);<br class="gmail_msg">
   Version = debug_info.getU16(offset_ptr);<br class="gmail_msg">
-  auto AI = InfoSection.Relocs.find(*offset_ptr);<br class="gmail_msg">
   uint64_t AbbrOffset = debug_info.getU32(offset_ptr);<br class="gmail_msg">
-  if (AI != InfoSection.Relocs.end())<br class="gmail_msg">
-    AbbrOffset += AI->second.second;<br class="gmail_msg">
   if (IndexEntry) {<br class="gmail_msg">
     if (AbbrOffset)<br class="gmail_msg">
       return false;<br class="gmail_msg">
<br class="gmail_msg">
Removed: llvm/trunk/test/DebugInfo/Inputs/dwarfdump-abbrev-off.elf-x86-64<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/dwarfdump-abbrev-off.elf-x86-64?rev=289960&view=auto" rel="noreferrer" class="gmail_msg" target="_blank">
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/dwarfdump-abbrev-off.elf-x86-64?rev=289960&view=auto</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
Binary files llvm/trunk/test/DebugInfo/Inputs/dwarfdump-abbrev-off.elf-x86-64 (original) and llvm/trunk/test/DebugInfo/Inputs/dwarfdump-abbrev-off.elf-x86-64 (removed) differ<br class="gmail_msg">
<br class="gmail_msg">
Removed: llvm/trunk/test/DebugInfo/dwarfdump-abbrev-off.test<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwarfdump-abbrev-off.test?rev=289960&view=auto" rel="noreferrer" class="gmail_msg" target="_blank">
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwarfdump-abbrev-off.test?rev=289960&view=auto</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/test/DebugInfo/dwarfdump-abbrev-off.test (original)<br class="gmail_msg">
+++ llvm/trunk/test/DebugInfo/dwarfdump-abbrev-off.test (removed)<br class="gmail_msg">
@@ -1,8 +0,0 @@<br class="gmail_msg">
-RUN: llvm-dwarfdump -debug-dump=info %p/Inputs/dwarfdump-abbrev-off.elf-x86-64 | FileCheck %s<br class="gmail_msg">
-<br class="gmail_msg">
-Check that we apply relocations to the abbr_offset - while LLVM never produces<br class="gmail_msg">
-an object file like this, a reproduction can be produced by linking two simple<br class="gmail_msg">
-object files together with ld -r.<br class="gmail_msg">
-<br class="gmail_msg">
-CHECK: abbr_offset = 0x0000<br class="gmail_msg">
-CHECK: abbr_offset = 0x0010<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
llvm-commits mailing list<br class="gmail_msg">
<a href="mailto:llvm-commits@lists.llvm.org" class="gmail_msg" target="_blank">llvm-commits@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class="gmail_msg">
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div></div></blockquote></div></div>