summaryrefslogtreecommitdiff
path: root/elf/tst-execstack-mod.c
blob: 038e6550b55bf9f20046fd9ac5da3dbce88aa36b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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) ();
}