<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=koi8-r">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;">>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 style="color: rgb(33, 33, 33);">
<div>
<div dir="ltr">
<div class="gmail_quote">
<div>><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>
<div>I see the issue now. It is not a buffer was modified, reason is implementation of llvm::LoadedObjectInfo interface:<br>
</div>
<div>
<div>template <class ELFT><br>
</div>
<div>uint64_t GdbIndexBuilder<ELFT>::getSectionLoadAddress(</div>
<div>    const object::SectionRef &Sec) const {</div>
<div>  return static_cast<const ELFSectionRef &>(Sec).getOffset();</div>
<div>}<br>
</div>
<div><br>
</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>
</div>
<div>in <span style="font-size: 12pt;">readAddressArea(size_t CurrentCU):</span></div>
<div><span style="font-size: 12pt;"><br>
</span></div>
<div>
<div>  for (const auto &CU : Dwarf->compile_units()) {</div>
<div>    DWARFAddressRangesVector Ranges;</div>
<div>    CU->collectAddressRanges(Ranges);<br>
</div>
</div>
<div><span style="font-size: 12pt;">Here Ranges has [Offset + LowPC, Offset + HighPC] values then. </span></div>
<div><span style="font-size: 12pt;">So I can use them to find </span><span style="font-size: 12pt;">section that range belongs to.</span></div>
<div><span style="font-size: 12pt;">Otherwise Ranges is just an offset in a section and I do not know which one exactly.</span></div>
<div><br>
</div>
<div>I do not know the other way to do that. <span style="font-size: 12pt;">I tried as a
</span><span style="font-size: 12pt;">different </span><span style="font-size: 12pt;">solution before implementing this one:</span></div>
<div><a href="https://reviews.llvm.org/D25822">https://reviews.llvm.org/D25822,</a>​ page contains more details.<br>
</div>
<div>It was closer to how gold solves that.<br>
<br>
</div>
<div>George.<br>
</div>
</div>
</div>
</div>
</div>
</body>
</html>