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

📄 loadlib.html

📁 vxworks相关论文
💻 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.html"><i>VxWorks Reference Manual :  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><i><a href="./loadLib.html#loadModule">loadModule</a></i>(&nbsp;)</b>  -  load an object module into memory<br><b><i><a href="./loadLib.html#loadModuleAt">loadModuleAt</a></i>(&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="./loadLib.html#top">loadLib</a></b>, <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.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>loadModule</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>loadModule</i>(&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 | LOCAL | 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><i><a href="./loadLib.html#loadModuleAt">loadModuleAt</a></i>(&nbsp;)</b> with NULL for the addresses oftext, data, and BSS segments.  For more details, see the manual entry for<b><i><a href="./loadLib.html#loadModuleAt">loadModuleAt</a></i>(&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><i><a href="./loadLib.html#loadModuleAt">loadModuleAt</a></i>(&nbsp;)</b><hr><a name="loadModuleAt"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>loadModuleAt</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>loadModuleAt</i>(&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 | LOCAL | GLOBAL | */    char * *ppText, /* load text segment at addr. pointed to by this ptr, */                    /* load addr. via this ptr */    char * *ppData, /* load data segment at addr. pointed to by this */                    /* return load addr. via this ptr */    char * *ppBss   /* load BSS segment at addr. pointed to by this pointer, */                    /* 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><i><a href="./memPartLib.html#malloc">malloc</a></i>(&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 are resolvedby looking up the missing symbols in the the system symbol table.If found, those references are correctly linked to the new module.If unresolved external references cannot be found in the system symboltable, then an error message ("undefined symbol: ...") is printed forthe symbol, but the loading/linking continues.  In this case, NULL willbe returned after the module is loaded.<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<p><dt><b>LOAD_LOCAL_SYMBOLS</b><dd>add only local symbols to the system symbol table<p><dt><b>LOAD_GLOBAL_SYMBOLS</b><dd>add only external symbols to the system symbol table<p><dt><b>LOAD_ALL_SYMBOLS</b><dd>add both local and external symbols to the system symbol table<p><dt><b>HIDDEN_MODULE</b><dd> do not display the module via <b><i><a href="./moduleLib.html#moduleShow">moduleShow</a></i>(&nbsp;)</b>. </dl><p>In addition, the following symbols are also added to the symbol tableto indicate the start of each segment:<i>filename</i>_text, <i>filename</i>_data, and <i>filename</i>_bss,where <i>filename</i> is the name associated with the fd.<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;<p><dt>A pointer to <b>LD_NO_ADDRESS</b><dd>no load address is specified, the return address is referenced by the pointer;<p><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><i><a href="./loadLib.html#loadModuleAt">loadModuleAt</a></i>(&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><dl><dt>(1)<dd>Allocate memory for a section (text in this example):  <i>ppText</i> == NULL<p><dt>(2)<dd> Begin a section at address zero (the text section, below):  *<i>ppText</i> == 0 </dl><p>Note that <b><i><a href="./loadLib.html#loadModule">loadModule</a></i>(&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 internally use another storage classknown as <i>common</i>.  In the C language, uninitialized global variablesare eventually 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 afully linked object module.  However, the VxWorks loader is most oftenused to load partially linked object modules.  When the VxWorks loaderencounters a variable labeled as common, memory for the variableis allocated, with <b><i><a href="./memPartLib.html#malloc">malloc</a></i>(&nbsp;)</b>, and the variable is entered in the systemsymbol table (if specified) at that address.  Note that most UNIXloaders have an option that forces resolution of the common storagewhile leaving the module relocatable (e.g., with typical BSD UNIX loaders,use options <b>-rd</b>).<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,or the file format is illegal.<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 + -