about summary refs log tree commit diff
path: root/REORG.TODO/elf/tst-execstack-mod.c
diff options
context:
space:
mode:
Diffstat (limited to 'REORG.TODO/elf/tst-execstack-mod.c')
-rw-r--r--REORG.TODO/elf/tst-execstack-mod.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/REORG.TODO/elf/tst-execstack-mod.c b/REORG.TODO/elf/tst-execstack-mod.c
new file mode 100644
index 0000000000..038e6550b5
--- /dev/null
+++ b/REORG.TODO/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) ();
+}