Commit | Line | Data |
---|---|---|
37fdf854 JJ |
1 | /* This testcase is part of GDB, the GNU debugger. |
2 | ||
6aba47ca | 3 | Copyright 2004, 2007 Free Software Foundation, Inc. |
37fdf854 JJ |
4 | |
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 7 | the Free Software Foundation; either version 3 of the License, or |
37fdf854 JJ |
8 | (at your option) any later version. |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
a9762ec7 | 14 | |
37fdf854 | 15 | You should have received a copy of the GNU General Public License |
a9762ec7 | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
37fdf854 JJ |
17 | |
18 | #include <stdio.h> | |
934353d6 | 19 | #include <stdlib.h> |
255e7678 DJ |
20 | |
21 | #ifdef __WIN32__ | |
22 | #include <windows.h> | |
23 | #define dlopen(name, mode) LoadLibrary (name) | |
24 | #define dlsym(handle, func) GetProcAddress (handle, func) | |
25 | #define dlclose(handle) FreeLibrary (handle) | |
26 | #define dlerror() "error %d occurred", GetLastError () | |
27 | #else | |
37fdf854 | 28 | #include <dlfcn.h> |
255e7678 | 29 | #endif |
37fdf854 JJ |
30 | |
31 | int k = 0; | |
32 | ||
37fdf854 JJ |
33 | int main() |
34 | { | |
35 | void *handle; | |
36 | int (*unloadshr) (int); | |
37 | int y; | |
00b51b9f | 38 | const char *msg; |
37fdf854 JJ |
39 | |
40 | handle = dlopen (SHLIB_NAME, RTLD_LAZY); | |
37fdf854 JJ |
41 | |
42 | if (!handle) | |
43 | { | |
255e7678 | 44 | fprintf (stderr, dlerror ()); |
37fdf854 JJ |
45 | exit (1); |
46 | } | |
47 | ||
48 | unloadshr = (int (*)(int))dlsym (handle, "shrfunc1"); | |
49 | ||
50 | if (!unloadshr) | |
51 | { | |
52 | fprintf (stderr, dlerror ()); | |
53 | exit (1); | |
54 | } | |
55 | ||
56 | y = (*unloadshr)(3); | |
57 | ||
58 | printf ("y is %d\n", y); | |
59 | ||
60 | dlclose (handle); | |
61 | ||
62 | return 0; | |
63 | } |