Back to index

glibc  2.9
tst-execstack-needed.c
Go to the documentation of this file.
00001 /* Test program for making nonexecutable stacks executable
00002    on DT_NEEDED load of a DSO that requires executable stacks.  */
00003 
00004 #include <dlfcn.h>
00005 #include <stdio.h>
00006 #include <string.h>
00007 #include <unistd.h>
00008 #include <error.h>
00009 
00010 extern void tryme (void);   /* from tst-execstack-mod.so */
00011 
00012 static void deeper (void (*f) (void));
00013 
00014 static int
00015 do_test (void)
00016 {
00017   tryme ();
00018 
00019   /* Test that growing the stack region gets new executable pages too.  */
00020   deeper (&tryme);
00021 
00022   return 0;
00023 }
00024 
00025 static void
00026 deeper (void (*f) (void))
00027 {
00028   char stack[1100 * 1024];
00029   memfrob (stack, sizeof stack);
00030   (*f) ();
00031   memfrob (stack, sizeof stack);
00032 }
00033 
00034 
00035 #define TEST_FUNCTION do_test ()
00036 #include "../test-skeleton.c"