* Patch in a short jmp instruction. */
| 367 | * Patch in a short jmp instruction. |
| 368 | */ |
| 369 | static void patchShortJump(Patch *P, intptr_t addr) |
| 370 | { |
| 371 | intptr_t diff = addr - (P->I->addr + /*sizeof(short jmp)=*/2); |
| 372 | assert(diff >= INT8_MIN && diff <= INT8_MAX); |
| 373 | int8_t rel8 = (int8_t)diff; |
| 374 | |
| 375 | uint8_t *bytes = P->I->PATCH, |
| 376 | *state = P->I->STATE; |
| 377 | |
| 378 | assert(*state == STATE_INSTRUCTION || *state == STATE_FREE); |
| 379 | *bytes++ = /*short jmp opcode=*/0xEB; |
| 380 | *state++ = STATE_PATCHED; |
| 381 | |
| 382 | assert(*state == STATE_INSTRUCTION || *state == STATE_FREE); |
| 383 | *bytes++ = (uint8_t)rel8; |
| 384 | *state++ = STATE_PATCHED; |
| 385 | } |
| 386 | |
| 387 | /* |
| 388 | * Patch in a trap (illegal) instruction. |