2015-07-16 07:58:59 +00:00
|
|
|
.\" Copyright 1995 Yggdrasil Computing, Incorporated.
|
|
|
|
.\" and Copyright 2003, 2015 Michael Kerrisk (mtk.manpages@gmail.com).
|
|
|
|
.\"
|
|
|
|
.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
|
|
|
|
.\" This is free documentation; you can redistribute it and/or
|
|
|
|
.\" modify it under the terms of the GNU General Public License as
|
|
|
|
.\" published by the Free Software Foundation; either version 2 of
|
|
|
|
.\" the License, or (at your option) any later version.
|
|
|
|
.\"
|
|
|
|
.\" The GNU General Public License's references to "object code"
|
|
|
|
.\" and "executables" are to be interpreted as the output of any
|
|
|
|
.\" document formatting or typesetting system, including
|
|
|
|
.\" intermediate and printed output.
|
|
|
|
.\"
|
|
|
|
.\" This manual is distributed in the hope that it will be useful,
|
|
|
|
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
.\" GNU General Public License for more details.
|
|
|
|
.\"
|
|
|
|
.\" You should have received a copy of the GNU General Public
|
|
|
|
.\" License along with this manual; if not, see
|
|
|
|
.\" <http://www.gnu.org/licenses/>.
|
|
|
|
.\" %%%LICENSE_END
|
|
|
|
.\"
|
ldd.1, sprof.1, accept.2, alarm.2, bind.2, chdir.2, clock_nanosleep.2, close.2, connect.2, dup.2, execve.2, fsync.2, getgid.2, getpeername.2, getsid.2, getsockname.2, getsockopt.2, getuid.2, io_getevents.2, kill.2, listen.2, lseek.2, mmap.2, msgctl.2, msgget.2, msgop.2, msync.2, nanosleep.2, nice.2, pause.2, pipe.2, rmdir.2, sched_get_priority_max.2, sched_rr_get_interval.2, sched_setparam.2, sched_setscheduler.2, sched_yield.2, select_tut.2, semctl.2, semop.2, setsid.2, shmctl.2, shmget.2, shmop.2, shutdown.2, sigaction.2, signal.2, socketpair.2, sync.2, timer_delete.2, timer_getoverrun.2, timer_settime.2, times.2, truncate.2, umask.2, MB_CUR_MAX.3, a64l.3, abs.3, assert.3, atexit.3, atof.3, atoi.3, basename.3, bsearch.3, btowc.3, byteorder.3, catgets.3, catopen.3, clock.3, clock_getcpuclockid.3, closedir.3, confstr.3, crypt.3, ctermid.3, difftime.3, div.3, dladdr.3, dlerror.3, dlinfo.3, dlopen.3, dlsym.3, drand48.3, encrypt.3, exit.3, fclose.3, ffs.3, fgetc.3, fgetwc.3, fgetws.3, flockfile.3, fmtmsg.3, fnmatch.3, fopen.3, fpathconf.3, fpclassify.3, fputwc.3, fputws.3, fseek.3, fseeko.3, ftok.3, fwide.3, getdate.3, getenv.3, getgrent.3, getgrnam.3, gethostid.3, getlogin.3, getnetent.3, getopt.3, getpwent.3, getpwnam.3, getsubopt.3, getutent.3, getwchar.3, grantpt.3, hsearch.3, iconv.3, iconv_close.3, iconv_open.3, if_nameindex.3, inet.3, inet_ntop.3, inet_pton.3, insque.3, isatty.3, isgreater.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, lockf.3, longjmp.3, lsearch.3, malloc.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, memccpy.3, memchr.3, memcmp.3, memmove.3, memset.3, mktemp.3, mq_close.3, mq_getattr.3, mq_receive.3, mq_send.3, mq_unlink.3, offsetof.3, popen.3, posix_memalign.3, posix_openpt.3, printf.3, pthread_attr_setdetachstate.3, pthread_attr_setguardsize.3, pthread_attr_setinheritsched.3, pthread_attr_setschedparam.3, pthread_attr_setschedpolicy.3, pthread_attr_setscope.3, pthread_attr_setstack.3, pthread_attr_setstacksize.3, pthread_equal.3, pthread_exit.3, pthread_getcpuclockid.3, pthread_kill.3, pthread_self.3, pthread_setcancelstate.3, pthread_setconcurrency.3, pthread_setschedparam.3, pthread_setschedprio.3, pthread_sigmask.3, pthread_testcancel.3, ptsname.3, putenv.3, puts.3, putwchar.3, qsort.3, raise.3, random.3, readdir.3, regex.3, remove.3, rewinddir.3, seekdir.3, sem_destroy.3, sem_getvalue.3, sem_unlink.3, sem_wait.3, setenv.3, setjmp.3, setlocale.3, setlogmask.3, signbit.3, sigpause.3, sigset.3, sigsetops.3, sigwait.3, sleep.3, sockatmark.3, statvfs.3, strcat.3, strchr.3, strcmp.3, strcoll.3, strcpy.3, strlen.3, strpbrk.3, strptime.3, strspn.3, strstr.3, strtod.3, strtoimax.3, strtok.3, strtol.3, strtoul.3, strxfrm.3, swab.3, sysconf.3, system.3, tcgetpgrp.3, tcgetsid.3, telldir.3, tmpfile.3, towctrans.3, tsearch.3, ttyname.3, tzset.3, ungetwc.3, unlocked_stdio.3, unlockpt.3, wcrtomb.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcslen.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstoimax.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wordexp.3, wprintf.3, fanotify.7, mq_overview.7, nptl.7, sem_overview.7, shm_overview.7, sigevent.7, symlink.7, ld.so.8: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-08-08 16:21:22 +00:00
|
|
|
.TH DLSYM 3 2015-08-08 "Linux" "Linux Programmer's Manual"
|
2015-07-16 07:58:59 +00:00
|
|
|
.SH NAME
|
|
|
|
dlsym, dlvsym \- obtain address of a symbol in a shared object or executable
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.B #include <dlfcn.h>
|
|
|
|
.sp
|
|
|
|
.BI "void *dlsym(void *" handle ", const char *" symbol );
|
|
|
|
.sp
|
|
|
|
.B #define _GNU_SOURCE
|
|
|
|
.br
|
|
|
|
.B #include <dlfcn.h>
|
|
|
|
.sp
|
|
|
|
.BI "void *dlvsym(void *" handle ", char *" symbol ", char *" version );
|
|
|
|
.sp
|
|
|
|
Link with \fI\-ldl\fP.
|
|
|
|
.SH DESCRIPTION
|
|
|
|
The function
|
|
|
|
.BR dlsym ()
|
|
|
|
takes a "handle" of a dynamic loaded shared object returned by
|
|
|
|
.BR dlopen (3)
|
|
|
|
along with a null-terminated symbol name,
|
|
|
|
and returns the address where that symbol is
|
|
|
|
loaded into memory.
|
|
|
|
If the symbol is not found, in the specified
|
|
|
|
object or any of the shared objects that were automatically loaded by
|
|
|
|
.BR dlopen (3)
|
|
|
|
when that object was loaded,
|
|
|
|
.BR dlsym ()
|
|
|
|
returns NULL.
|
|
|
|
(The search performed by
|
|
|
|
.BR dlsym ()
|
|
|
|
is breadth first through the dependency tree of these shared objects.)
|
|
|
|
|
|
|
|
Since the value of the symbol could actually be NULL (so that a
|
|
|
|
NULL return from
|
|
|
|
.BR dlsym ()
|
|
|
|
need not indicate an error), the correct way to test for an error
|
|
|
|
is to call
|
|
|
|
.BR dlerror (3)
|
|
|
|
to clear any old error conditions, then call
|
|
|
|
.BR dlsym (),
|
|
|
|
and then call
|
|
|
|
.BR dlerror (3)
|
|
|
|
again, saving its return value into a variable, and check whether
|
|
|
|
this saved value is not NULL.
|
|
|
|
.PP
|
|
|
|
There are two special pseudo-handles that may be specified in
|
|
|
|
.IR handle :
|
|
|
|
.TP
|
|
|
|
.B RTLD_DEFAULT
|
|
|
|
Find the first occurrence of the desired symbol
|
|
|
|
using the default shared object search order.
|
|
|
|
The search will include global symbols in the executable
|
|
|
|
and its dependencies,
|
|
|
|
as well as symbols in shared objects that were dynamically loaded with the
|
|
|
|
.BR RTLD_GLOBAL
|
|
|
|
flag.
|
|
|
|
.TP
|
|
|
|
.BR RTLD_NEXT
|
|
|
|
Find the next occurrence of the desired symbol in the search order
|
|
|
|
after the current object.
|
|
|
|
This allows one to provide a wrapper
|
|
|
|
around a function in another shared object, so that, for example,
|
|
|
|
the definition of a function in a preloaded shared object
|
|
|
|
(see
|
|
|
|
.B LD_PRELOAD
|
|
|
|
in
|
|
|
|
.BR ld.so (8))
|
|
|
|
can find and invoke the "real" function provided in another shared object
|
|
|
|
(or for that matter, the "next" definition of the function in cases
|
|
|
|
where there are multiple layers of preloading).
|
2016-05-13 08:59:06 +00:00
|
|
|
.PP
|
2015-07-16 07:58:59 +00:00
|
|
|
The function
|
|
|
|
.BR dlvsym ()
|
|
|
|
does the same as
|
|
|
|
.BR dlsym ()
|
|
|
|
but takes a version string as an additional argument.
|
|
|
|
.SH RETURN VALUE
|
|
|
|
On success,
|
|
|
|
these functions return the address associated with
|
|
|
|
.IR symbol .
|
|
|
|
On failure, they return NULL;
|
|
|
|
the cause of the error can be diagnosed using
|
|
|
|
.BR dlerror (3).
|
|
|
|
.SH VERSIONS
|
|
|
|
.BR dlsym ()
|
|
|
|
is present in glibc 2.0 and later.
|
|
|
|
.BR dlvsym ()
|
|
|
|
first appeared in glibc 2.1.
|
2015-07-19 12:51:35 +00:00
|
|
|
.SH ATTRIBUTES
|
|
|
|
For an explanation of the terms used in this section, see
|
|
|
|
.BR attributes (7).
|
|
|
|
.TS
|
|
|
|
allbox;
|
|
|
|
lb lb lb
|
|
|
|
l l l.
|
|
|
|
Interface Attribute Value
|
|
|
|
T{
|
|
|
|
.BR dlsym (),
|
|
|
|
.BR dlvsym ()
|
|
|
|
T} Thread safety MT-Safe
|
|
|
|
.TE
|
2015-07-16 07:58:59 +00:00
|
|
|
.SH CONFORMING TO
|
|
|
|
POSIX.1-2001 describes
|
|
|
|
.BR dlsym ().
|
|
|
|
The
|
|
|
|
.BR dlvsym ()
|
|
|
|
function is a GNU extension.
|
|
|
|
.SH NOTES
|
|
|
|
.SS History
|
|
|
|
The
|
|
|
|
.BR dlsym ()
|
|
|
|
function is part of the dlopen API, derived from SunOS.
|
|
|
|
That system does not have
|
|
|
|
.BR dlvsym ().
|
|
|
|
.SH EXAMPLE
|
|
|
|
See
|
|
|
|
.BR dlopen (3).
|
|
|
|
.SH SEE ALSO
|
|
|
|
.BR dl_iterate_phdr (3),
|
|
|
|
.BR dladdr (3),
|
2015-07-16 08:48:35 +00:00
|
|
|
.BR dlerror (3),
|
2015-07-16 07:58:59 +00:00
|
|
|
.BR dlinfo (3),
|
|
|
|
.BR dlopen (3),
|
|
|
|
.BR ld.so (8)
|