I've also seen:
call 1f
1: <next instruction>So commonly I hadn't considered that people thought getting the EIP on x86 was an obstacle.
call 1f
1: <next instruction>So commonly I hadn't considered that people thought getting the EIP on x86 was an obstacle.
> call 1f > > 1: <next instruction>
It's worth noting that "call $+5" degrades performance if used improperly. Consider:
call 1f
1:
pop %eax
See the problem? (Hint: it's branch prediction)That's right! The CPU has its own idea of an approximate "call stack" (a.k.a. return stack buffer), which it uses to predict branch target for RETs.
Note that the POP doesn't count as a "return," so it usually does not pop from the return stack buffer at all. In this case, the CPU confidently mispredicts the branch when the next matching RET gets queued into the pipeline, sometimes severly degrading performance.