[lld] r192930 - Fill gap in .text with NOP.

Rui Ueyama ruiu at google.com
Thu Oct 17 16:13:37 PDT 2013


On Thu, Oct 17, 2013 at 4:04 PM, Reid Kleckner <rnk at google.com> wrote:

> On Thu, Oct 17, 2013 at 3:54 PM, Chandler Carruth <chandlerc at google.com>wrote:
>
>>
>> On Thu, Oct 17, 2013 at 3:45 PM, Rui Ueyama <ruiu at google.com> wrote:
>>
>>> Author: ruiu
>>> Date: Thu Oct 17 17:45:16 2013
>>> New Revision: 192930
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=192930&view=rev
>>> Log:
>>> Fill gap in .text with NOP.
>>>
>>
>> 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?
>>
>
> 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.
>

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.

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131017/7637b212/attachment.html>


More information about the llvm-commits mailing list