From d555fb6089da308956e49db7f60dfbb4d182c3df Mon Sep 17 00:00:00 2001 From: comex Date: Sun, 22 Feb 2015 22:43:43 -0500 Subject: Fix vm_remap, of trouble with which the previous diagnosis was completely incorrect. It's actually the fact that no vm_map_server actually exists on the kernel side - even though the otherwise useless function vm_remap exists in the kernel source, and mig generates server code for it, apparently that server code isn't built or linked into the kobject table. Bizarre. Anyway, switch to mach_vm_remap, which is what vm_remap in userspace calls into. --- test/test-hook-functions.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/test-hook-functions.c') diff --git a/test/test-hook-functions.c b/test/test-hook-functions.c index ab027de..7978658 100644 --- a/test/test-hook-functions.c +++ b/test/test-hook-functions.c @@ -31,7 +31,17 @@ void break_after() { __asm__ volatile(""); } +__attribute__((section("__TEST,__foo"), noinline)) +static int my_own_function(int x) { + return x + 4; +} + +static int hook_my_own_function(int x) { + return x + 5; +} + static const struct substitute_function_hook hooks[] = { + {my_own_function, hook_my_own_function, NULL}, {getpid, hook_getpid, &old_getpid}, {hcreate, hook_hcreate, NULL}, {fwrite, hook_fwrite, &old_fwrite}, @@ -55,6 +65,7 @@ int main() { printf("errno = %d\n", e); printf("getpid() => %d\n", getpid()); printf("hcreate() => %d\n", hcreate(42)); + printf("my_own_function() => %d\n", my_own_function(0)); #else (void) hooks; printf("can't test this here\n"); -- cgit v1.2.3