[go: up one dir, main page]

File: s-dlopen.c

package info (click to toggle)
uftrace 0.13-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,212 kB
  • sloc: ansic: 53,313; python: 9,846; makefile: 838; asm: 703; cpp: 602; sh: 560; javascript: 191
file content (33 lines) | stat: -rw-r--r-- 462 bytes parent folder | download | duplicates (3)
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
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
	void *handle;
	void (*sym)(int);
	int n = 1;

	if (argc > 1)
		n = atoi(argv[1]);

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

	if (!handle)
		return -1;

	sym = dlsym(handle, "lib_a");
	sym(n);
	dlclose(handle);

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

	if (!handle)
		return -1;

	sym = dlsym(handle, "foo");
	sym(n);
	dlclose(handle);

	return 0;
}