advanced-microcode-patching / shiva

A custom ELF linker/loader for installing ET_REL binary patches at runtime
Other
146 stars 13 forks source link

x86_64 imm-call relinking needs it's own private PLT/GOT to handle calls to further than 2GB away in either direction #23

Open elfmaster opened 7 months ago

elfmaster commented 7 months ago

The patch image is loaded further than 2gb away in memory and thus we cannot re-link call instructions with an offset that fits in 4 bytes

elfmaster commented 5 months ago

This same problem applies to relinking load/stores of global variables with mov instructions who's destination register is only 32bits.

8b 2d f0 ad 00 00: mov 0xadf0(%rip), %ebp

The instruction above only has 3 bytes for encoding the offset, and we need 4 bytes to reach the patch target (The global variable).