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

📄 alpha-relocs.html

📁 gcc手册
💻 HTML
字号:
<html lang="en">

<head>

<title>Using as</title>

<meta http-equiv="Content-Type" content="text/html">

<meta name="description" content="Using as">

<meta name="generator" content="makeinfo 4.3">

<link href="http://www.gnu.org/software/texinfo/" rel="generator-home">

</head>

<body>

<div class="node">

<p>

Node:<a name="Alpha-Relocs">Alpha-Relocs</a>,

Previous:<a rel="previous" accesskey="p" href="Alpha-Regs.html#Alpha-Regs">Alpha-Regs</a>,

Up:<a rel="up" accesskey="u" href="Alpha-Syntax.html#Alpha%20Syntax">Alpha Syntax</a>

<hr><br>

</div>



<h5 class="subsection">Relocations</h5>



   <p>Some of these relocations are available for ECOFF, but mostly

only for ELF.  They are modeled after the relocation format

introduced in Digial Unix 4.0, but there are additions.



   <p>The format is <code>!</code><var>tag</var><code></code> or <code>!</code><var>tag</var><code>!</code><var>number</var><code></code>

where <var>tag</var> is the name of the relocation.  In some cases

<var>number</var> is used to relate specific instructions.



   <p>The relocation is placed at the end of the instruction like so:



<pre class="example">     ldah  $0,a($29)    !gprelhigh

     lda   $0,a($0)     !gprellow

     ldq   $1,b($29)    !literal!100

     ldl   $2,0($1)     !lituse_base!100

     </pre>



     <dl>

<dt><code>!literal</code>

     <dd><dt><code>!literal!</code><var>N</var><code></code>

     <dd>Used with an <code>ldq</code> instruction to load the address of a symbol

from the GOT.



     <p>A sequence number <var>N</var> is optional, and if present is used to pair

<code>lituse</code> relocations with this <code>literal</code> relocation.  The

<code>lituse</code> relocations are used by the linker to optimize the code

based on the final location of the symbol.



     <p>Note that these optimizations are dependent on the data flow of the

program.  Therefore, if <em>any</em> <code>lituse</code> is paired with a

<code>literal</code> relocation, then <em>all</em> uses of the register set by

the <code>literal</code> instruction must also be marked with <code>lituse</code>

relocations.  This is because the original <code>literal</code> instruction

may be deleted or transformed into another instruction.



     <p>Also note that there may be a one-to-many relationship between

<code>literal</code> and <code>lituse</code>, but not a many-to-one.  That is, if

there are two code paths that load up the same address and feed the

value to a single use, then the use may not use a <code>lituse</code>

relocation.



     <br><dt><code>!lituse_base!</code><var>N</var><code></code>

     <dd>Used with any memory format instruction (e.g. <code>ldl</code>) to indicate

that the literal is used for an address load.  The offset field of the

instruction must be zero.  During relaxation, the code may be altered

to use a gp-relative load.



     <br><dt><code>!lituse_jsr!</code><var>N</var><code></code>

     <dd>Used with a register branch format instruction (e.g. <code>jsr</code>) to

indicate that the literal is used for a call.  During relaxation, the

code may be altered to use a direct branch (e.g. <code>bsr</code>).



     <br><dt><code>!lituse_bytoff!</code><var>N</var><code></code>

     <dd>Used with a byte mask instruction (e.g. <code>extbl</code>) to indicate

that only the low 3 bits of the address are relevant.  During relaxation,

the code may be altered to use an immediate instead of a register shift.



     <br><dt><code>!lituse_addr!</code><var>N</var><code></code>

     <dd>Used with any other instruction to indicate that the original address

is in fact used, and the original <code>ldq</code> instruction may not be

altered or deleted.  This is useful in conjunction with <code>lituse_jsr</code>

to test whether a weak symbol is defined.



     <pre class="example">          ldq  $27,foo($29)   !literal!1

          beq  $27,is_undef   !lituse_addr!1

          jsr  $26,($27),foo  !lituse_jsr!1

          </pre>



     <br><dt><code>!lituse_tlsgd!</code><var>N</var><code></code>

     <dd>Used with a register branch format instruction to indicate that the

literal is the call to <code>__tls_get_addr</code> used to compute the

address of the thread-local storage variable whose descriptor was

loaded with <code>!tlsgd!</code><var>N</var><code></code>.



     <br><dt><code>!lituse_tlsldm!</code><var>N</var><code></code>

     <dd>Used with a register branch format instruction to indicate that the

literal is the call to <code>__tls_get_addr</code> used to compute the

address of the base of the thread-local storage block for the current

module.  The descriptor for the module must have been loaded with

<code>!tlsldm!</code><var>N</var><code></code>.



     <br><dt><code>!gpdisp!</code><var>N</var><code></code>

     <dd>Used with <code>ldah</code> and <code>lda</code> to load the GP from the current

address, a-la the <code>ldgp</code> macro.  The source register for the

<code>ldah</code> instruction must contain the address of the <code>ldah</code>

instruction.  There must be exactly one <code>lda</code> instruction paired

with the <code>ldah</code> instruction, though it may appear anywhere in

the instruction stream.  The immediate operands must be zero.



     <pre class="example">          bsr  $26,foo

          ldah $29,0($26)     !gpdisp!1

          lda  $29,0($29)     !gpdisp!1

          </pre>



     <br><dt><code>!gprelhigh</code>

     <dd>Used with an <code>ldah</code> instruction to add the high 16 bits of a

32-bit displacement from the GP.



     <br><dt><code>!gprellow</code>

     <dd>Used with any memory format instruction to add the low 16 bits of a

32-bit displacement from the GP.



     <br><dt><code>!gprel</code>

     <dd>Used with any memory format instruction to add a 16-bit displacement

from the GP.



     <br><dt><code>!samegp</code>

     <dd>Used with any branch format instruction to skip the GP load at the

target address.  The referenced symbol must have the same GP as the

source object file, and it must be declared to either not use <code>$27</code>

or perform a standard GP load in the first two instructions via the

<code>.prologue</code> directive.



     <br><dt><code>!tlsgd</code>

     <dd><dt><code>!tlsgd!</code><var>N</var><code></code>

     <dd>Used with an <code>lda</code> instruction to load the address of a TLS

descriptor for a symbol in the GOT.



     <p>The sequence number <var>N</var> is optional, and if present it used to

pair the descriptor load with both the <code>literal</code> loading the

address of the <code>__tls_get_addr</code> function and the <code>lituse_tlsgd</code>

marking the call to that function.



     <p>For proper relaxation, both the <code>tlsgd</code>, <code>literal</code> and

<code>lituse</code> relocations must be in the same extended basic block. 

That is, the relocation with the lowest address must be executed

first at runtime.



     <br><dt><code>!tlsldm</code>

     <dd><dt><code>!tlsldm!</code><var>N</var><code></code>

     <dd>Used with an <code>lda</code> instruction to load the address of a TLS

descriptor for the current module in the GOT.



     <p>Similar in other respects to <code>tlsgd</code>.



     <br><dt><code>!gotdtprel</code>

     <dd>Used with an <code>ldq</code> instruction to load the offset of the TLS

symbol within its module's thread-local storage block.  Also known

as the dynamic thread pointer offset or dtp-relative offset.



     <br><dt><code>!dtprelhi</code>

     <dd><dt><code>!dtprello</code>

     <dd><dt><code>!dtprel</code>

     <dd>Like <code>gprel</code> relocations except they compute dtp-relative offsets.



     <br><dt><code>!gottprel</code>

     <dd>Used with an <code>ldq</code> instruction to load the offset of the TLS

symbol from the thread pointer.  Also known as the tp-relative offset.



     <br><dt><code>!tprelhi</code>

     <dd><dt><code>!tprello</code>

     <dd><dt><code>!tprel</code>

     <dd>Like <code>gprel</code> relocations except they compute tp-relative offsets. 

</dl>



   </body></html>



⌨️ 快捷键说明

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