dlsym man page on IRIX

Man page or keyword search:  
man Server   31559 pages
apropos Keyword Search (all sections)
Output format
IRIX logo
[printable version]



DLSYM(3C)							     DLSYM(3C)

NAME
     dlsym - get the address of a symbol in shared object

SYNOPSIS
     cc [flag ...] file ...  -lc [library ...]

     #include <dlfcn.h>

     void *dlsym(void *handle, const char *name);

DESCRIPTION
     dlsym allows a process to obtain the address of a symbol defined within a
     shared object previously opened by dlopen, sgidlopen_version, or
     sgidladd.	handle is a value returned by a call to dlopen; the
     corresponding shared object must not have been closed using dlclose.
     name is the symbol's name as a character string.  dlsym searchs for the
     named symbol in all shared objects loaded automatically as a result of
     loading the object referenced by handle [see dlopen(3)].

     The name search is done in the following order:
	 If the handle is NULL, the base object is searched and then the rld-
	 list of objects is searched, looking only at globally-visible DSOs.

	 If the handle is not NULL, the named object is searched and then the
	 library list of the DSO opened on handle is searched (in a pre-order
	 breadth-first search of all listed DSOs).

	 The first visible symbol with the requested name (weak or strong) is
	 returned.

     For information on how names are generally resolved (as distinct from
     dlsym resolution) and on symbol visibility see the dlopen "NAMESPACE
     ISSUES" section.

     Note that name resolution for names on the NULL handle is in rld-list
     order whereas for other handles the resolution is in library-list order.

EXAMPLES
     The following example shows how one can use dlopen and dlsym to access
     either function or data objects.  For simplicity, error checking has been
     omitted.

	  void *handle;
	  int i, *iptr;
	  int (*fptr)(int);

	  /* open the needed object */
	  handle = dlopen("/usr/mydir/libx.so", RTLD_LAZY);

	  /* find address of function and data objects */
	  fptr = (int (*)(int))dlsym(handle, "some_function");

									Page 1

DLSYM(3C)							     DLSYM(3C)

	  iptr = (int *)dlsym(handle, "int_object");

	  /* invoke function, passing value of integer as a parameter */

	  i = (*fptr)(*iptr);

SEE ALSO
     dlerror(3), dlopen(3), sgidlopen_version(3), dlclose(3),
     sgigetdsoversion(3), sgidladd(3).

DIAGNOSTICS
     The C or C++ compiler may emit a warning similar to "warning(1048): cast
     between pointer-to-object and pointer-to-function" when casting the
     return type of dlsym to be a function pointer.  While a cast from
     pointer-to-data to pointer-to-function is not necessarily portable to all
     systems (which is what the warning means) the cast and the resulting call
     will work fine on any system actually supporting dlsym.  One could define
     a function
     int (*dlsymfunc(void *handle,char *name))();
     int (*dlsymfunc(void *handle,char *name))()
     {
	     return (int (*)())dlsym(handle,name);
     }
     and call it instead of dlsym when getting function addresses: that has
     the effect of moving the warning message to a single spot in the program
     (the dlsymfunc definition) so the rest of the code does not get this
     warning.

     If handle does not refer to a valid object opened by dlopen, or if the
     named symbol cannot be found within any of the objects associated with
     handle, dlsym returns NULL. More detailed diagnostic information is
     available through dlerror.

									Page 2

[top]

List of man pages available for IRIX

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net