diff options
author | comex | 2015-02-22 23:28:20 -0500 |
---|---|---|
committer | comex | 2015-02-23 00:54:13 -0500 |
commit | 6080774f1af3103be688941beb43174d69d60483 (patch) | |
tree | 76a32ee6c7a9dc66a7a6bbc508e33596f2991945 /lib/x86/jump-patch.h | |
parent | fix i386 manual syscall, mmap return check (diff) | |
download | substitute-6080774f1af3103be688941beb43174d69d60483.tar.gz |
fix some i386 stuff
Diffstat (limited to 'lib/x86/jump-patch.h')
-rw-r--r-- | lib/x86/jump-patch.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/x86/jump-patch.h b/lib/x86/jump-patch.h index 569eb74..09554d1 100644 --- a/lib/x86/jump-patch.h +++ b/lib/x86/jump-patch.h @@ -13,19 +13,24 @@ static inline int jump_patch_size(uint_tptr pc, uint_tptr dpc, return force ? (2+4+8) : -1; } -static inline void make_jump_patch(void **codep, uint_tptr pc, uint_tptr dpc, - UNUSED struct arch_dis_ctx arch) { +static inline void make_jmp_or_call(void **codep, uint_tptr pc, uint_tptr dpc, + bool call) { uint_tptr diff = dpc - (pc + 5); void *code = *codep; if (diff == (uint_tptr) (int32_t) diff) { - op8(&code, 0xe9); + op8(&code, call ? 0xe8 : 0xe9); op32(&code, diff); } else { /* jmpq *(%rip) */ op8(&code, 0xff); - op8(&code, 0x25); + op8(&code, call ? 0x15 : 0x25); op32(&code, 0); op64(&code, dpc); } *codep = code; } + +static inline void make_jump_patch(void **codep, uint_tptr pc, uint_tptr dpc, + UNUSED struct arch_dis_ctx arch) { + make_jmp_or_call(codep, pc, dpc, false); +} |