aboutsummaryrefslogtreecommitdiff
path: root/elf/tst-execstack-mod.c
diff options
context:
space:
mode:
Diffstat (limited to 'elf/tst-execstack-mod.c')
-rw-r--r--elf/tst-execstack-mod.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/elf/tst-execstack-mod.c b/elf/tst-execstack-mod.c
new file mode 100644
index 0000000..038e655
--- /dev/null
+++ b/elf/tst-execstack-mod.c
@@ -0,0 +1,30 @@
+/* Test module for making nonexecutable stacks executable
+ on load of a DSO that requires executable stacks. */
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void callme (void (*callback) (void));
+
+/* This is a function that makes use of executable stack by
+ using a local function trampoline. */
+void
+tryme (void)
+{
+ bool ok = false;
+ void callback (void) { ok = true; }
+
+ callme (&callback);
+
+ if (ok)
+ printf ("DSO called ok (local %p, trampoline %p)\n", &ok, &callback);
+ else
+ abort ();
+}
+
+void
+callme (void (*callback) (void))
+{
+ (*callback) ();
+}