summaryrefslogtreecommitdiff
path: root/test/dlopen/libtest1.c
blob: c440d9b4ac119ac4ccd295725f0d47eba62c7080 (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
#include <stdio.h>

extern int libtest2_func(const char *s);


void __attribute__((constructor)) libtest1_ctor(void)
{
    printf("I am the libtest1 constructor!\n");
}

void __attribute__((destructor)) libtest1_dtor(void)
{
    printf("I am the libtest1 destructor!\n");
}

void __attribute__((weak)) function1(void)
{
    printf("libtest1: I am function1 from libtest1!\n");
}

void function2(void)
{
    printf("libtest1: I am overriding function2!\n");
}


int dltest(const char *s)
{
    printf( "libtest1: function1 = %p\n"
	    "libtest1: function2 = %p\n",
	    function1, function2);
    function1();
    function2();
    return(libtest2_func(s));
}