OSDN Git Service

* gdb.base/unload.c (main): Make local variable msg const.
[pf3gnuchains/pf3gnuchains4x.git] / gdb / testsuite / gdb.base / unload.c
1 /* This testcase is part of GDB, the GNU debugger.
2
3    Copyright 2004 Free Software Foundation, Inc.
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
7    the Free Software Foundation; either version 2 of the License, or
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.
14  
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18
19 #include <stdio.h>
20 #include <dlfcn.h>
21
22 int k = 0;
23
24 #define SHLIB_NAME SHLIB_DIR "/unloadshr.sl"
25
26 int main()
27 {
28   void *handle;
29   int (*unloadshr) (int);
30   int y;
31   const char *msg;
32
33   handle = dlopen (SHLIB_NAME, RTLD_LAZY);
34   msg = dlerror ();
35   
36   if (!handle)
37     {
38       fprintf (stderr, msg);
39       exit (1);
40     }
41
42   unloadshr = (int (*)(int))dlsym (handle, "shrfunc1");
43
44   if (!unloadshr)
45     {
46       fprintf (stderr, dlerror ());
47       exit (1);
48     }
49
50   y = (*unloadshr)(3);
51
52   printf ("y is %d\n", y);
53
54   dlclose (handle);
55
56   return 0;
57 }