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

📄 reloc.html

📁 我在网上下的
💻 HTML
字号:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
   <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win95; I) [Netscape]">
   <title>COFF: Relocation Directives</title>
</head>
<body>

<center><table BORDER=0 CELLSPACING=0 CELLPADDING=3 WIDTH="100%" >
<tr>
<td ALIGN=LEFT VALIGN=TOP BGCOLOR="#FFCC99"><b><font face="itc avant garde gothic,helvetica,arial">&nbsp;
<a href="/" target="_top">www.delorie.com</a>/<a href="/djgpp/" target="_top">djgpp</a>/<a href="/djgpp/doc/" target="_top">doc</a>/<a href="/djgpp/doc/coff/" target="_top">coff</a>/reloc.html</font></b></td>

<td ALIGN=RIGHT VALIGN=TOP BGCOLOR="#FFCC99"><b><font face="itc avant garde gothic,helvetica,arial">&nbsp;
<a href="/search/">search</a></font></b></td>
</tr>
</table></center>

<center><b><font size=-1>COFF: Relocation Directives</font></b></center>

<pre>typedef struct {
&nbsp; unsigned long&nbsp; <b>r_vaddr</b>;&nbsp;&nbsp; /* address of relocation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp; unsigned long&nbsp; <b>r_symndx</b>;&nbsp; /* symbol we're adjusting for */
&nbsp; unsigned short <b>r_type</b>;&nbsp;&nbsp;&nbsp; /* type of relocation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */
} <b>RELOC</b>;</pre>
<i>Warning:</i> This structure's size is not a multiple of four. When reading
from file, it is strongly recommended that either (1) you read each entry
in a loop, reading <tt>RELSZ</tt> bytes each time, or allocate a block
of memory and calculate a pointer to each entry you need by multiplying
by <tt>RELSZ</tt>. In no case should you assume that array addressing or
<tt>sizeof(RELOC)</tt> will be useful.
<p>There are only two types of relocations that you will encounter in a
normal DJGPP COFF object.
<center><table>
<tr>
<th>Type
<hr noshade size=1></th>

<th>Value
<hr noshade size=1></th>

<th>Purpose
<hr noshade size=1></th>
</tr>

<tr VALIGN=TOP>
<td><tt>RELOC_ADDR32</tt></td>

<td ALIGN=CENTER>6</td>

<td>Relocate a 32-bit absolute reference</td>
</tr>

<tr VALIGN=TOP>
<td><tt>RELOC_REL32</tt></td>

<td ALIGN=CENTER>20</td>

<td>Relocate a 32-bit relative reference</td>
</tr>
</table></center>

<p>For any relocation, you must determine the new address of the relocated
symbol that we are adjusting for. If the symbol is in another object (external),
<a href="symtab.html">the symbol table</a> will contain a reference to
that external symbol, and the relocation will refer to that symbol table
entry. If the symbol is in the same object, the symbol table will have
entries that refer to the sections themselves (always there and always
private) that will be referred to. When you relocate the section itself,
these symbols will reflect its new location.
<p><b><tt>RELOC_ADDR32</tt></b>
<p>To do this relocation, you must perform the following steps:
<ul>
<li>
Get the address of the symbol referred to.</li>

<li>
Add the value currently stored in the location being adjusted.</li>

<li>
Store the value back into the location being adjusted.</li>
</ul>
<b><tt>RELOC_REL32</tt></b>
<p>This relocation happens normally only in executable sections, and refers
only to external symbols. To do this relocation, you must perform the following
steps:
<ul>
<li>
Get the address of the symbol referred to.</li>

<li>
Add the value currently stored in the location being adjusted.</li>

<li>
Subtract the address of the beginning of the section.</li>

<li>
Add the original (unrelocated) address of the beginning of this section.
Normally this is zero for DJGPP as only the _text section, which is first
(and thus at unrelocated address zero), has relative relocs.</li>

<br><i>Note:</i> The preceeding two steps can be replaced with the single
step of "subtract the amount you moved this section".
<li>
Store the value back into the location being adjusted.</li>
</ul>

<table BORDER=0 CELLSPACING=0 CELLPADDING=3 WIDTH="100%" >
<tr>
<td ALIGN=LEFT VALIGN=TOP BGCOLOR="#FFCC99"><b><font face="itc avant garde gothic,helvetica,arial">&nbsp;
<a href="/users/dj/" target="_top">webmaster</a>&nbsp;

<a href="/donations.html" target="_top">donations</a>&nbsp; 
<a href="/store/books/" target="_top">bookstore</a></font></b></td>

<td ALIGN=RIGHT VALIGN=TOP BGCOLOR="#FFCC99"><b><font face="itc avant garde gothic,helvetica,arial">&nbsp;
<a href="/" target="_top">delorie
software</a>&nbsp; 
<a href="/privacy.html" target="_top">privacy</a></font></b></td>
</tr>

<tr>
<td ALIGN=LEFT VALIGN=TOP BGCOLOR="#FFCC99"><b><font face="itc avant garde gothic,helvetica,arial">&nbsp;
<a href="/copyright.html" target="_top">Copyright

⌨️ 快捷键说明

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