173 lines
6.9 KiB
HTML
173 lines
6.9 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>dlsym</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="dlsym"></a> <a name="tag_03_112"></a><!-- dlsym -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_03_112_01"></a>NAME</h4>
|
|
|
|
<blockquote>dlsym - obtain the address of a symbol from a dlopen object</blockquote>
|
|
|
|
<h4><a name="tag_03_112_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<div class="box"><code><tt><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt=
|
|
"[Option Start]" border="0"> #include <<a href="../basedefs/dlfcn.h.html">dlfcn.h</a>><br>
|
|
<br>
|
|
void *dlsym(void *restrict</tt> <i>handle</i><tt>, const char *restrict</tt> <i>name</i><tt>); <img src="../images/opt-end.gif"
|
|
alt="[Option End]" border="0"></tt></code></div>
|
|
|
|
<tt><br>
|
|
</tt></blockquote>
|
|
|
|
<h4><a name="tag_03_112_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>dlsym</i>() function shall obtain the address of a symbol defined within an object made accessible through a <a href=
|
|
"../functions/dlopen.html"><i>dlopen</i>()</a> call. The <i>handle</i> argument is the value returned from a call to <a href=
|
|
"../functions/dlopen.html"><i>dlopen</i>()</a> (and which has not since been released via a call to <a href=
|
|
"../functions/dlclose.html"><i>dlclose</i>()</a>), and <i>name</i> is the symbol's name as a character string.</p>
|
|
|
|
<p>The <i>dlsym</i>() function shall search for the named symbol in all objects loaded automatically as a result of loading the
|
|
object referenced by <i>handle</i> (see <a href="dlopen.html"><i>dlopen</i>()</a> ). Load ordering is used in <i>dlsym</i>()
|
|
operations upon the global symbol object. The symbol resolution algorithm used shall be dependency order as described in <a href=
|
|
"dlopen.html"><i>dlopen</i>()</a> .</p>
|
|
|
|
<p>The RTLD_DEFAULT and RTLD_NEXT flags are reserved for future use.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_112_04"></a>RETURN VALUE</h4>
|
|
|
|
<blockquote>
|
|
<p>If <i>handle</i> does not refer to a valid object opened by <a href="../functions/dlopen.html"><i>dlopen</i>()</a>, or if the
|
|
named symbol cannot be found within any of the objects associated with <i>handle</i>, <i>dlsym</i>() shall return NULL. More
|
|
detailed diagnostic information shall be available through <a href="dlerror.html"><i>dlerror</i>()</a> .</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_112_05"></a>ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>No errors are defined.</p>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_03_112_06"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>The following example shows how <a href="../functions/dlopen.html"><i>dlopen</i>()</a> and <i>dlsym</i>() can be used to access
|
|
either function or data objects. For simplicity, error checking has been omitted.</p>
|
|
|
|
<pre>
|
|
<tt>void *handle;
|
|
int *iptr, (*fptr)(int);
|
|
<br>
|
|
/* open the needed object */
|
|
handle = dlopen("/usr/home/me/libfoo.so", RTLD_LOCAL | RTLD_LAZY);
|
|
<br>
|
|
/* find the address of function and data objects */
|
|
fptr = (int (*)(int))dlsym(handle, "my_function");
|
|
iptr = (int *)dlsym(handle, "my_object");
|
|
<br>
|
|
/* invoke function, passing value of integer as a parameter */
|
|
(*fptr)(*iptr);
|
|
</tt>
|
|
</pre>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_112_07"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>Special purpose values for <i>handle</i> are reserved for future use. These values and their meanings are:</p>
|
|
|
|
<dl compact>
|
|
<dt>RTLD_DEFAULT</dt>
|
|
|
|
<dd>The symbol lookup happens in the normal global scope; that is, a search for a symbol using this handle would find the same
|
|
definition as a direct use of this symbol in the program code.</dd>
|
|
|
|
<dt>RTLD_NEXT</dt>
|
|
|
|
<dd>Specifies the next object after this one that defines <i>name</i>. <i>This one</i> refers to the object containing the
|
|
invocation of <i>dlsym</i>(). The <i>next</i> object is the one found upon the application of a load order symbol resolution
|
|
algorithm (see <a href="dlopen.html"><i>dlopen</i>()</a> ). The next object is either one of global scope (because it was
|
|
introduced as part of the original process image or because it was added with a <a href=
|
|
"../functions/dlopen.html"><i>dlopen</i>()</a> operation including the RTLD_GLOBAL flag), or is an object that was included in the
|
|
same <a href="../functions/dlopen.html"><i>dlopen</i>()</a> operation that loaded this one.
|
|
|
|
<p>The RTLD_NEXT flag is useful to navigate an intentionally created hierarchy of multiply-defined symbols created through
|
|
<i>interposition</i>. For example, if a program wished to create an implementation of <a href=
|
|
"../functions/malloc.html"><i>malloc</i>()</a> that embedded some statistics gathering about memory allocations, such an
|
|
implementation could use the real <a href="../functions/malloc.html"><i>malloc</i>()</a> definition to perform the memory
|
|
allocation-and itself only embed the necessary logic to implement the statistics gathering function.</p>
|
|
</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_112_08"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_112_09"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_112_10"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="dlclose.html"><i>dlclose</i>()</a> , <a href="dlerror.html"><i>dlerror</i>()</a> , <a href=
|
|
"dlopen.html"><i>dlopen</i>()</a> , the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/dlfcn.h.html"><i><dlfcn.h></i></a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_112_11"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 5.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_112_12"></a>Issue 6</h4>
|
|
|
|
<blockquote>
|
|
<p>The <b>restrict</b> keyword is added to the <i>dlsym</i>() prototype for alignment with the ISO/IEC 9899:1999 standard.</p>
|
|
|
|
<p>The RTLD_DEFAULT and RTLD_NEXT flags are reserved for future use.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|