]> git.saurik.com Git - apple/dyld.git/blob - unit-tests/test-cases/interpose-dynamic-dlsym/foo.c
dyld-360.19.tar.gz
[apple/dyld.git] / unit-tests / test-cases / interpose-dynamic-dlsym / foo.c
1 #include <stdio.h> // fprintf(), NULL
2 #include <stdlib.h> // exit(), EXIT_SUCCESS
3 #include <string.h>
4 #include <dlfcn.h>
5 #include <crt_externs.h>
6 #include <mach-o/dyld_priv.h>
7
8
9 int foo() { return 0; }
10
11 int alt_foo() { return 10; }
12
13
14
15
16 static const struct dyld_interpose_tuple sTable[] = { {&alt_foo, &foo} };
17
18
19 __attribute__((constructor))
20 void init()
21 {
22 // switch main executable to use alt_foo() when it calls foo()
23 dyld_dynamic_interpose((const struct mach_header*)_NSGetMachExecuteHeader(), sTable, 1);
24
25 }
26