* Patch in a (redundant) jmp instruction prefix. */
| 305 | * Patch in a (redundant) jmp instruction prefix. |
| 306 | */ |
| 307 | static void patchJumpPrefix(Patch *P, unsigned prefix) |
| 308 | { |
| 309 | // TODO: support other prefixes/encodings/NOPs |
| 310 | const uint8_t prefixes[] = {0x48, 0x26, 0x36, 0x3E}; |
| 311 | assert(prefix < P->I->size && prefix <= sizeof(prefixes)); |
| 312 | |
| 313 | uint8_t *bytes = P->I->PATCH, *state = P->I->STATE; |
| 314 | for (unsigned i = 0; i < prefix; i++) |
| 315 | { |
| 316 | assert(state[i] == STATE_INSTRUCTION || |
| 317 | state[i] == STATE_FREE); |
| 318 | bytes[i] = prefixes[i]; |
| 319 | state[i] = STATE_PATCHED; |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | /* |
| 324 | * Patch in a jmpq instruction. |