⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loadlib.html

📁 Vxworks API操作系统和驱动程序设计API。压缩的HTML文件
💻 HTML
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/loadLib.html - generated by refgen from loadLib.c --> <title> loadLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.htm"><i>VxWorks API Reference :  OS Libraries</i></a></p></blockquote><h1>loadLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>loadLib</strong> - object module loader </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><a href="./loadLib.html#loadModule">loadModule</a>(&nbsp;)</b>  -  load an object module into memory<br><b><a href="./loadLib.html#loadModuleAt">loadModuleAt</a>(&nbsp;)</b>  -  load an object module into memory<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides a generic object module loading facility.  Anysupported format files may be loaded into memory, relocated properly, theirexternal references resolved, and their external definitions added tothe system symbol table for use by other modules and from the shell.Modules may be loaded from any I/O stream which allows repositioning of thepointer.  This includes <b><a href="./netDrv.html#top">netDrv</a></b>, nfs, or local file devices.  It does not include sockets.<p></blockquote><h4>EXAMPLE</h4><blockquote><p><pre>    fdX = open ("/devX/objFile", O_RDONLY);    loadModule (fdX, LOAD_ALL_SYMBOLS);    close (fdX);</pre>This code fragment would load the object file "objFile" located ondevice "/devX/" into memory which would be allocated from the systemmemory pool.  All external and static definitions from the file would beadded to the system symbol table.<p>This could also have been accomplished from the shell, by typing:<pre>    -&gt; ld (1) &lt;/devX/objFile</pre></blockquote><h4>INCLUDE FILE</h4><blockquote><p><b>loadLib.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./usrLib.html#top">usrLib</a></b>, <b><a href="./symLib.html#top">symLib</a></b>, <b><a href="./memLib.html#top">memLib</a></b>,<i>VxWorks Programmer's Guide: Basic OS </i><hr><a name="loadModule"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries :  Routines</i></a></p></blockquote><h1>loadModule(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>loadModule(&nbsp;)</strong> - load an object module into memory</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>MODULE_ID loadModule    (    int              fd,      /* fd of file to load */    int              symFlag  /* symbols to add to table (LOAD_[NO    ALL]_SYMBOLS) */ GLOBAL    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine loads an object module from the specified file, and placesthe code, data, and BSS into memory allocated from the system memorypool.<p>This call is equivalent to <b><a href="./loadLib.html#loadModuleAt">loadModuleAt</a>(&nbsp;)</b> with NULL for the addresses oftext, data, and BSS segments.  For more details, see the manual entry for<b><a href="./loadLib.html#loadModuleAt">loadModuleAt</a>(&nbsp;)</b>.<p></blockquote><h4>RETURNS</h4><blockquote><p><p><b>MODULE_ID</b>, or NULL if the routine cannot read the file, there is notenough memory, or the file format is illegal.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./loadLib.html#top">loadLib</a></b>, <b><a href="./loadLib.html#loadModuleAt">loadModuleAt</a>(&nbsp;)</b><hr><a name="loadModuleAt"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries :  Routines</i></a></p></blockquote><h1>loadModuleAt(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>loadModuleAt(&nbsp;)</strong> - load an object module into memory</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>MODULE_ID loadModuleAt    (    int    fd,                /* fd from which to read module */    int    symFlag,           /* symbols to add to table (LOAD_[NO    char * *ppText,           /* load text segment at addr. pointed to by */                              /* this ptr, return load addr. via this ptr */     char * *ppData,           /* load data segment at addr. pointed to by */                              /* this pointer, return load addr. via this */                              /* ptr */     char * *ppBss             /* load BSS segment at addr. pointed to by */                              /* this pointer, return load addr. via this */                              /* ptr */     )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine reads an object module from <i>fd</i>, and loads the code, data,and BSS segments at the specified load addresses in memory set aside bythe user using <b><a href="./memPartLib.html#malloc">malloc</a>(&nbsp;)</b>, or in the system memory partition as describedbelow.  The module is properly relocated according to the relocationcommands in the file.  Unresolved externals will be linked to symbolsfound in the system symbol table.  Symbols in the module being loaded canoptionally be added to the system symbol table.<p></blockquote><h4>LINKING UNRESOLVED EXTERNALS </h4><blockquote><p>As the module is loaded, any unresolved external references areresolved by looking up the missing symbols in the the system symboltable.  If found, those references are correctly linked to the newmodule.  If unresolved external references cannot be found in thesystem symbol table, then an error message ("undefined symbol: ...")is printed for the symbol, but the loading/linking continues.  Thepartially resolved module is not removed, to enable the user toexamine the module for debugging purposes.  Care should be takenwhen executing code from the resulting module.  Executing code which contains references to unresolved symbols may have unexpected results and may corrupt the system's memory.<p>Even though a module with unresolved symbols remains loaded after thisroutine returns, NULL will be returned to enable the caller to detectthe failure programatically.  To unload the module, the caller mayeither call the unload routine with the module name, or look up themodule using the module name and then unload the module using the returned <b>MODULE_ID</b>.  See the library entries for <b><a href="./moduleLib.html#top">moduleLib</a></b> and <b><a href="./unldLib.html#top">unldLib</a></b>for details.  The name of the module is the name of the file loaded withthe path removed.<p></blockquote><h4>ADDING SYMBOLS TO THE SYMBOL TABLE</h4><blockquote><p>The symbols defined in the module to be loaded may be optionally addedto the system symbol table, depending on the value of <i>symFlag</i>:<dl><dt><b>LOAD_NO_SYMBOLS</b><dd>add no symbols to the system symbol table<dt><b>LOAD_LOCAL_SYMBOLS</b><dd>add only local symbols to the system symbol table<dt><b>LOAD_GLOBAL_SYMBOLS</b><dd>add only external symbols to the system symbol table<dt><b>LOAD_ALL_SYMBOLS</b><dd>add both local and external symbols to the system symbol table<dt><b>HIDDEN_MODULE</b><dd>do not display the module via <b><a href="./moduleLib.html#moduleShow">moduleShow</a>(&nbsp;)</b>.</dl><p>Obsolete symbols:<p>For backward compatibility with previous releases, the following symbolsare also added to the symbol table to indicate the start of each segment:<i>filename</i>_text, <i>filename</i>_data, and <i>filename</i>_bss, where <i>filename</i> isthe name associated with the fd. Note that these symbols are not available when the ELF format is used. Also they will disappear with the next VxWorksrelease. The <b><a href="./moduleLib.html#top">moduleLib</a></b> API should be used instead to get segment information.<p></blockquote><h4>RELOCATION</h4><blockquote><p>The relocation commands in the object module are used to relocatethe text, data, and BSS segments of the module.  The location of eachsegment can be specified explicitly, or left unspecified in whichcase memory will be allocated for the segment from the system memorypartition.  This is determined by the parameters <i>ppText</i>, <i>ppData</i>, and<i>ppBss</i>, each of which can have the following values:<dl><dt>NULL<dd>no load address is specified, none will be returned;<dt>A pointer to <b>LD_NO_ADDRESS</b><dd>no load address is specified, the return address is referenced by the pointer;<dt>A pointer to an address<dd>the load address is specified.</dl><p>The <i>ppText</i>, <i>ppData</i>, and <i>ppBss</i> parameters specify where to loadthe text, data, and bss sections respectively.  Each of theseparameters is a pointer to a  pointer; for example, **<i>ppText</i>gives the address where the text segment is to begin.<p>For any of the three parameters, there are two ways to request thatnew memory be allocated, rather than specifying the section'sstarting address: you can either specify the parameter itself asNULL, or you can write the constant <b>LD_NO_ADDRESS</b> in place of anaddress.  In the second case, <b><a href="./loadLib.html#loadModuleAt">loadModuleAt</a>(&nbsp;)</b> routine replaces the<b>LD_NO_ADDRESS</b> value with the address actually used for each section(that is, it records the address at *<i>ppText</i>, *<i>ppData</i>, or*<i>ppBss</i>).<p>The double indirection not only permits reporting the addressesactually used, but also allows you to specify loading a segmentat the beginning of memory, since the following cases can bedistinguished:<p><table></tr><tr valign=top><td>(1)<td>Allocate memory for a section (text in this example):  <i>ppText</i> == NULL</tr><tr valign=top><td>(2)<td>Begin a section at address zero (the text section, below):  *<i>ppText</i> == 0</table>Note that <b><a href="./loadLib.html#loadModule">loadModule</a>(&nbsp;)</b> is equivalent to this routine if all three of thesegment-address parameters are set to NULL.<p></blockquote><h4>COMMON</h4><blockquote><p>Some host compiler/linker combinations use another storage class internallycalled "common".  In the C language, uninitialized global variables areeventually put in the bss segment.  However, in partially linked objectmodules they are flagged internally as "common" and the static linker (host) resolves these and places them in bss as a final step in creating a fully linked object module.  However, the target loaderis most often used to load partially linked object modules.When the target loader encounters a variable labeled "common",its behavior depends on the following flags :<dl><dt><b>LOAD_COMMON_MATCH_NONE</b><dd>Allocate memory for the variable with <b><a href="./memPartLib.html#malloc">malloc</a>(&nbsp;)</b> and enter the variablein the target symbol table (if specified) at that address. This isthe default.<dt><b>LOAD_COMMON_MATCH_USER</b><dd>Search for the symbol in the target symbol table, excluding thevxWorks image  symbols. If several symbols exist, then the order of matchingis:  (1) bss, (2) data. If no symbol is found, act like thedefault.<dt><b>LOAD_COMMON_MATCH_ALL</b><dd>Search for the symbol in the target symbol table, including thevxWorks image symbols. If several symbols exist, then the order of matching is:  (1) bss, (2) data. If no symbol is found, act like the default.</dl>Note that most UNIX loaders have an option that forces resolution of thecommon storage while leaving the module relocatable (for example, withtypical BSD UNIX loaders, use options "-rd").<p></blockquote><h4>EXAMPLES</h4><blockquote><p>Load a module into allocated memory, but do not return segment addresses:<pre>    module_id = loadModuleAt (fd, LOAD_GLOBAL_SYMBOLS, NULL, NULL, NULL);</pre>Load a module into allocated memory, and return segment addresses:<pre>    pText = pData = pBss = LD_NO_ADDRESS;    module_id = loadModuleAt (fd, LOAD_GLOBAL_SYMBOLS, &amp;pText, &amp;pData, &amp;pBss);</pre>Load a module to off-board memory at a specified address:<pre>    pText = 0x800000;                 /* address of text segment        */    pData = pBss = LD_NO_ADDRESS      /* other segments follow by default */    module_id = loadModuleAt (fd, LOAD_GLOBAL_SYMBOLS, &amp;pText, &amp;pData, &amp;pBss);</pre></blockquote><h4>RETURNS</h4><blockquote><p><p><b>MODULE_ID</b>, orNULL if the file cannot be read, there is not enough memory,the file format is illegal, or there were unresolved symbols.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./loadLib.html#top">loadLib</a></b>, <i>VxWorks Programmer's Guide: Basic OS</i></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -