<div dir="ltr">On Thu, Oct 17, 2013 at 4:04 PM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="im">On Thu, Oct 17, 2013 at 3:54 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>></span> wrote:<br>


</div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><div>On Thu, Oct 17, 2013 at 3:45 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br>



</div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="overflow:hidden">Author: ruiu<br>
Date: Thu Oct 17 17:45:16 2013<br>
New Revision: 192930<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=192930&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=192930&view=rev</a><br>
Log:<br>
Fill gap in .text with NOP.</div></blockquote></div></div><br>It almost seems like it would be better to fill with UD1 or something that won't actually execute if a stray jump lands here?</div></div></blockquote><div>


<br></div></div></div><div>The MSVC toolchain uses int3 to pad things for this reason.  I think the gnu toolchain tries to get clever and write really wide nops, since the CPU still decodes unexecuted instructions.  Not sure if it matters at all.</div>


</div></div></div>
</blockquote></div><br></div><div class="gmail_extra">I remember that in IA32/64 optimization manual published by Intel says that you could place a UD2 after a branch instruction to stop machine code decoding. Not sure if it makes sense for a gap between functions, as the last instruction is almost always unconditional branch instruction RET.</div>

<div class="gmail_extra"><br></div><div class="gmail_extra">Comparing UDx and INT 3, INT 3 looks better because it's a one byte instruction. UDx are two bytes. That means by using INT 3, we don't need to worry about some invalid jump instruction would jump in the middle of UDx.</div>

</div>