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.
82 lines
3.8 KiB
HTML
82 lines
3.8 KiB
HTML
4 years ago
|
<html lang="en">
|
||
|
<head>
|
||
|
<title>AArch64-Relocations - Using as</title>
|
||
|
<meta http-equiv="Content-Type" content="text/html">
|
||
|
<meta name="description" content="Using as">
|
||
|
<meta name="generator" content="makeinfo 4.13">
|
||
|
<link title="Top" rel="start" href="index.html#Top">
|
||
|
<link rel="up" href="AArch64-Syntax.html#AArch64-Syntax" title="AArch64 Syntax">
|
||
|
<link rel="prev" href="AArch64_002dRegs.html#AArch64_002dRegs" title="AArch64-Regs">
|
||
|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
|
||
|
<!--
|
||
|
This file documents the GNU Assembler "as".
|
||
|
|
||
|
Copyright (C) 1991-2015 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.3
|
||
|
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''.
|
||
|
|
||
|
-->
|
||
|
<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; }
|
||
|
span.sansserif { font-family:sans-serif; font-weight:normal; }
|
||
|
--></style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div class="node">
|
||
|
<a name="AArch64-Relocations"></a>
|
||
|
<a name="AArch64_002dRelocations"></a>
|
||
|
<p>
|
||
|
Previous: <a rel="previous" accesskey="p" href="AArch64_002dRegs.html#AArch64_002dRegs">AArch64-Regs</a>,
|
||
|
Up: <a rel="up" accesskey="u" href="AArch64-Syntax.html#AArch64-Syntax">AArch64 Syntax</a>
|
||
|
<hr>
|
||
|
</div>
|
||
|
|
||
|
<h5 class="subsubsection">9.1.3.3 Relocations</h5>
|
||
|
|
||
|
<p><a name="index-relocations_002c-AArch64-541"></a><a name="index-AArch64-relocations-542"></a><a name="index-MOVN_002c-MOVZ-and-MOVK-group-relocations_002c-AArch64-543"></a>Relocations for ‘<samp><span class="samp">MOVZ</span></samp>’ and ‘<samp><span class="samp">MOVK</span></samp>’ instructions can be generated
|
||
|
by prefixing the label with ‘<samp><span class="samp">#:abs_g2:</span></samp>’ etc.
|
||
|
For example to load the 48-bit absolute address of <var>foo</var> into x0:
|
||
|
|
||
|
<pre class="smallexample"> movz x0, #:abs_g2:foo // bits 32-47, overflow check
|
||
|
movk x0, #:abs_g1_nc:foo // bits 16-31, no overflow check
|
||
|
movk x0, #:abs_g0_nc:foo // bits 0-15, no overflow check
|
||
|
</pre>
|
||
|
<p><a name="index-ADRP_002c-ADD_002c-LDR_002fSTR-group-relocations_002c-AArch64-544"></a>Relocations for ‘<samp><span class="samp">ADRP</span></samp>’, and ‘<samp><span class="samp">ADD</span></samp>’, ‘<samp><span class="samp">LDR</span></samp>’ or ‘<samp><span class="samp">STR</span></samp>’
|
||
|
instructions can be generated by prefixing the label with
|
||
|
‘<samp><span class="samp">:pg_hi21:</span></samp>’ and ‘<samp><span class="samp">#:lo12:</span></samp>’ respectively.
|
||
|
|
||
|
<p>For example to use 33-bit (+/-4GB) pc-relative addressing to
|
||
|
load the address of <var>foo</var> into x0:
|
||
|
|
||
|
<pre class="smallexample"> adrp x0, :pg_hi21:foo
|
||
|
add x0, x0, #:lo12:foo
|
||
|
</pre>
|
||
|
<p>Or to load the value of <var>foo</var> into x0:
|
||
|
|
||
|
<pre class="smallexample"> adrp x0, :pg_hi21:foo
|
||
|
ldr x0, [x0, #:lo12:foo]
|
||
|
</pre>
|
||
|
<p>Note that ‘<samp><span class="samp">:pg_hi21:</span></samp>’ is optional.
|
||
|
|
||
|
<pre class="smallexample"> adrp x0, foo
|
||
|
</pre>
|
||
|
<p>is equivalent to
|
||
|
|
||
|
<pre class="smallexample"> adrp x0, :pg_hi21:foo
|
||
|
</pre>
|
||
|
</body></html>
|
||
|
|