<div dir="ltr">Filed as <a href="http://bugs.llvm.org/show_bug.cgi?id=32227">http://bugs.llvm.org/show_bug.cgi?id=32227</a>.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 10, 2017 at 10:02 AM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Yes, I think we should fill gaps in executable sections with 0xcc (or an equivalent instruction for each arch) by default. LLD supports linker script's `=FILLEXP`, but in order to use that you also specify the entire section layout, which you probably don't want to do.</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 10, 2017 at 9:22 AM, Hal Finkel via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><span>
<p><br>
</p>
<div class="m_-92892105380760747m_-5582163343402506840moz-cite-prefix">On 03/10/2017 10:19 AM, James Henderson
via llvm-dev wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>
<div>
<div>Hi,<br>
<br>
</div>
I was doing some experiments with LLD and noticed that it
pads out OutputSections with null bytes in all cases (as far
as I could tell). However, for executable sections on some
targets, 0x00 forms part of an executable instruction that
is not nop. In particular, for x86_64 targets at least, the
sequence 0x00 0x00 is an add instruction. This can result in
confusing disassembly.<br>
<br>
</div>
For example, on x86_64, given a simple InputSection that is a
single "0xc3 retq" instruction, and given an alignment of 16
bytes, 15 null bytes are inserted between the end of that
InputSection and the next. In the disassembly I then see the
retq instruction followed by a series of adds, the last of
which actually consumes 1 or more bytes of the next section to
form a valid instruction, which can in turn throw off the
disassembly of the following instructions at the start of the
next section.<br>
<br>
What do people think about using a target-specific nop
instruction sequence to pad executable sections? Another
possible option, on x86_64 at least (I haven't investigated
other targets), is to use the 0xcc interrupt instruction.<br>
</div>
</div>
</blockquote>
<br></span>
As I understand it, filling with nops has undesirable security
consequences. As you suggest, using some trap sequence is probably
better.<br>
<br>
-Hal <br>
<br>
<blockquote type="cite">
<div dir="ltr">
<div><br>
</div>
<div>Regards,<br>
<br>
</div>
<div>James<br>
</div>
</div>
<br>
<fieldset class="m_-92892105380760747m_-5582163343402506840mimeAttachmentHeader"></fieldset>
<br>
<pre>______________________________<wbr>_________________
LLVM Developers mailing list
<a class="m_-92892105380760747m_-5582163343402506840moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a class="m_-92892105380760747m_-5582163343402506840moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><span class="m_-92892105380760747HOEnZb"><font color="#888888">
</font></span></pre><span class="m_-92892105380760747HOEnZb"><font color="#888888">
</font></span></blockquote><span class="m_-92892105380760747HOEnZb"><font color="#888888">
<br>
<pre class="m_-92892105380760747m_-5582163343402506840moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</font></span></div>
<br>______________________________<wbr>_________________<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/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>