1*1bce49b2Skurt /* $OpenBSD: main.c,v 1.1.1.1 2005/09/28 15:42:32 kurt Exp $ */
2*1bce49b2Skurt
3*1bce49b2Skurt /*
4*1bce49b2Skurt * Copyright (c) 2005 Kurt Miller <kurt@openbsd.org>
5*1bce49b2Skurt *
6*1bce49b2Skurt * Permission to use, copy, modify, and distribute this software for any
7*1bce49b2Skurt * purpose with or without fee is hereby granted, provided that the above
8*1bce49b2Skurt * copyright notice and this permission notice appear in all copies.
9*1bce49b2Skurt *
10*1bce49b2Skurt * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11*1bce49b2Skurt * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12*1bce49b2Skurt * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13*1bce49b2Skurt * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14*1bce49b2Skurt * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15*1bce49b2Skurt * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16*1bce49b2Skurt * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*1bce49b2Skurt */
18*1bce49b2Skurt
19*1bce49b2Skurt #include <dlfcn.h>
20*1bce49b2Skurt #include <stdio.h>
21*1bce49b2Skurt
22*1bce49b2Skurt int
main()23*1bce49b2Skurt main()
24*1bce49b2Skurt {
25*1bce49b2Skurt int ret = 0;
26*1bce49b2Skurt void *libaa;
27*1bce49b2Skurt
28*1bce49b2Skurt libaa = dlopen("libaa.so", RTLD_LAZY|RTLD_GLOBAL);
29*1bce49b2Skurt
30*1bce49b2Skurt if (libaa == NULL) {
31*1bce49b2Skurt printf("dlopen(\"libaa.so\", RTLD_LAZY|RTLD_GLOBAL) FAILED\n");
32*1bce49b2Skurt return (1);
33*1bce49b2Skurt }
34*1bce49b2Skurt
35*1bce49b2Skurt libaa = dlopen("libaa.so", RTLD_LAZY|RTLD_GLOBAL);
36*1bce49b2Skurt
37*1bce49b2Skurt dlclose(libaa);
38*1bce49b2Skurt
39*1bce49b2Skurt /* RTLD_DEFAULT should see aaSymbol */
40*1bce49b2Skurt if (dlsym(RTLD_DEFAULT, "aaSymbol") == NULL) {
41*1bce49b2Skurt printf("dlsym(RTLD_DEFAULT, \"aaSymbol\") == NULL\n");
42*1bce49b2Skurt ret = 1;
43*1bce49b2Skurt }
44*1bce49b2Skurt
45*1bce49b2Skurt dlclose(libaa);
46*1bce49b2Skurt
47*1bce49b2Skurt return (ret);
48*1bce49b2Skurt }
49