[PATCH] D30886: [ELF] Pad x86 executable sections with 0xcc int3 instructions

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 13 05:20:25 PDT 2017


jhenderson created this revision.

See PR32227 <http://bugs.llvm.org/show_bug.cgi?id=32227>. Executable sections should not be padded with zero by default. On some architectures, 0x00 is the start of a valid instruction sequence, so can confuse disassembly between InputSections (and indeed the start of the next InputSection in some situations). Further, in the case of misjumps into padding, padding may start to be executed silently.

On x86, the "0xcc" byte represents the int3 trap instruction. It is a single byte long so can serve well as padding. This change switches x86 (and x86_64) to use this value for padding in executable sections, if no linker script directive overrides it. It also puts the behaviour into place making it easy to change the behaviour of other targets when desired. I do not know the relevant instruction sequences for trap instructions on other targets however, so somebody should add this separately.


https://reviews.llvm.org/D30886

Files:
  ELF/OutputSections.cpp
  ELF/Target.cpp
  ELF/Target.h
  test/ELF/default-fill.s
  test/ELF/linkerscript/excludefile.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30886.91539.patch
Type: text/x-patch
Size: 3610 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170313/adbfaf43/attachment.bin>


More information about the llvm-commits mailing list