From 83442f9005c21de839b5ed69bd3e0b4e59032020 Mon Sep 17 00:00:00 2001 From: comex Date: Thu, 16 Jul 2015 13:04:23 -0400 Subject: Add options field to struct substitute_{function,import}_hook. I will probably need to add an option to deal with GCC 5.2's new optimization - to not save caller-saved registers if the called function is known not to use them, which would break with hooked functions. Don't want to emit the required stub by default because it will likely be slow. I need to verify that Clang doesn't currently have such an optimization... (ABI break - need to avoid this once it gets widely distributed Soon, obviously) --- lib/substitute.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/substitute.h b/lib/substitute.h index 034cc26..72c3919 100644 --- a/lib/substitute.h +++ b/lib/substitute.h @@ -87,10 +87,17 @@ enum { const char *substitute_strerror(int err); struct substitute_function_hook { + /* The function to hook. (On ARM, Thumb functions are indicated as usual + * for function pointers.) */ void *function; + /* The replacement function. */ void *replacement; - void *old_ptr; /* optional: out *pointer* to function pointer to call old - * impl */ + /* Optional: out *pointer* to function pointer to call old implementation + * (i.e. given 'void (*old_foo)(...);', pass &old_foo) */ + void *old_ptr; + /* Currently unused; pass 0. (Protip: When using C {} struct initializer + * syntax, you can just omit this.) */ + int options; }; /* substitute_hook_functions options */ @@ -216,6 +223,9 @@ struct substitute_import_hook { * the same symbol, only one address is returned (hopefully they are all * equal) */ void *old_ptr; + /* Currently unused; pass 0. (Protip: When using C {} struct initializer + * syntax, you can just omit this.) */ + int options; }; /* Directly modify the GOT/PLT entries from a specified image corresponding to -- cgit v1.2.3