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

📄 c-loader9.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title>    Object-Module Loader   </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="c-loader.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-loader.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-loader8.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-wtx.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="85068">3.9  &nbsp;&nbsp;Writing an OMF Manager</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85070"> </a>The remainder of this chapter describes how to write a new OMF manager. Code examples are based on Wind River Systems OMF managers. They do not cover every possible situation, but they do illustrate common OMF issues.</p><dd><p class="Body"><a name="85071"> </a>In the remaining sections, comments enclosed between square braces (<i class="i">[comment]</i>) in the code fragments indicate lines of code not detailed for the sake of clarity. Function calls with <i class="term">Omf</i> as part of the name, with or without parameters indicated by (...), are examples of how to use function calls.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="85072">3.9.1  &nbsp;&nbsp;Dynamically Linked Library Implementation</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85074"> </a>An OMF manager and its RUs form a single component, the OMF reader. The OMF reader is implemented as two dynamically linked libraries (DLL): one for the OMF manager and a second for the relocation unit. The DLLs offer the ability to load and unload portions of code at run time. They can be shared by programs without being linked into the programs. DLLs have several advantages:</p></dl><dl class="margin"><p class="listspace"><ul class="Bullet" type="disc"><li><a name="85075"> </a><font face="Helvetica, sans-serif" size="-1" class="sans"><b class="hb">Program Size</b></font>: Since only the required pieces of code are loaded, the program (in this case the target server) uses less memory.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="85076"> </a><font face="Helvetica, sans-serif" size="-1" class="sans"><b class="hb">Scalability</b></font>: It is possible to build an application dynamically from a reduced set of routines that exactly fits the user's needs.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="85077"> </a><font face="Helvetica, sans-serif" size="-1" class="sans"><b class="hb">Flexibility</b></font>: It is easy to add function without recompiling the main program.</li></ul></p></dl></dl><dl class="margin"><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/note.gif"></td><td><hr><div class="CalloutCell"><a name="88635"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">NOTE:  </font></b></a>DLLs should export only necessary data to maintain good performance.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout><dl class="margin"><dd><p class="Body"><a name="85087"> </a>The OMF-reader code is common to all supported platforms.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="85089">3.9.2  &nbsp;&nbsp;Installing a Shared-Library Manager</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85091"> </a>The target server reads <i class="textVariable">installDir</i><b class="file">/host/resource/target/architecturedb</b> when it starts. This resource file establishes the relationship between the target CPU family, the object-module format, the relocation unit, and the corresponding shared libraries. OMF and RU names are established according to the conventions outlined in <a href="c-loader9.html#85097"><i class="title">3.9.3&nbsp;Naming Conventions</i></a>. Shared libraries are listed without their extensions because the extension is architecture dependent (<b class="file">.so </b>for Solaris, <b class="file">.sl</b> for HP-UX, and <b class="file">.dll</b> for Windows NT). </p><dd><p class="Body"><a name="85095"> </a>At initialization, the target server attaches in turn each OMF manager listed in the resource file. It tests whether or not the OMF manager can handle the core file and if not, detaches it. When the target server finds an OMF manager that can read the core file format, it keeps that OMF manager attached and continues with initialization. If it finds no appropriate OMF manager, it exits with an error message.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="85097">3.9.3  &nbsp;&nbsp;Naming Conventions</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85099"> </a>In addition to the Wind River Systems coding conventions, specific naming conventions are adopted by the loader for the OMF-manager and RU interface routines, and for the related shared libraries file names.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85101">Interface Routines</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85102"> </a>The <i class="term">Omf</i> part of both OMF and RU routine names depends on the OMF strings supported for a given CPU, which are defined by <b class="symbol_lc">Object File Type</b> in the <i class="textVariable">installDir</i><b class="file">/host/resource/target/architecturedb</b> file. These strings are read by the target server and used to build the routine names. The following rules apply:</p></dl><dl class="margin"><p class="listspace"><ul class="Dash" type="circle"><li><a name="85103"> </a>Only the alphanumeric portion of the string is kept.</li></ul></p><p class="listspace"><ul class="Dash" type="circle"><li><a name="85104"> </a>No matter what letter case is used in the string, for OMF routines the first letter is converted to uppercase and all others are converted to lowercase. For example, "a.out" becomes "Aout" and "COFF" becomes "Coff". For RU routines, all characters are lowercase.</li></ul></p></dl><dl class="margin"><dd><p class="Body"><a name="85105"> </a>The <i class="term">Cpu</i> part of the RU routine name is defined in the <b class="symbol_lc">ExtentionName</b><b class="symbol_UC"> </b>field in the <i class="textVariable">installDir</i><b class="file">/host/resource/target/architecturedb</b> file. </p></dl><dl class="margin"><b class="HU-bullet"><li><a name="85106"> </a><font face="Helvetica, sans-serif" size="-1" class="sans"><font face="Helvetica, sans-serif" size="-1" class="sans"><b class="hb">OMF Manager</b></font>: </font></li></b></dl><dl class="margin"><dd><p class="Body"><a name="85107"> </a>The OMF manager has three interface routines: <b class="routine"><i class="routine">load</i></b><i class="term">Omf</i><b class="routine"><i class="routine">FmtManage</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">load</i></b><i class="term">Omf</i><b class="routine"><i class="routine">FmtCheck</i></b><b>(&nbsp;)</b>, and <b class="routine"><i class="routine">load</i></b><i class="term">Omf</i><b class="routine"><i class="routine">FmtInit</i></b><b>(&nbsp;)</b>. <i class="term">Omf</i> is the only variant portion of the name and reflects the OMF as follows:<p class="table"><h4 class="EntityTitle"><a name="85110"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 3-1:&nbsp;&nbsp;OMF Manager Function Names</font></a></h4><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeadingC" align="center"><a name="85116"> </a><b><font face="Helvetica, sans-serif" size="-1" class="sans">OMF   </font></b></div></th><td width="10">&nbsp;</td><th rowspan="1" colspan="1"><div class="CellHeadingC" align="center"><a name="85118"> </a><b><font face="Helvetica, sans-serif" size="-1" class="sans"> Variant part </font></b></div></th><td width="10">&nbsp;</td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="85120"> </a><font face="Helvetica, sans-serif" size="-1" class="sans"> Function name</font></b></div></th><td width="10">&nbsp;</td></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="85122"> </a><i class="acronym_lc">a.out</i> </div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="85124"> </a> Aout     </div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="85126"> </a> <b class="routine"><i class="routine">loadAoutFmtManage</i></b><b>(&nbsp;)</b> </div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="85128"> </a>COFF </div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="85130"> </a> Coff     </div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="85132"> </a> <b class="routine"><i class="routine">loadCoffFmtManage</i></b><b>(&nbsp;)</b> </div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="85134"> </a>ELF   </div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="85136"> </a> Elf      </div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="85138"> </a> <b class="routine"><i class="routine">loadElfFmtManage</i></b><b>(&nbsp;)</b> </div></td><td width="10">&nbsp;</td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p></p></dl><dl class="margin"><b class="HU-bullet"><li><a name="85139"> </a><font face="Helvetica, sans-serif" size="-1" class="sans"><font face="Helvetica, sans-serif" size="-1" class="sans"><b class="hb">RU</b></font>:</font></li></b></dl><dl class="margin"><dd><p class="Body"><a name="85140"> </a>The interface routines are similar to <i class="term">omfCpu</i><b class="routine"><i class="routine">SegReloc</i></b><b>(&nbsp;)</b><b class="routine"><i class="routine">.</i></b> Again, <i class="term">omf</i> and <i class="term">Cpu</i> are the only variant parts; They reflect the OMF and the CPU as shown:<p class="table"><h4 class="EntityTitle"><a name="85143"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 3-2:&nbsp;&nbsp;RU Function Names</font></a></h4><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeadingC" align="center"><a name="85151"> </a><b><font face="Helvetica, sans-serif" size="-1" class="sans">OMF   </font></b></div></th><td width="10">&nbsp;</td><th rowspan="1" colspan="1"><div class="CellHeadingC" align="center"><a name="85153"> </a><b><font face="Helvetica, sans-serif" size="-1" class="sans"> Cpu name</font></b></div></th><td width="10">&nbsp;</td><th rowspan="1" colspan="1"><div class="CellHeadingC" align="center"><a name="85155"> </a><b><font face="Helvetica, sans-serif" size="-1" class="sans"> Variant parts </font></b></div></th><td width="10">&nbsp;</td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="85157"> </a><font face="Helvetica, sans-serif" size="-1" class="sans"> Function name</font></b></div></th><td width="10">&nbsp;</td></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="85159"> </a><i class="acronym_lc">a.out</i> </div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="85161"> </a> MC680<i class="textVariable">x</i>0 </div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="85163"> </a>   Aout - 68k    </div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="85165"> </a> <b class="routine"><i class="routine">aout68kSegReloc</i></b><b>(&nbsp;)</b> </div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="85167"> </a><i class="acronym_lc">a.out</i> </div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="85169"> </a>   SPARC </div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="85171"> </a>   Aout - Sparc </div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="85173"> </a> <b class="routine"><i class="routine">aoutSparcSegReloc</i></b><b>(&nbsp;)</b> </div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="87920"> </a><i class="acronym_lc">a.out</i> </div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="87922"> </a>X86 </div></td>

⌨️ 快捷键说明

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