blob: 64dadd53ff8ef109900c68b31d06e2ef066c6fd1 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#include <dlfcn.h>
2#include <stdio.h>
3
4
5extern void constr (void) __attribute__ ((__constructor__));
6void
7__attribute__ ((__constructor__))
8constr (void)
9{
10 void *handle;
11
12 /* Open the library. */
13 handle = dlopen (NULL, RTLD_NOW);
14 if (handle == NULL)
15 {
16 puts ("Cannot get handle to own object");
17 return;
18 }
19
20 /* Get a symbol. */
21 dlsym (handle, "main");
22 puts ("called dlsym() to get main");
23
24 dlclose (handle);
25}