How does hardware and compiler deal with an x86 instruction that crosses into a non-executable page?
Unlike (most) RISC arch, x86 instructions have variable length. The start/end of an instruction doesn't have to aligned. If the compiler doesn't one instruction could be just lying across the page margin.
Assume that if the first byte of an instruction is at the last byte of a page, which is mar开发者_开发技巧ked as executable. The rest bytes of the instruction are at the second page, which is marked as non-executable.
In such case, what will happen in the CPU when the execution reaches this instruction?
Does compiler need to care such cases?
Hardware will (should, haven't tested) generate a GPF.
Compiler shouldn't care.
精彩评论