summaryrefslogtreecommitdiff
path: root/elf/tst-array2dep.c
blob: be46dd13e29c7fd02d1b7949a330b3e74219c95e (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <unistd.h>

static void init (void) __attribute__ ((constructor));

static void
init (void)
{
  write (STDOUT_FILENO, "DSO init\n", 9);
}

static void fini (void) __attribute__ ((destructor));

static void
fini (void)
{
  write (STDOUT_FILENO, "DSO fini\n", 9);
}

static void
init_0 (void)
{
  write (STDOUT_FILENO, "DSO init array 0\n", 17);
}

static void
init_1 (void)
{
  write (STDOUT_FILENO, "DSO init array 1\n", 17);
}

static void
init_2 (void)
{
  write (STDOUT_FILENO, "DSO init array 2\n", 17);
}

void (*const init_array []) (void) __attribute__ ((section (".init_array"))) =
{
  &init_0,
  &init_1,
  &init_2
};

static void
fini_0 (void)
{
  write (STDOUT_FILENO, "DSO fini array 0\n", 17);
}

static void
fini_1 (void)
{
  write (STDOUT_FILENO, "DSO fini array 1\n", 17);
}

static void
fini_2 (void)
{
  write (STDOUT_FILENO, "DSO fini array 2\n", 17);
}

void (*const fini_array []) (void) __attribute__ ((section (".fini_array"))) =
{
  &fini_0,
  &fini_1,
  &fini_2
};