summaryrefslogtreecommitdiff
path: root/test/ldso/dltest.c
blob: 676e1ae55a80e4623758149559028799a00f8725 (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
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>

extern void _dlinfo();

int main(int argc, char **argv) {
	void *handle;
	int (*myhowdy)(const char *s);
	char *error;

#ifdef __UCLIBC__
	_dlinfo();   /* not supported by ld.so.2 */
#endif

	handle = dlopen ("./libhowdy.so", RTLD_LAZY);

	if (!handle) {
		fputs (dlerror(), stderr);
		exit(1);
	}

	myhowdy = dlsym(handle, "howdy");
	if ((error = dlerror()) != NULL)  {
		fputs(error, stderr);
		exit(1);
	}

	myhowdy("hello world!\n");

#ifdef __UCLIBC__
	_dlinfo();   /* not supported by ld.so.2 */
#endif

	dlclose(handle);

	return EXIT_SUCCESS;
}