Add support to GDB for the Renesas rl78 architecture.
[external/binutils.git] / gdb / testsuite / gdb.base / solib.c
1 /* This program uses HP-UX-specific features to load and unload SOM
2    shared libraries that it wasn't linked against (i.e., libraries
3    that the loader doesn't automatically load along with the program
4    itself).
5    */
6
7 #include <stdio.h>
8 #include <dl.h>
9
10 int main ()
11 {
12   shl_t  solib_handle;
13   int  dummy;
14   int  status;
15   int  (*solib_main) (int);
16
17   /* Load a shlib, with immediate binding of all symbols.
18
19      Note that the pathname of the loaded shlib is assumed to be relative
20      to the testsuite directory (from whence the tested GDB is run), not
21      from dot/.
22    */
23   dummy = 1;  /* Put some code between shl_ calls... */
24   solib_handle = shl_load ("gdb.base/solib1.sl", BIND_IMMEDIATE, 0);
25
26   /* Find a function within the shlib, and call it. */
27   status = shl_findsym (&solib_handle,
28                         "solib_main",
29                         TYPE_PROCEDURE,
30                         (long *) &solib_main);
31   status = (*solib_main) (dummy);
32
33   /* Unload the shlib. */
34   status = shl_unload (solib_handle);
35
36   /* Load a different shlib, with deferred binding of all symbols. */
37   dummy = 2;
38   solib_handle = shl_load ("gdb.base/solib2.sl", BIND_DEFERRED, 0);
39
40   /* Find a function within the shlib, and call it. */
41   status = shl_findsym (&solib_handle,
42                         "solib_main",
43                         TYPE_PROCEDURE,
44                         (long *) &solib_main);
45   status = (*solib_main) (dummy);
46
47   /* Unload the shlib. */
48   status = shl_unload (solib_handle);
49
50   /* Reload the first shlib again, with deferred symbol binding this time. */
51   dummy = 3;
52   solib_handle = shl_load ("gdb.base/solib1.sl", BIND_IMMEDIATE, 0);
53
54   /* Unload it without trying to find any symbols in it. */
55   status = shl_unload (solib_handle);
56
57   /* All done. */
58   dummy = -1;
59   return 0;
60 }