4 #include <sys/sysctl.h>
9 __attribute__((noinline
))
18 * volatile to stop the compiler from optimizing away calls to atan()
20 volatile double zero
= 0.0;
23 main(int argc
, char **argv
)
26 size_t s
= sizeof(addr
);
31 * needs to run as root for sysctl.
34 printf("Test not running as root\n");
38 if (strcmp(argv
[argc
- 1], "foo") == 0) {
40 } else if (strcmp(argv
[argc
- 1], "Xfoo") == 0) {
41 printf("Warm up call to foo()\n");
43 addr
= ptrauth_strip(&foo
, ptrauth_key_function_pointer
);
44 err
= sysctlbyname("vm.corrupt_text_addr", NULL
, NULL
, &addr
, s
);
46 } else if (strcmp(argv
[argc
- 1], "atan") == 0) {
47 printf("atan(0) is %g\n", atan(zero
));
48 } else if (strcmp(argv
[argc
- 1], "Xatan") == 0) {
49 printf("Warmup call to atan(0) is %g\n", atan(zero
));
50 addr
= ptrauth_strip(&atan
, ptrauth_key_function_pointer
);
51 err
= sysctlbyname("vm.corrupt_text_addr", NULL
, NULL
, &addr
, s
);
52 printf("atan(0) is %g\n", atan(zero
));