neingeist
/
arduinisten
Archived
1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

180 lines
8.2 KiB
HTML

<html lang="en">
<head>
<title>Sparc-Relocs - Using as</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Using as">
<meta name="generator" content="makeinfo 4.7">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Sparc_002dSyntax.html#Sparc_002dSyntax" title="Sparc-Syntax">
<link rel="prev" href="Sparc_002dConstants.html#Sparc_002dConstants" title="Sparc-Constants">
<link rel="next" href="Sparc_002dSize_002dTranslations.html#Sparc_002dSize_002dTranslations" title="Sparc-Size-Translations">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This file documents the GNU Assembler "as".
Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002,
2006, 2007 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1
or any later version published by the Free Software Foundation;
with no Invariant Sections, with no Front-Cover Texts, and with no
Back-Cover Texts. A copy of the license is included in the
section entitled ``GNU Free Documentation License''.
man end-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family: serif; font-weight: normal; }
--></style>
</head>
<body>
<div class="node">
<p>
<a name="Sparc_002dRelocs"></a>Next:&nbsp;<a rel="next" accesskey="n" href="Sparc_002dSize_002dTranslations.html#Sparc_002dSize_002dTranslations">Sparc-Size-Translations</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Sparc_002dConstants.html#Sparc_002dConstants">Sparc-Constants</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Sparc_002dSyntax.html#Sparc_002dSyntax">Sparc-Syntax</a>
<hr><br>
</div>
<h5 class="subsubsection">9.30.3.4 Relocations</h5>
<p><a name="index-Sparc-relocations-1518"></a><a name="index-relocations_002c-Sparc-1519"></a>
ELF relocations are available as defined in the 32-bit and 64-bit
Sparc ELF specifications.
<p><code>R_SPARC_HI22</code> is obtained using <span class="samp">%hi</span> and <code>R_SPARC_LO10</code>
is obtained using <span class="samp">%lo</span>. Likewise <code>R_SPARC_HIX22</code> is
obtained from <span class="samp">%hix</span> and <code>R_SPARC_LOX10</code> is obtained
using <span class="samp">%lox</span>. For example:
<pre class="example"> sethi %hi(symbol), %g1
or %g1, %lo(symbol), %g1
sethi %hix(symbol), %g1
xor %g1, %lox(symbol), %g1
</pre>
<p>These &ldquo;high&rdquo; mnemonics extract bits 31:10 of their operand,
and the &ldquo;low&rdquo; mnemonics extract bits 9:0 of their operand.
<p>V9 code model relocations can be requested as follows:
<ul>
<li><code>R_SPARC_HH22</code> is requested using <span class="samp">%hh</span>. It can
also be generated using <span class="samp">%uhi</span>.
<li><code>R_SPARC_HM10</code> is requested using <span class="samp">%hm</span>. It can
also be generated using <span class="samp">%ulo</span>.
<li><code>R_SPARC_LM22</code> is requested using <span class="samp">%lm</span>.
<li><code>R_SPARC_H44</code> is requested using <span class="samp">%h44</span>.
<li><code>R_SPARC_M44</code> is requested using <span class="samp">%m44</span>.
<li><code>R_SPARC_L44</code> is requested using <span class="samp">%l44</span>.
</ul>
<p>The PC relative relocation <code>R_SPARC_PC22</code> can be obtained by
enclosing an operand inside of <span class="samp">%pc22</span>. Likewise, the
<code>R_SPARC_PC10</code> relocation can be obtained using <span class="samp">%pc10</span>.
These are mostly used when assembling PIC code. For example, the
standard PIC sequence on Sparc to get the base of the global offset
table, PC relative, into a register, can be performed as:
<pre class="example"> sethi %pc22(_GLOBAL_OFFSET_TABLE_-4), %l7
add %l7, %pc10(_GLOBAL_OFFSET_TABLE_+4), %l7
</pre>
<p>Several relocations exist to allow the link editor to potentially
optimize GOT data references. The <code>R_SPARC_GOTDATA_OP_HIX22</code>
relocation can obtained by enclosing an operand inside of
<span class="samp">%gdop_hix22</span>. The <code>R_SPARC_GOTDATA_OP_LOX10</code>
relocation can obtained by enclosing an operand inside of
<span class="samp">%gdop_lox10</span>. Likewise, <code>R_SPARC_GOTDATA_OP</code> can be
obtained by enclosing an operand inside of <span class="samp">%gdop</span>.
For example, assuming the GOT base is in register <code>%l7</code>:
<pre class="example"> sethi %gdop_hix22(symbol), %l1
xor %l1, %gdop_lox10(symbol), %l1
ld [%l7 + %l1], %l2, %gdop(symbol)
</pre>
<p>There are many relocations that can be requested for access to
thread local storage variables. All of the Sparc TLS mnemonics
are supported:
<ul>
<li><code>R_SPARC_TLS_GD_HI22</code> is requested using <span class="samp">%tgd_hi22</span>.
<li><code>R_SPARC_TLS_GD_LO10</code> is requested using <span class="samp">%tgd_lo10</span>.
<li><code>R_SPARC_TLS_GD_ADD</code> is requested using <span class="samp">%tgd_add</span>.
<li><code>R_SPARC_TLS_GD_CALL</code> is requested using <span class="samp">%tgd_call</span>.
<li><code>R_SPARC_TLS_LDM_HI22</code> is requested using <span class="samp">%tldm_hi22</span>.
<li><code>R_SPARC_TLS_LDM_LO10</code> is requested using <span class="samp">%tldm_lo10</span>.
<li><code>R_SPARC_TLS_LDM_ADD</code> is requested using <span class="samp">%tldm_add</span>.
<li><code>R_SPARC_TLS_LDM_CALL</code> is requested using <span class="samp">%tldm_call</span>.
<li><code>R_SPARC_TLS_LDO_HIX22</code> is requested using <span class="samp">%tldo_hix22</span>.
<li><code>R_SPARC_TLS_LDO_LOX10</code> is requested using <span class="samp">%tldo_lox10</span>.
<li><code>R_SPARC_TLS_LDO_ADD</code> is requested using <span class="samp">%tldo_add</span>.
<li><code>R_SPARC_TLS_IE_HI22</code> is requested using <span class="samp">%tie_hi22</span>.
<li><code>R_SPARC_TLS_IE_LO10</code> is requested using <span class="samp">%tie_lo10</span>.
<li><code>R_SPARC_TLS_IE_LD</code> is requested using <span class="samp">%tie_ld</span>.
<li><code>R_SPARC_TLS_IE_LDX</code> is requested using <span class="samp">%tie_ldx</span>.
<li><code>R_SPARC_TLS_IE_ADD</code> is requested using <span class="samp">%tie_add</span>.
<li><code>R_SPARC_TLS_LE_HIX22</code> is requested using <span class="samp">%tle_hix22</span>.
<li><code>R_SPARC_TLS_LE_LOX10</code> is requested using <span class="samp">%tle_lox10</span>.
</ul>
<p>Here are some example TLS model sequences.
<p>First, General Dynamic:
<pre class="example"> sethi %tgd_hi22(symbol), %l1
add %l1, %tgd_lo10(symbol), %l1
add %l7, %l1, %o0, %tgd_add(symbol)
call __tls_get_addr, %tgd_call(symbol)
nop
</pre>
<p>Local Dynamic:
<pre class="example"> sethi %tldm_hi22(symbol), %l1
add %l1, %tldm_lo10(symbol), %l1
add %l7, %l1, %o0, %tldm_add(symbol)
call __tls_get_addr, %tldm_call(symbol)
nop
sethi %tldo_hix22(symbol), %l1
xor %l1, %tldo_lox10(symbol), %l1
add %o0, %l1, %l1, %tldo_add(symbol)
</pre>
<p>Initial Exec:
<pre class="example"> sethi %tie_hi22(symbol), %l1
add %l1, %tie_lo10(symbol), %l1
ld [%l7 + %l1], %o0, %tie_ld(symbol)
add %g7, %o0, %o0, %tie_add(symbol)
sethi %tie_hi22(symbol), %l1
add %l1, %tie_lo10(symbol), %l1
ldx [%l7 + %l1], %o0, %tie_ldx(symbol)
add %g7, %o0, %o0, %tie_add(symbol)
</pre>
<p>And finally, Local Exec:
<pre class="example"> sethi %tle_hix22(symbol), %l1
add %l1, %tle_lox10(symbol), %l1
add %g7, %l1, %l1
</pre>
<p>When assembling for 64-bit, and a secondary constant addend is
specified in an address expression that would normally generate
an <code>R_SPARC_LO10</code> relocation, the assembler will emit an
<code>R_SPARC_OLO10</code> instead.
</body></html>