<div dir="ltr">Seems we have a few choices:<br><br>Say that getSectionLoadAddress should return 0 for all debug info sections<br>Change libDebugInfo/DWARF to not query getSectionLoadAddress for debug info sections (so they're effectively zero)<br>Change DWARFDebugAbbrev::extract to take into account the base address of the section when parsing/building the table.<br><br>I suspect 1 or 2 is better, and probably 2. But that's also a bit inconvenient having to do more special case logic about how we apply/create relocations - an already pretty complicated part of the DWARF parsing code, I think.<br><br>(+ Lang, Keno, and Eric - involved in adding this getSectionLoadAddress support in the first place. I'm guessing for the JIT use case it wouldn't have ever had a load address for a debug info section - just for the code sections?)<br><br><div class="gmail_quote"><div dir="ltr">On Tue, Dec 20, 2016 at 10:28 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="color:rgb(33,33,33);font-size:12pt" class="gmail_msg">>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.</span></p>
</div><div dir="ltr" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif" class="gmail_msg"><div style="color:rgb(33,33,33)" class="gmail_msg"><div class="gmail_msg"><div dir="ltr" class="gmail_msg"><div class="gmail_quote gmail_msg">
<div class="gmail_msg">><br class="gmail_msg">
>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 class="gmail_msg">
><br class="gmail_msg">
>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 class="gmail_msg">
><br class="gmail_msg">
>Rui: Does any of this sound familiar? Are relocations in input object memory buffers modified at some point?<br class="gmail_msg">
<br class="gmail_msg">
</div>
</div></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 style="color:rgb(33,33,33)" class="gmail_msg"><div class="gmail_msg"><div dir="ltr" class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg">I see the issue now. It is not a buffer was modified, reason is implementation of llvm::LoadedObjectInfo interface:<br class="gmail_msg">
</div>
<div class="gmail_msg">
<div class="gmail_msg">template <class ELFT><br class="gmail_msg">
</div>
<div class="gmail_msg">uint64_t GdbIndexBuilder<ELFT>::getSectionLoadAddress(</div>
<div class="gmail_msg">    const object::SectionRef &Sec) const {</div>
<div class="gmail_msg">  return static_cast<const ELFSectionRef &>(Sec).getOffset();</div>
<div class="gmail_msg">}<br class="gmail_msg">
</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
I had to implement this callback, it returns section offset as an address now. That way I can later get the proper section index
<br class="gmail_msg">
</div>
<div class="gmail_msg">in <span style="font-size:12pt" class="gmail_msg">readAddressArea(size_t CurrentCU):</span></div>
<div class="gmail_msg"><span style="font-size:12pt" class="gmail_msg"><br class="gmail_msg">
</span></div>
<div class="gmail_msg"></div></div></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 style="color:rgb(33,33,33)" class="gmail_msg"><div class="gmail_msg"><div dir="ltr" class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg">
<div class="gmail_msg">  for (const auto &CU : Dwarf->compile_units()) {</div>
</div></div></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 style="color:rgb(33,33,33)" class="gmail_msg"><div class="gmail_msg"><div dir="ltr" class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg"><div class="gmail_msg">    DWARFAddressRangesVector Ranges;</div>
<div class="gmail_msg">    CU->collectAddressRanges(Ranges);<br class="gmail_msg">
</div>
</div>
<div class="gmail_msg"><span style="font-size:12pt" class="gmail_msg">Here Ranges has [Offset + LowPC, Offset + HighPC] values then. </span></div>
<div class="gmail_msg"><span style="font-size:12pt" class="gmail_msg">So I can use them to find </span><span style="font-size:12pt" class="gmail_msg">section that range belongs to.</span></div>
<div class="gmail_msg"><span style="font-size:12pt" class="gmail_msg">Otherwise Ranges is just an offset in a section and I do not know which one exactly.</span></div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg">I do not know the other way to do that. <span style="font-size:12pt" class="gmail_msg">I tried as a
</span><span style="font-size:12pt" class="gmail_msg">different </span><span style="font-size:12pt" class="gmail_msg">solution before implementing this one:</span></div>
<div class="gmail_msg"><a href="https://reviews.llvm.org/D25822" class="gmail_msg" target="_blank">https://reviews.llvm.org/D25822,</a>​ page contains more details.<br class="gmail_msg">
</div>
<div class="gmail_msg">It was closer to how gold solves that.<br class="gmail_msg">
<br class="gmail_msg">
</div></div></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 style="color:rgb(33,33,33)" class="gmail_msg"><div class="gmail_msg"><div dir="ltr" class="gmail_msg"><div class="gmail_quote gmail_msg">
<div class="gmail_msg">George.<br class="gmail_msg">
</div>
</div></div></div></div></div></blockquote></div></div>