PowerPC64-ELF64.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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 linker LD
  4. (GNU Binutils)
  5. version 2.28.
  6. Copyright (C) 1991-2017 Free Software Foundation, Inc.
  7. Permission is granted to copy, distribute and/or modify this document
  8. under the terms of the GNU Free Documentation License, Version 1.3
  9. or any later version published by the Free Software Foundation;
  10. with no Invariant Sections, with no Front-Cover Texts, and with no
  11. Back-Cover Texts. A copy of the license is included in the
  12. section entitled "GNU Free Documentation License". -->
  13. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <title>LD: PowerPC64 ELF64</title>
  16. <meta name="description" content="LD: PowerPC64 ELF64">
  17. <meta name="keywords" content="LD: PowerPC64 ELF64">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  22. <link href="index.html#Top" rel="start" title="Top">
  23. <link href="LD-Index.html#LD-Index" rel="index" title="LD Index">
  24. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  25. <link href="Machine-Dependent.html#Machine-Dependent" rel="up" title="Machine Dependent">
  26. <link href="SPU-ELF.html#SPU-ELF" rel="next" title="SPU ELF">
  27. <link href="PowerPC-ELF32.html#PowerPC-ELF32" rel="prev" title="PowerPC ELF32">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.smallquotation {font-size: smaller}
  32. div.display {margin-left: 3.2em}
  33. div.example {margin-left: 3.2em}
  34. div.indentedblock {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  38. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  39. div.smalllisp {margin-left: 3.2em}
  40. kbd {font-style:oblique}
  41. pre.display {font-family: inherit}
  42. pre.format {font-family: inherit}
  43. pre.menu-comment {font-family: serif}
  44. pre.menu-preformatted {font-family: serif}
  45. pre.smalldisplay {font-family: inherit; font-size: smaller}
  46. pre.smallexample {font-size: smaller}
  47. pre.smallformat {font-family: inherit; font-size: smaller}
  48. pre.smalllisp {font-size: smaller}
  49. span.nocodebreak {white-space:nowrap}
  50. span.nolinebreak {white-space:nowrap}
  51. span.roman {font-family:serif; font-weight:normal}
  52. span.sansserif {font-family:sans-serif; font-weight:normal}
  53. ul.no-bullet {list-style: none}
  54. -->
  55. </style>
  56. </head>
  57. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  58. <a name="PowerPC64-ELF64"></a>
  59. <div class="header">
  60. <p>
  61. Next: <a href="SPU-ELF.html#SPU-ELF" accesskey="n" rel="next">SPU ELF</a>, Previous: <a href="PowerPC-ELF32.html#PowerPC-ELF32" accesskey="p" rel="prev">PowerPC ELF32</a>, Up: <a href="Machine-Dependent.html#Machine-Dependent" accesskey="u" rel="up">Machine Dependent</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="LD-Index.html#LD-Index" title="Index" rel="index">Index</a>]</p>
  62. </div>
  63. <hr>
  64. <a name="ld-and-PowerPC64-64_002dbit-ELF-Support"></a>
  65. <h3 class="section">4.13 <code>ld</code> and PowerPC64 64-bit ELF Support</h3>
  66. <a name="index-PowerPC64-ELF64-options"></a>
  67. <dl compact="compact">
  68. <dd><a name="index-PowerPC64-stub-grouping"></a>
  69. <a name="index-_002d_002dstub_002dgroup_002dsize"></a>
  70. </dd>
  71. <dt><samp>--stub-group-size</samp></dt>
  72. <dd><p>Long branch stubs, PLT call stubs and TOC adjusting stubs are placed
  73. by <code>ld</code> in stub sections located between groups of input sections.
  74. &lsquo;<samp>--stub-group-size</samp>&rsquo; specifies the maximum size of a group of input
  75. sections handled by one stub section. Since branch offsets are signed,
  76. a stub section may serve two groups of input sections, one group before
  77. the stub section, and one group after it. However, when using
  78. conditional branches that require stubs, it may be better (for branch
  79. prediction) that stub sections only serve one group of input sections.
  80. A negative value for &lsquo;<samp>N</samp>&rsquo; chooses this scheme, ensuring that
  81. branches to stubs always use a negative offset. Two special values of
  82. &lsquo;<samp>N</samp>&rsquo; are recognized, &lsquo;<samp>1</samp>&rsquo; and &lsquo;<samp>-1</samp>&rsquo;. These both instruct
  83. <code>ld</code> to automatically size input section groups for the branch types
  84. detected, with the same behaviour regarding stub placement as other
  85. positive or negative values of &lsquo;<samp>N</samp>&rsquo; respectively.
  86. </p>
  87. <p>Note that &lsquo;<samp>--stub-group-size</samp>&rsquo; does not split input sections. A
  88. single input section larger than the group size specified will of course
  89. create a larger group (of one section). If input sections are too
  90. large, it may not be possible for a branch to reach its stub.
  91. </p>
  92. <a name="index-PowerPC64-stub-symbols"></a>
  93. <a name="index-_002d_002demit_002dstub_002dsyms-1"></a>
  94. </dd>
  95. <dt><samp>--emit-stub-syms</samp></dt>
  96. <dd><p>This option causes <code>ld</code> to label linker stubs with a local
  97. symbol that encodes the stub type and destination.
  98. </p>
  99. <a name="index-PowerPC64-dot-symbols"></a>
  100. <a name="index-_002d_002ddotsyms"></a>
  101. <a name="index-_002d_002dno_002ddotsyms"></a>
  102. </dd>
  103. <dt><samp>--dotsyms</samp></dt>
  104. <dt><samp>--no-dotsyms</samp></dt>
  105. <dd><p>These two options control how <code>ld</code> interprets version patterns
  106. in a version script. Older PowerPC64 compilers emitted both a
  107. function descriptor symbol with the same name as the function, and a
  108. code entry symbol with the name prefixed by a dot (&lsquo;<samp>.</samp>&rsquo;). To
  109. properly version a function &lsquo;<samp>foo</samp>&rsquo;, the version script thus needs
  110. to control both &lsquo;<samp>foo</samp>&rsquo; and &lsquo;<samp>.foo</samp>&rsquo;. The option
  111. &lsquo;<samp>--dotsyms</samp>&rsquo;, on by default, automatically adds the required
  112. dot-prefixed patterns. Use &lsquo;<samp>--no-dotsyms</samp>&rsquo; to disable this
  113. feature.
  114. </p>
  115. <a name="index-PowerPC64-register-save_002frestore-functions"></a>
  116. <a name="index-_002d_002dsave_002drestore_002dfuncs"></a>
  117. <a name="index-_002d_002dno_002dsave_002drestore_002dfuncs"></a>
  118. </dd>
  119. <dt><samp>--save-restore-funcs</samp></dt>
  120. <dt><samp>--no-save-restore-funcs</samp></dt>
  121. <dd><p>These two options control whether PowerPC64 <code>ld</code> automatically
  122. provides out-of-line register save and restore functions used by
  123. &lsquo;<samp>-Os</samp>&rsquo; code. The default is to provide any such referenced
  124. function for a normal final link, and to not do so for a relocatable
  125. link.
  126. </p>
  127. <a name="index-PowerPC64-TLS-optimization"></a>
  128. <a name="index-_002d_002dno_002dtls_002doptimize-1"></a>
  129. </dd>
  130. <dt><samp>--no-tls-optimize</samp></dt>
  131. <dd><p>PowerPC64 <code>ld</code> normally performs some optimization of code
  132. sequences used to access Thread-Local Storage. Use this option to
  133. disable the optimization.
  134. </p>
  135. <a name="index-PowerPC64-_005f_005ftls_005fget_005faddr-optimization"></a>
  136. <a name="index-_002d_002dtls_002dget_002daddr_002doptimize"></a>
  137. <a name="index-_002d_002dno_002dtls_002dget_002daddr_002doptimize"></a>
  138. </dd>
  139. <dt><samp>--tls-get-addr-optimize</samp></dt>
  140. <dt><samp>--no-tls-get-addr-optimize</samp></dt>
  141. <dd><p>These options control whether PowerPC64 <code>ld</code> uses a special
  142. stub to call __tls_get_addr. PowerPC64 glibc 2.22 and later support
  143. an optimization that allows the second and subsequent calls to
  144. <code>__tls_get_addr</code> for a given symbol to be resolved by the special
  145. stub without calling in to glibc. By default the linker enables this
  146. option when glibc advertises the availability of __tls_get_addr_opt.
  147. Forcing this option on when using an older glibc won&rsquo;t do much besides
  148. slow down your applications, but may be useful if linking an
  149. application against an older glibc with the expectation that it will
  150. normally be used on systems having a newer glibc.
  151. </p>
  152. <a name="index-PowerPC64-OPD-optimization"></a>
  153. <a name="index-_002d_002dno_002dopd_002doptimize"></a>
  154. </dd>
  155. <dt><samp>--no-opd-optimize</samp></dt>
  156. <dd><p>PowerPC64 <code>ld</code> normally removes <code>.opd</code> section entries
  157. corresponding to deleted link-once functions, or functions removed by
  158. the action of &lsquo;<samp>--gc-sections</samp>&rsquo; or linker script <code>/DISCARD/</code>.
  159. Use this option to disable <code>.opd</code> optimization.
  160. </p>
  161. <a name="index-PowerPC64-OPD-spacing"></a>
  162. <a name="index-_002d_002dnon_002doverlapping_002dopd"></a>
  163. </dd>
  164. <dt><samp>--non-overlapping-opd</samp></dt>
  165. <dd><p>Some PowerPC64 compilers have an option to generate compressed
  166. <code>.opd</code> entries spaced 16 bytes apart, overlapping the third word,
  167. the static chain pointer (unused in C) with the first word of the next
  168. entry. This option expands such entries to the full 24 bytes.
  169. </p>
  170. <a name="index-PowerPC64-TOC-optimization"></a>
  171. <a name="index-_002d_002dno_002dtoc_002doptimize"></a>
  172. </dd>
  173. <dt><samp>--no-toc-optimize</samp></dt>
  174. <dd><p>PowerPC64 <code>ld</code> normally removes unused <code>.toc</code> section
  175. entries. Such entries are detected by examining relocations that
  176. reference the TOC in code sections. A reloc in a deleted code section
  177. marks a TOC word as unneeded, while a reloc in a kept code section
  178. marks a TOC word as needed. Since the TOC may reference itself, TOC
  179. relocs are also examined. TOC words marked as both needed and
  180. unneeded will of course be kept. TOC words without any referencing
  181. reloc are assumed to be part of a multi-word entry, and are kept or
  182. discarded as per the nearest marked preceding word. This works
  183. reliably for compiler generated code, but may be incorrect if assembly
  184. code is used to insert TOC entries. Use this option to disable the
  185. optimization.
  186. </p>
  187. <a name="index-PowerPC64-multi_002dTOC"></a>
  188. <a name="index-_002d_002dno_002dmulti_002dtoc"></a>
  189. </dd>
  190. <dt><samp>--no-multi-toc</samp></dt>
  191. <dd><p>If given any toc option besides <code>-mcmodel=medium</code> or
  192. <code>-mcmodel=large</code>, PowerPC64 GCC generates code for a TOC model
  193. where TOC
  194. entries are accessed with a 16-bit offset from r2. This limits the
  195. total TOC size to 64K. PowerPC64 <code>ld</code> extends this limit by
  196. grouping code sections such that each group uses less than 64K for its
  197. TOC entries, then inserts r2 adjusting stubs between inter-group
  198. calls. <code>ld</code> does not split apart input sections, so cannot
  199. help if a single input file has a <code>.toc</code> section that exceeds
  200. 64K, most likely from linking multiple files with <code>ld -r</code>.
  201. Use this option to turn off this feature.
  202. </p>
  203. <a name="index-PowerPC64-TOC-sorting"></a>
  204. <a name="index-_002d_002dno_002dtoc_002dsort"></a>
  205. </dd>
  206. <dt><samp>--no-toc-sort</samp></dt>
  207. <dd><p>By default, <code>ld</code> sorts TOC sections so that those whose file
  208. happens to have a section called <code>.init</code> or <code>.fini</code> are
  209. placed first, followed by TOC sections referenced by code generated
  210. with PowerPC64 gcc&rsquo;s <code>-mcmodel=small</code>, and lastly TOC sections
  211. referenced only by code generated with PowerPC64 gcc&rsquo;s
  212. <code>-mcmodel=medium</code> or <code>-mcmodel=large</code> options. Doing this
  213. results in better TOC grouping for multi-TOC. Use this option to turn
  214. off this feature.
  215. </p>
  216. <a name="index-PowerPC64-PLT-stub-alignment"></a>
  217. <a name="index-_002d_002dplt_002dalign"></a>
  218. <a name="index-_002d_002dno_002dplt_002dalign"></a>
  219. </dd>
  220. <dt><samp>--plt-align</samp></dt>
  221. <dt><samp>--no-plt-align</samp></dt>
  222. <dd><p>Use these options to control whether individual PLT call stubs are
  223. padded so that they don&rsquo;t cross a 32-byte boundary, or to the
  224. specified power of two boundary when using <code>--plt-align=</code>. Note
  225. that this isn&rsquo;t alignment in the usual sense. By default PLT call
  226. stubs are packed tightly.
  227. </p>
  228. <a name="index-PowerPC64-PLT-call-stub-static-chain"></a>
  229. <a name="index-_002d_002dplt_002dstatic_002dchain"></a>
  230. <a name="index-_002d_002dno_002dplt_002dstatic_002dchain"></a>
  231. </dd>
  232. <dt><samp>--plt-static-chain</samp></dt>
  233. <dt><samp>--no-plt-static-chain</samp></dt>
  234. <dd><p>Use these options to control whether PLT call stubs load the static
  235. chain pointer (r11). <code>ld</code> defaults to not loading the static
  236. chain since there is never any need to do so on a PLT call.
  237. </p>
  238. <a name="index-PowerPC64-PLT-call-stub-thread-safety"></a>
  239. <a name="index-_002d_002dplt_002dthread_002dsafe"></a>
  240. <a name="index-_002d_002dno_002dplt_002dthread_002dsafe"></a>
  241. </dd>
  242. <dt><samp>--plt-thread-safe</samp></dt>
  243. <dt><samp>--no-thread-safe</samp></dt>
  244. <dd><p>With power7&rsquo;s weakly ordered memory model, it is possible when using
  245. lazy binding for ld.so to update a plt entry in one thread and have
  246. another thread see the individual plt entry words update in the wrong
  247. order, despite ld.so carefully writing in the correct order and using
  248. memory write barriers. To avoid this we need some sort of read
  249. barrier in the call stub, or use LD_BIND_NOW=1. By default, <code>ld</code>
  250. looks for calls to commonly used functions that create threads, and if
  251. seen, adds the necessary barriers. Use these options to change the
  252. default behaviour.
  253. </p></dd>
  254. </dl>
  255. <hr>
  256. <div class="header">
  257. <p>
  258. Next: <a href="SPU-ELF.html#SPU-ELF" accesskey="n" rel="next">SPU ELF</a>, Previous: <a href="PowerPC-ELF32.html#PowerPC-ELF32" accesskey="p" rel="prev">PowerPC ELF32</a>, Up: <a href="Machine-Dependent.html#Machine-Dependent" accesskey="u" rel="up">Machine Dependent</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="LD-Index.html#LD-Index" title="Index" rel="index">Index</a>]</p>
  259. </div>
  260. </body>
  261. </html>