diff options
Diffstat (limited to 'gdb/testsuite/gdb.base/solib.c')
-rw-r--r-- | gdb/testsuite/gdb.base/solib.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/solib.c b/gdb/testsuite/gdb.base/solib.c new file mode 100644 index 0000000..ff9d359 --- /dev/null +++ b/gdb/testsuite/gdb.base/solib.c @@ -0,0 +1,59 @@ +/* This program uses HP-UX-specific features to load and unload SOM + shared libraries that it wasn't linked against (i.e., libraries + that the loader doesn't automatically load along with the program + itself). + */ + +#include <stdio.h> +#include <dl.h> + +main () +{ + shl_t solib_handle; + int dummy; + int status; + int (*solib_main) (); + + /* Load a shlib, with immediate binding of all symbols. + + Note that the pathname of the loaded shlib is assumed to be relative + to the testsuite directory (from whence the tested GDB is run), not + from dot/. + */ + dummy = 1; /* Put some code between shl_ calls... */ + solib_handle = shl_load ("gdb.base/solib1.sl", BIND_IMMEDIATE, 0); + + /* Find a function within the shlib, and call it. */ + status = shl_findsym (&solib_handle, + "solib_main", + TYPE_PROCEDURE, + (long *) &solib_main); + status = (*solib_main) (dummy); + + /* Unload the shlib. */ + status = shl_unload (solib_handle); + + /* Load a different shlib, with deferred binding of all symbols. */ + dummy = 2; + solib_handle = shl_load ("gdb.base/solib2.sl", BIND_DEFERRED, 0); + + /* Find a function within the shlib, and call it. */ + status = shl_findsym (&solib_handle, + "solib_main", + TYPE_PROCEDURE, + (long *) &solib_main); + status = (*solib_main) (dummy); + + /* Unload the shlib. */ + status = shl_unload (solib_handle); + + /* Reload the first shlib again, with deferred symbol binding this time. */ + dummy = 3; + solib_handle = shl_load ("gdb.base/solib1.sl", BIND_IMMEDIATE, 0); + + /* Unload it without trying to find any symbols in it. */ + status = shl_unload (solib_handle); + + /* All done. */ + dummy = -1; +} |