I have a jump table something like this:
jmp rax
@@table:
jmp @@seg1
jmp @@sge2
jmp @@seg3
...
This was working perfectly with the understanding that the jmp code is two bytes in length. I have subsequently added code to the @@seg? code segments, which is now causing a crash when jumping to "further away" code segments (labels).
I'm concluding that the longer jumps are being encoded with a greater length than 2. Unfortunately the disassembler I use stops at the jmp rax
line, so I can't confirm. But the conclusion is logical.
Is there a way to cause the compiler to align the jmp @@seg
? commands at say 4 bytes so that I have a guaranteed large enough and consistent size for the jump table? If so, I could ensure rax
increments in 4s.
I certainly don't want to start manually adding nop
's in an attempt to solve this.