summaryrefslogtreecommitdiff
path: root/test/dlopen/libC.c
blob: 84cbbef3df15ef8be08cce230883b00d14b7d536 (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
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>

#define LIBNAME "libB.so"
void _libC_fini(void);
void _libC_fini(void)
{
	printf("libC_fini():finish - atexit()\n");
}

void libC_fini(void);
void libC_fini(void)
{
	_libC_fini();
}

void libC_func(void);
void libC_func(void)
{
	void *libB;

	libB = dlopen(LIBNAME, RTLD_LAZY);
	if (!libB) {
		fprintf(stderr, "Could not open ./%s: %s\n", LIBNAME, dlerror());
		exit(1);
	}

	atexit(libC_fini);
}