wuxb
wuxb

Reputation: 2612

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 marked 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?

Upvotes: 6

Views: 224

Answers (1)

ninjalj
ninjalj

Reputation: 43698

Hardware will (should, haven't tested) generate a GPF.

Compiler shouldn't care.

Upvotes: 5

Related Questions