Back to index

glibc  2.9
tst-execstack-mod.c
Go to the documentation of this file.
00001 /* Test module for making nonexecutable stacks executable
00002    on load of a DSO that requires executable stacks.  */
00003 
00004 #include <stdbool.h>
00005 #include <stdio.h>
00006 #include <stdlib.h>
00007 
00008 void callme (void (*callback) (void));
00009 
00010 /* This is a function that makes use of executable stack by
00011    using a local function trampoline.  */
00012 void
00013 tryme (void)
00014 {
00015   bool ok = false;
00016   void callback (void) { ok = true; }
00017 
00018   callme (&callback);
00019 
00020   if (ok)
00021     printf ("DSO called ok (local %p, trampoline %p)\n", &ok, &callback);
00022   else
00023     abort ();
00024 }
00025 
00026 void
00027 callme (void (*callback) (void))
00028 {
00029   (*callback) ();
00030 }