aboutsummaryrefslogtreecommitdiff
path: root/test/test-hook-functions.c
diff options
context:
space:
mode:
authorcomex2015-02-22 22:43:43 -0500
committercomex2015-02-23 00:54:13 -0500
commitd555fb6089da308956e49db7f60dfbb4d182c3df (patch)
treefad1fa0d64e7fb591d0a2030633c2a3ed76e41c7 /test/test-hook-functions.c
parentremove old comment (diff)
downloadsubstitute-d555fb6089da308956e49db7f60dfbb4d182c3df.tar.gz
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.
Diffstat (limited to '')
-rw-r--r--test/test-hook-functions.c11
1 files changed, 11 insertions, 0 deletions
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");