advanced-microcode-patching / shiva

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

shiva_tf_relink_local_branch_x86_64 re-writes short branch with offset that becomes negative in splice patches larger than 127 bytes in length. #21

Open elfmaster opened 8 months ago

elfmaster commented 8 months ago

shiva_tf_relink_local_branch_x86_64 re-writes short branch with offset that becomes negative in splice patches larger than 127 bytes in length.

In short... the two byte instruction "\x74\0x00" can only hold a one byte offset. If it goes beyond 127 bytes than it becomes a negative offset and the 'je' instruction jumps to an invalid location.

Shiva needs to calculate which local branches will need to be re-written from a "Short branch" to a "Near branch" and then rewrite