Nios-II-Relocations.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- This file documents the GNU Assembler "as".
  4. Copyright (C) 1991-2017 Free Software Foundation, Inc.
  5. Permission is granted to copy, distribute and/or modify this document
  6. under the terms of the GNU Free Documentation License, Version 1.3
  7. or any later version published by the Free Software Foundation;
  8. with no Invariant Sections, with no Front-Cover Texts, and with no
  9. Back-Cover Texts. A copy of the license is included in the
  10. section entitled "GNU Free Documentation License".
  11. -->
  12. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <title>Using as: Nios II Relocations</title>
  15. <meta name="description" content="Using as: Nios II Relocations">
  16. <meta name="keywords" content="Using as: Nios II Relocations">
  17. <meta name="resource-type" content="document">
  18. <meta name="distribution" content="global">
  19. <meta name="Generator" content="makeinfo">
  20. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  21. <link href="index.html#Top" rel="start" title="Top">
  22. <link href="AS-Index.html#AS-Index" rel="index" title="AS Index">
  23. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  24. <link href="NiosII_002dDependent.html#NiosII_002dDependent" rel="up" title="NiosII-Dependent">
  25. <link href="Nios-II-Directives.html#Nios-II-Directives" rel="next" title="Nios II Directives">
  26. <link href="Nios-II-Chars.html#Nios-II-Chars" rel="prev" title="Nios II Chars">
  27. <style type="text/css">
  28. <!--
  29. a.summary-letter {text-decoration: none}
  30. blockquote.smallquotation {font-size: smaller}
  31. div.display {margin-left: 3.2em}
  32. div.example {margin-left: 3.2em}
  33. div.indentedblock {margin-left: 3.2em}
  34. div.lisp {margin-left: 3.2em}
  35. div.smalldisplay {margin-left: 3.2em}
  36. div.smallexample {margin-left: 3.2em}
  37. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  38. div.smalllisp {margin-left: 3.2em}
  39. kbd {font-style:oblique}
  40. pre.display {font-family: inherit}
  41. pre.format {font-family: inherit}
  42. pre.menu-comment {font-family: serif}
  43. pre.menu-preformatted {font-family: serif}
  44. pre.smalldisplay {font-family: inherit; font-size: smaller}
  45. pre.smallexample {font-size: smaller}
  46. pre.smallformat {font-family: inherit; font-size: smaller}
  47. pre.smalllisp {font-size: smaller}
  48. span.nocodebreak {white-space:nowrap}
  49. span.nolinebreak {white-space:nowrap}
  50. span.roman {font-family:serif; font-weight:normal}
  51. span.sansserif {font-family:sans-serif; font-weight:normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  57. <a name="Nios-II-Relocations"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Nios-II-Directives.html#Nios-II-Directives" accesskey="n" rel="next">Nios II Directives</a>, Previous: <a href="Nios-II-Syntax.html#Nios-II-Syntax" accesskey="p" rel="prev">Nios II Syntax</a>, Up: <a href="NiosII_002dDependent.html#NiosII_002dDependent" accesskey="u" rel="up">NiosII-Dependent</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
  61. </div>
  62. <hr>
  63. <a name="Nios-II-Machine-Relocations"></a>
  64. <h4 class="subsection">9.31.3 Nios II Machine Relocations</h4>
  65. <a name="index-machine-relocations_002c-Nios-II"></a>
  66. <a name="index-Nios-II-machine-relocations"></a>
  67. <dl compact="compact">
  68. <dd><a name="index-hiadj-directive_002c-Nios-II"></a>
  69. </dd>
  70. <dt><code>%hiadj(<var>expression</var>)</code></dt>
  71. <dd><p>Extract the upper 16 bits of <var>expression</var> and add
  72. one if the 15th bit is set.
  73. </p>
  74. <p>The value of <code>%hiadj(<var>expression</var>)</code> is:
  75. </p><div class="smallexample">
  76. <pre class="smallexample">((<var>expression</var> &gt;&gt; 16) &amp; 0xffff) + ((<var>expression</var> &gt;&gt; 15) &amp; 0x01)
  77. </pre></div>
  78. <p>The <code>%hiadj</code> relocation is intended to be used with
  79. the <code>addi</code>, <code>ld</code> or <code>st</code> instructions
  80. along with a <code>%lo</code>, in order to load a 32-bit constant.
  81. </p>
  82. <div class="smallexample">
  83. <pre class="smallexample">movhi r2, %hiadj(symbol)
  84. addi r2, r2, %lo(symbol)
  85. </pre></div>
  86. <a name="index-hi-directive_002c-Nios-II"></a>
  87. </dd>
  88. <dt><code>%hi(<var>expression</var>)</code></dt>
  89. <dd><p>Extract the upper 16 bits of <var>expression</var>.
  90. </p>
  91. <a name="index-lo-directive_002c-Nios-II"></a>
  92. </dd>
  93. <dt><code>%lo(<var>expression</var>)</code></dt>
  94. <dd><p>Extract the lower 16 bits of <var>expression</var>.
  95. </p>
  96. <a name="index-gprel-directive_002c-Nios-II"></a>
  97. </dd>
  98. <dt><code>%gprel(<var>expression</var>)</code></dt>
  99. <dd><p>Subtract the value of the symbol <code>_gp</code> from
  100. <var>expression</var>.
  101. </p>
  102. <p>The intention of the <code>%gprel</code> relocation is
  103. to have a fast small area of memory which only
  104. takes a 16-bit immediate to access.
  105. </p>
  106. <div class="smallexample">
  107. <pre class="smallexample"> .section .sdata
  108. fastint:
  109. .int 123
  110. .section .text
  111. ldw r4, %gprel(fastint)(gp)
  112. </pre></div>
  113. <a name="index-call-directive_002c-Nios-II"></a>
  114. <a name="index-call_005flo-directive_002c-Nios-II"></a>
  115. <a name="index-call_005fhiadj-directive_002c-Nios-II"></a>
  116. <a name="index-got-directive_002c-Nios-II"></a>
  117. <a name="index-got_005flo-directive_002c-Nios-II"></a>
  118. <a name="index-got_005fhiadj-directive_002c-Nios-II"></a>
  119. <a name="index-gotoff-directive_002c-Nios-II"></a>
  120. <a name="index-gotoff_005flo-directive_002c-Nios-II"></a>
  121. <a name="index-gotoff_005fhiadj-directive_002c-Nios-II"></a>
  122. <a name="index-tls_005fgd-directive_002c-Nios-II"></a>
  123. <a name="index-tls_005fie-directive_002c-Nios-II"></a>
  124. <a name="index-tls_005fle-directive_002c-Nios-II"></a>
  125. <a name="index-tls_005fldm-directive_002c-Nios-II"></a>
  126. <a name="index-tls_005fldo-directive_002c-Nios-II"></a>
  127. </dd>
  128. <dt><code>%call(<var>expression</var>)</code></dt>
  129. <dt><code>%call_lo(<var>expression</var>)</code></dt>
  130. <dt><code>%call_hiadj(<var>expression</var>)</code></dt>
  131. <dt><code>%got(<var>expression</var>)</code></dt>
  132. <dt><code>%got_lo(<var>expression</var>)</code></dt>
  133. <dt><code>%got_hiadj(<var>expression</var>)</code></dt>
  134. <dt><code>%gotoff(<var>expression</var>)</code></dt>
  135. <dt><code>%gotoff_lo(<var>expression</var>)</code></dt>
  136. <dt><code>%gotoff_hiadj(<var>expression</var>)</code></dt>
  137. <dt><code>%tls_gd(<var>expression</var>)</code></dt>
  138. <dt><code>%tls_ie(<var>expression</var>)</code></dt>
  139. <dt><code>%tls_le(<var>expression</var>)</code></dt>
  140. <dt><code>%tls_ldm(<var>expression</var>)</code></dt>
  141. <dt><code>%tls_ldo(<var>expression</var>)</code></dt>
  142. <dd>
  143. <p>These relocations support the ABI for Linux Systems documented in the
  144. <cite>Nios II Processor Reference Handbook</cite>.
  145. </p></dd>
  146. </dl>
  147. </body>
  148. </html>