diff options
author | Yifan Lu | 2016-10-05 22:27:32 -0700 |
---|---|---|
committer | Yifan Lu | 2016-10-05 22:27:32 -0700 |
commit | d2971bb2511a96061467cc2276fdeae6b2bbd5e0 (patch) | |
tree | e3a5082788e605c667d3fdaf96620156793602a5 /lib/hook-functions.c | |
parent | Added option to removed pthread dependency (diff) | |
download | substitute-d2971bb2511a96061467cc2276fdeae6b2bbd5e0.tar.gz |
Fixed missing trampoline_size_left decrement for making initial trampoline jump
Added comment about min exec page size requirement
Diffstat (limited to '')
-rw-r--r-- | lib/hook-functions.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/hook-functions.c b/lib/hook-functions.c index 8363567..5f71229 100644 --- a/lib/hook-functions.c +++ b/lib/hook-functions.c @@ -195,6 +195,7 @@ int substitute_hook_functions(const struct substitute_function_hook *hooks, initial_target = (uintptr_t) trampoline_ptr; make_jump_patch(&trampoline_ptr, (uintptr_t) trampoline_ptr, (uintptr_t) hook->replacement, arch); + trampoline_size_left -= patch_size; } else { initial_target = (uintptr_t) hook->replacement; } @@ -211,6 +212,9 @@ int substitute_hook_functions(const struct substitute_function_hook *hooks, if ((ret = execmem_alloc_unsealed(0, &trampoline_ptr, &trampoline_size_left))) goto end; + /* NOTE: We assume that each page is large enough (min 0x1000) + * so we don't lose a reference by having one hook allocate two + * pages. */ hi->trampoline_page = trampoline_ptr; } |