<div dir="ltr">But I can't think of a reason that valgrind needs executable data segment. It is likely that valgrind assumes some specific segment layout that the GNU linker creates and can't handle other layout even if it is valid.<br></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Apr 5, 2018 at 3:21 PM Rui Ueyama <<a href="mailto:ruiu@google.com">ruiu@google.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">--rosegment puts read-only data and executable text in a single segment and make it executable, so your read-only code becomes executable. I think that shouldn't be a default behavior. If valgrind needs that, we can't fix it by changing the default.<br><br><div class="gmail_quote"><div dir="ltr">On Thu, Apr 5, 2018 at 2:50 PM Andrew Kelley via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</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"><div>Confirmed that -no-rosegment worked around the issue.<br><br></div>However, a valgrind developer says that perhaps LLD is generating strange object files:<br><br><tomhughes> I suspect that is some extra ro segment in addition to the normal rodata<br><tomhughes> so without it you have two<br><tomhughes> but I know nothing about lld<br><tomhughes> but without an executable to examine/test it's hard to be sure<br><andrewrk> the not working elf file has only 1 .rodata section<br><andrewrk> here's the difference between bad and good headers: <a href="https://clbin.com/vvB8O" target="_blank">https://clbin.com/vvB8O</a><br><tomhughes> ah I see it's because it's a mapped ro segment in the phdrs<br><tomhughes> don't think it's the problem but this file is quite odd - the ro segment in the phdrs doesn't seem to have to any section listed in the shdrs<br><tomhughes> s/have/map/<br><div><div><div class="gmail_extra"><br></div><div class="gmail_extra">Is this something where LLD can be reasonably changed to be compatible with valgrind without this workaround?<br><br></div><div class="gmail_extra">Thanks,<br></div><div class="gmail_extra">Andrew<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 5, 2018 at 5:28 PM, Andrew Kelley <span dir="ltr"><<a href="mailto:superjoe30@gmail.com" target="_blank">superjoe30@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>As a frontend, what are the downsides of enabling --no-rosegment by default?<br><br></div><div>So far the pro list is:<br></div><div> * valgrind debug info will work by default<br><br></div><div>What's on the con list?<br></div><div><div class="m_-1856788636211231988m_-2122909633160941005gmail-h5"><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 5, 2018 at 5:16 PM, Shoaib Meenai <span dir="ltr"><<a href="mailto:smeenai@fb.com" target="_blank">smeenai@fb.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-US">
<div class="m_-1856788636211231988m_-2122909633160941005gmail-m_-4491447127625396845m_-1756913145478988886WordSection1">
<p class="MsoNormal">It's more of a valgrind issue than an LLD issue, but you can work around it by linking with --no-rosegment<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border-color:rgb(181,196,223) currentcolor currentcolor;border-style:solid none none;border-width:1pt medium medium;padding:3pt 0in 0in">
<p class="MsoNormal" style="margin-left:0.5in"><b><span style="font-size:12pt;color:black">From:
</span></b><span style="font-size:12pt;color:black">llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>> on behalf of Andrew Kelley via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Reply-To: </b>Andrew Kelley <<a href="mailto:superjoe30@gmail.com" target="_blank">superjoe30@gmail.com</a>><br>
<b>Date: </b>Thursday, April 5, 2018 at 2:14 PM<br>
<b>To: </b>LLVM Dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject: </b>[llvm-dev] can valgrind read LLD's debug info?<u></u><u></u></span></p>
</div><span>
<div>
<p class="MsoNormal" style="margin-left:0.5in"><u></u> <u></u></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-right:0in;margin-bottom:12pt;margin-left:0.5in">
<a name="m_-1856788636211231988_m_-2122909633160941005_m_-4491447127625396845_m_-1756913145478988886__MailOriginalBody">I just filed </a><a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D37021&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=LOIzu9sn31pmykUwYH1_wAigCpxv33qUDNdmOrmGop4&s=2_EmscX6fjQZR0pF1CQWKUPDgpBLCJhFfnOvlkivJBE&e=" target="_blank"><span>https://bugs.llvm.org/show_bug.cgi?id=37021</span><span></span></a><span><u></u><u></u></span></p>
</div>
<p class="MsoNormal" style="margin-right:0in;margin-bottom:12pt;margin-left:0.5in">
<span>There was another bug that seems related to this which is
</span><a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D35032&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=LOIzu9sn31pmykUwYH1_wAigCpxv33qUDNdmOrmGop4&s=c8bjnWV_NwOLITc1Tc5dCjJC88BhCt86girLjAbXTbk&e=" target="_blank"><span>https://bugs.llvm.org/show_bug.cgi?id=35032</span><span></span></a><span>
 but that one is marked fixed. But this seems to be an issue in trunk.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:0.5in"><span>Is this a known issue?<u></u><u></u></span></p>
</div>
</div>
</span></div>
</div>

</blockquote></div><br></div></div></div></div></div></div>
</blockquote></div><br></div></div></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div></blockquote></div>