Alpha_002dRelocs.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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: Alpha-Relocs</title>
  15. <meta name="description" content="Using as: Alpha-Relocs">
  16. <meta name="keywords" content="Using as: Alpha-Relocs">
  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="Alpha-Syntax.html#Alpha-Syntax" rel="up" title="Alpha Syntax">
  25. <link href="Alpha-Floating-Point.html#Alpha-Floating-Point" rel="next" title="Alpha Floating Point">
  26. <link href="Alpha_002dRegs.html#Alpha_002dRegs" rel="prev" title="Alpha-Regs">
  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="Alpha_002dRelocs"></a>
  58. <div class="header">
  59. <p>
  60. Previous: <a href="Alpha_002dRegs.html#Alpha_002dRegs" accesskey="p" rel="prev">Alpha-Regs</a>, Up: <a href="Alpha-Syntax.html#Alpha-Syntax" accesskey="u" rel="up">Alpha Syntax</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="Relocations-1"></a>
  64. <h4 class="subsubsection">9.2.3.3 Relocations</h4>
  65. <a name="index-Alpha-relocations"></a>
  66. <a name="index-relocations_002c-Alpha"></a>
  67. <p>Some of these relocations are available for ECOFF, but mostly
  68. only for ELF. They are modeled after the relocation format
  69. introduced in Digital Unix 4.0, but there are additions.
  70. </p>
  71. <p>The format is &lsquo;<samp>!<var>tag</var></samp>&rsquo; or &lsquo;<samp>!<var>tag</var>!<var>number</var></samp>&rsquo;
  72. where <var>tag</var> is the name of the relocation. In some cases
  73. <var>number</var> is used to relate specific instructions.
  74. </p>
  75. <p>The relocation is placed at the end of the instruction like so:
  76. </p>
  77. <div class="example">
  78. <pre class="example">ldah $0,a($29) !gprelhigh
  79. lda $0,a($0) !gprellow
  80. ldq $1,b($29) !literal!100
  81. ldl $2,0($1) !lituse_base!100
  82. </pre></div>
  83. <dl compact="compact">
  84. <dt><code>!literal</code></dt>
  85. <dt><code>!literal!<var>N</var></code></dt>
  86. <dd><p>Used with an <code>ldq</code> instruction to load the address of a symbol
  87. from the GOT.
  88. </p>
  89. <p>A sequence number <var>N</var> is optional, and if present is used to pair
  90. <code>lituse</code> relocations with this <code>literal</code> relocation. The
  91. <code>lituse</code> relocations are used by the linker to optimize the code
  92. based on the final location of the symbol.
  93. </p>
  94. <p>Note that these optimizations are dependent on the data flow of the
  95. program. Therefore, if <em>any</em> <code>lituse</code> is paired with a
  96. <code>literal</code> relocation, then <em>all</em> uses of the register set by
  97. the <code>literal</code> instruction must also be marked with <code>lituse</code>
  98. relocations. This is because the original <code>literal</code> instruction
  99. may be deleted or transformed into another instruction.
  100. </p>
  101. <p>Also note that there may be a one-to-many relationship between
  102. <code>literal</code> and <code>lituse</code>, but not a many-to-one. That is, if
  103. there are two code paths that load up the same address and feed the
  104. value to a single use, then the use may not use a <code>lituse</code>
  105. relocation.
  106. </p>
  107. </dd>
  108. <dt><code>!lituse_base!<var>N</var></code></dt>
  109. <dd><p>Used with any memory format instruction (e.g. <code>ldl</code>) to indicate
  110. that the literal is used for an address load. The offset field of the
  111. instruction must be zero. During relaxation, the code may be altered
  112. to use a gp-relative load.
  113. </p>
  114. </dd>
  115. <dt><code>!lituse_jsr!<var>N</var></code></dt>
  116. <dd><p>Used with a register branch format instruction (e.g. <code>jsr</code>) to
  117. indicate that the literal is used for a call. During relaxation, the
  118. code may be altered to use a direct branch (e.g. <code>bsr</code>).
  119. </p>
  120. </dd>
  121. <dt><code>!lituse_jsrdirect!<var>N</var></code></dt>
  122. <dd><p>Similar to <code>lituse_jsr</code>, but also that this call cannot be vectored
  123. through a PLT entry. This is useful for functions with special calling
  124. conventions which do not allow the normal call-clobbered registers to be
  125. clobbered.
  126. </p>
  127. </dd>
  128. <dt><code>!lituse_bytoff!<var>N</var></code></dt>
  129. <dd><p>Used with a byte mask instruction (e.g. <code>extbl</code>) to indicate
  130. that only the low 3 bits of the address are relevant. During relaxation,
  131. the code may be altered to use an immediate instead of a register shift.
  132. </p>
  133. </dd>
  134. <dt><code>!lituse_addr!<var>N</var></code></dt>
  135. <dd><p>Used with any other instruction to indicate that the original address
  136. is in fact used, and the original <code>ldq</code> instruction may not be
  137. altered or deleted. This is useful in conjunction with <code>lituse_jsr</code>
  138. to test whether a weak symbol is defined.
  139. </p>
  140. <div class="example">
  141. <pre class="example">ldq $27,foo($29) !literal!1
  142. beq $27,is_undef !lituse_addr!1
  143. jsr $26,($27),foo !lituse_jsr!1
  144. </pre></div>
  145. </dd>
  146. <dt><code>!lituse_tlsgd!<var>N</var></code></dt>
  147. <dd><p>Used with a register branch format instruction to indicate that the
  148. literal is the call to <code>__tls_get_addr</code> used to compute the
  149. address of the thread-local storage variable whose descriptor was
  150. loaded with <code>!tlsgd!<var>N</var></code>.
  151. </p>
  152. </dd>
  153. <dt><code>!lituse_tlsldm!<var>N</var></code></dt>
  154. <dd><p>Used with a register branch format instruction to indicate that the
  155. literal is the call to <code>__tls_get_addr</code> used to compute the
  156. address of the base of the thread-local storage block for the current
  157. module. The descriptor for the module must have been loaded with
  158. <code>!tlsldm!<var>N</var></code>.
  159. </p>
  160. </dd>
  161. <dt><code>!gpdisp!<var>N</var></code></dt>
  162. <dd><p>Used with <code>ldah</code> and <code>lda</code> to load the GP from the current
  163. address, a-la the <code>ldgp</code> macro. The source register for the
  164. <code>ldah</code> instruction must contain the address of the <code>ldah</code>
  165. instruction. There must be exactly one <code>lda</code> instruction paired
  166. with the <code>ldah</code> instruction, though it may appear anywhere in
  167. the instruction stream. The immediate operands must be zero.
  168. </p>
  169. <div class="example">
  170. <pre class="example">bsr $26,foo
  171. ldah $29,0($26) !gpdisp!1
  172. lda $29,0($29) !gpdisp!1
  173. </pre></div>
  174. </dd>
  175. <dt><code>!gprelhigh</code></dt>
  176. <dd><p>Used with an <code>ldah</code> instruction to add the high 16 bits of a
  177. 32-bit displacement from the GP.
  178. </p>
  179. </dd>
  180. <dt><code>!gprellow</code></dt>
  181. <dd><p>Used with any memory format instruction to add the low 16 bits of a
  182. 32-bit displacement from the GP.
  183. </p>
  184. </dd>
  185. <dt><code>!gprel</code></dt>
  186. <dd><p>Used with any memory format instruction to add a 16-bit displacement
  187. from the GP.
  188. </p>
  189. </dd>
  190. <dt><code>!samegp</code></dt>
  191. <dd><p>Used with any branch format instruction to skip the GP load at the
  192. target address. The referenced symbol must have the same GP as the
  193. source object file, and it must be declared to either not use <code>$27</code>
  194. or perform a standard GP load in the first two instructions via the
  195. <code>.prologue</code> directive.
  196. </p>
  197. </dd>
  198. <dt><code>!tlsgd</code></dt>
  199. <dt><code>!tlsgd!<var>N</var></code></dt>
  200. <dd><p>Used with an <code>lda</code> instruction to load the address of a TLS
  201. descriptor for a symbol in the GOT.
  202. </p>
  203. <p>The sequence number <var>N</var> is optional, and if present it used to
  204. pair the descriptor load with both the <code>literal</code> loading the
  205. address of the <code>__tls_get_addr</code> function and the <code>lituse_tlsgd</code>
  206. marking the call to that function.
  207. </p>
  208. <p>For proper relaxation, both the <code>tlsgd</code>, <code>literal</code> and
  209. <code>lituse</code> relocations must be in the same extended basic block.
  210. That is, the relocation with the lowest address must be executed
  211. first at runtime.
  212. </p>
  213. </dd>
  214. <dt><code>!tlsldm</code></dt>
  215. <dt><code>!tlsldm!<var>N</var></code></dt>
  216. <dd><p>Used with an <code>lda</code> instruction to load the address of a TLS
  217. descriptor for the current module in the GOT.
  218. </p>
  219. <p>Similar in other respects to <code>tlsgd</code>.
  220. </p>
  221. </dd>
  222. <dt><code>!gotdtprel</code></dt>
  223. <dd><p>Used with an <code>ldq</code> instruction to load the offset of the TLS
  224. symbol within its module&rsquo;s thread-local storage block. Also known
  225. as the dynamic thread pointer offset or dtp-relative offset.
  226. </p>
  227. </dd>
  228. <dt><code>!dtprelhi</code></dt>
  229. <dt><code>!dtprello</code></dt>
  230. <dt><code>!dtprel</code></dt>
  231. <dd><p>Like <code>gprel</code> relocations except they compute dtp-relative offsets.
  232. </p>
  233. </dd>
  234. <dt><code>!gottprel</code></dt>
  235. <dd><p>Used with an <code>ldq</code> instruction to load the offset of the TLS
  236. symbol from the thread pointer. Also known as the tp-relative offset.
  237. </p>
  238. </dd>
  239. <dt><code>!tprelhi</code></dt>
  240. <dt><code>!tprello</code></dt>
  241. <dt><code>!tprel</code></dt>
  242. <dd><p>Like <code>gprel</code> relocations except they compute tp-relative offsets.
  243. </p></dd>
  244. </dl>
  245. <hr>
  246. <div class="header">
  247. <p>
  248. Previous: <a href="Alpha_002dRegs.html#Alpha_002dRegs" accesskey="p" rel="prev">Alpha-Regs</a>, Up: <a href="Alpha-Syntax.html#Alpha-Syntax" accesskey="u" rel="up">Alpha Syntax</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>
  249. </div>
  250. </body>
  251. </html>