PowerPC64-ELF64.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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 Toolchain for the A-profile Architecture 10.2-2020.11 (arm-10.16))
  5. version 2.35.1.
  6. Copyright (C) 1991-2020 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.1, 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="S_002f390-ELF.html#S_002f390-ELF" rel="next" title="S/390 ELF">
  27. <link href="PowerPC-ELF32.html#PowerPC-ELF32" rel="previous" 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="S_002f390-ELF.html#S_002f390-ELF" accesskey="n" rel="next">S/390 ELF</a>, Previous: <a href="PowerPC-ELF32.html#PowerPC-ELF32" accesskey="p" rel="previous">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.12 <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. <a name="index-_002d_002dtls_002dget_002daddr_002dregsave"></a>
  139. <a name="index-_002d_002dno_002dtls_002dget_002daddr_002dregsave"></a>
  140. </dd>
  141. <dt><samp>--tls-get-addr-optimize</samp></dt>
  142. <dt><samp>--no-tls-get-addr-optimize</samp></dt>
  143. <dd><p>These options control how PowerPC64 <code>ld</code> uses a special
  144. stub to call __tls_get_addr. PowerPC64 glibc 2.22 and later support
  145. an optimization that allows the second and subsequent calls to
  146. <code>__tls_get_addr</code> for a given symbol to be resolved by the special
  147. stub without calling in to glibc. By default the linker enables
  148. generation of the stub when glibc advertises the availability of
  149. __tls_get_addr_opt.
  150. Using <samp>--tls-get-addr-optimize</samp> with an older glibc won&rsquo;t do
  151. much besides slow down your applications, but may be useful if linking
  152. an application against an older glibc with the expectation that it
  153. will normally be used on systems having a newer glibc.
  154. <samp>--tls-get-addr-regsave</samp> forces generation of a stub that saves
  155. and restores volatile registers around the call into glibc. Normally,
  156. this is done when the linker detects a call to __tls_get_addr_desc.
  157. Such calls then go via the register saving stub to __tls_get_addr_opt.
  158. <samp>--no-tls-get-addr-regsave</samp> disables generation of the
  159. register saves.
  160. </p>
  161. <a name="index-PowerPC64-OPD-optimization"></a>
  162. <a name="index-_002d_002dno_002dopd_002doptimize"></a>
  163. </dd>
  164. <dt><samp>--no-opd-optimize</samp></dt>
  165. <dd><p>PowerPC64 <code>ld</code> normally removes <code>.opd</code> section entries
  166. corresponding to deleted link-once functions, or functions removed by
  167. the action of &lsquo;<samp>--gc-sections</samp>&rsquo; or linker script <code>/DISCARD/</code>.
  168. Use this option to disable <code>.opd</code> optimization.
  169. </p>
  170. <a name="index-PowerPC64-OPD-spacing"></a>
  171. <a name="index-_002d_002dnon_002doverlapping_002dopd"></a>
  172. </dd>
  173. <dt><samp>--non-overlapping-opd</samp></dt>
  174. <dd><p>Some PowerPC64 compilers have an option to generate compressed
  175. <code>.opd</code> entries spaced 16 bytes apart, overlapping the third word,
  176. the static chain pointer (unused in C) with the first word of the next
  177. entry. This option expands such entries to the full 24 bytes.
  178. </p>
  179. <a name="index-PowerPC64-TOC-optimization"></a>
  180. <a name="index-_002d_002dno_002dtoc_002doptimize"></a>
  181. </dd>
  182. <dt><samp>--no-toc-optimize</samp></dt>
  183. <dd><p>PowerPC64 <code>ld</code> normally removes unused <code>.toc</code> section
  184. entries. Such entries are detected by examining relocations that
  185. reference the TOC in code sections. A reloc in a deleted code section
  186. marks a TOC word as unneeded, while a reloc in a kept code section
  187. marks a TOC word as needed. Since the TOC may reference itself, TOC
  188. relocs are also examined. TOC words marked as both needed and
  189. unneeded will of course be kept. TOC words without any referencing
  190. reloc are assumed to be part of a multi-word entry, and are kept or
  191. discarded as per the nearest marked preceding word. This works
  192. reliably for compiler generated code, but may be incorrect if assembly
  193. code is used to insert TOC entries. Use this option to disable the
  194. optimization.
  195. </p>
  196. <a name="index-PowerPC64-inline-PLT-call-optimization"></a>
  197. <a name="index-_002d_002dno_002dinline_002doptimize"></a>
  198. </dd>
  199. <dt><samp>--no-inline-optimize</samp></dt>
  200. <dd><p>PowerPC64 <code>ld</code> normally replaces inline PLT call sequences
  201. marked with <code>R_PPC64_PLTSEQ</code>, <code>R_PPC64_PLTCALL</code>,
  202. <code>R_PPC64_PLT16_HA</code> and <code>R_PPC64_PLT16_LO_DS</code> relocations by
  203. a number of <code>nop</code>s and a direct call when the function is defined
  204. locally and can&rsquo;t be overridden by some other definition. This option
  205. disables that optimization.
  206. </p>
  207. <a name="index-PowerPC64-multi_002dTOC"></a>
  208. <a name="index-_002d_002dno_002dmulti_002dtoc"></a>
  209. </dd>
  210. <dt><samp>--no-multi-toc</samp></dt>
  211. <dd><p>If given any toc option besides <code>-mcmodel=medium</code> or
  212. <code>-mcmodel=large</code>, PowerPC64 GCC generates code for a TOC model
  213. where TOC
  214. entries are accessed with a 16-bit offset from r2. This limits the
  215. total TOC size to 64K. PowerPC64 <code>ld</code> extends this limit by
  216. grouping code sections such that each group uses less than 64K for its
  217. TOC entries, then inserts r2 adjusting stubs between inter-group
  218. calls. <code>ld</code> does not split apart input sections, so cannot
  219. help if a single input file has a <code>.toc</code> section that exceeds
  220. 64K, most likely from linking multiple files with <code>ld -r</code>.
  221. Use this option to turn off this feature.
  222. </p>
  223. <a name="index-PowerPC64-TOC-sorting"></a>
  224. <a name="index-_002d_002dno_002dtoc_002dsort"></a>
  225. </dd>
  226. <dt><samp>--no-toc-sort</samp></dt>
  227. <dd><p>By default, <code>ld</code> sorts TOC sections so that those whose file
  228. happens to have a section called <code>.init</code> or <code>.fini</code> are
  229. placed first, followed by TOC sections referenced by code generated
  230. with PowerPC64 gcc&rsquo;s <code>-mcmodel=small</code>, and lastly TOC sections
  231. referenced only by code generated with PowerPC64 gcc&rsquo;s
  232. <code>-mcmodel=medium</code> or <code>-mcmodel=large</code> options. Doing this
  233. results in better TOC grouping for multi-TOC. Use this option to turn
  234. off this feature.
  235. </p>
  236. <a name="index-PowerPC64-PLT-stub-alignment"></a>
  237. <a name="index-_002d_002dplt_002dalign"></a>
  238. <a name="index-_002d_002dno_002dplt_002dalign"></a>
  239. </dd>
  240. <dt><samp>--plt-align</samp></dt>
  241. <dt><samp>--no-plt-align</samp></dt>
  242. <dd><p>Use these options to control whether individual PLT call stubs are
  243. aligned to a 32-byte boundary, or to the specified power of two
  244. boundary when using <code>--plt-align=</code>. A negative value may be
  245. specified to pad PLT call stubs so that they do not cross the
  246. specified power of two boundary (or the minimum number of boundaries
  247. if a PLT stub is so large that it must cross a boundary). By default
  248. PLT call stubs are aligned to 32-byte boundaries.
  249. </p>
  250. <a name="index-PowerPC64-PLT-call-stub-static-chain"></a>
  251. <a name="index-_002d_002dplt_002dstatic_002dchain"></a>
  252. <a name="index-_002d_002dno_002dplt_002dstatic_002dchain"></a>
  253. </dd>
  254. <dt><samp>--plt-static-chain</samp></dt>
  255. <dt><samp>--no-plt-static-chain</samp></dt>
  256. <dd><p>Use these options to control whether PLT call stubs load the static
  257. chain pointer (r11). <code>ld</code> defaults to not loading the static
  258. chain since there is never any need to do so on a PLT call.
  259. </p>
  260. <a name="index-PowerPC64-PLT-call-stub-thread-safety"></a>
  261. <a name="index-_002d_002dplt_002dthread_002dsafe"></a>
  262. <a name="index-_002d_002dno_002dplt_002dthread_002dsafe"></a>
  263. </dd>
  264. <dt><samp>--plt-thread-safe</samp></dt>
  265. <dt><samp>--no-plt-thread-safe</samp></dt>
  266. <dd><p>With power7&rsquo;s weakly ordered memory model, it is possible when using
  267. lazy binding for ld.so to update a plt entry in one thread and have
  268. another thread see the individual plt entry words update in the wrong
  269. order, despite ld.so carefully writing in the correct order and using
  270. memory write barriers. To avoid this we need some sort of read
  271. barrier in the call stub, or use LD_BIND_NOW=1. By default, <code>ld</code>
  272. looks for calls to commonly used functions that create threads, and if
  273. seen, adds the necessary barriers. Use these options to change the
  274. default behaviour.
  275. </p>
  276. <a name="index-PowerPC64-ELFv2-PLT-localentry-optimization"></a>
  277. <a name="index-_002d_002dplt_002dlocalentry"></a>
  278. <a name="index-_002d_002dno_002dplt_002dlocalentry"></a>
  279. </dd>
  280. <dt><samp>--plt-localentry</samp></dt>
  281. <dt><samp>--no-localentry</samp></dt>
  282. <dd><p>ELFv2 functions with localentry:0 are those with a single entry point,
  283. ie. global entry == local entry, and that have no requirement on r2
  284. (the TOC/GOT pointer) or r12, and guarantee r2 is unchanged on return.
  285. Such an external function can be called via the PLT without saving r2
  286. or restoring it on return, avoiding a common load-hit-store for small
  287. functions. The optimization is attractive, with up to 40% reduction
  288. in execution time for a small function, but can result in symbol
  289. interposition failures. Also, minor changes in a shared library,
  290. including system libraries, can cause a function that was localentry:0
  291. to become localentry:8. This will result in a dynamic loader
  292. complaint and failure to run. The option is experimental, use with
  293. care. <samp>--no-plt-localentry</samp> is the default.
  294. </p>
  295. <a name="index-PowerPC64-Power10-stubs"></a>
  296. <a name="index-_002d_002dpower10_002dstubs"></a>
  297. <a name="index-_002d_002dno_002dpower10_002dstubs"></a>
  298. </dd>
  299. <dt><samp>--power10-stubs</samp></dt>
  300. <dt><samp>--no-power10-stubs</samp></dt>
  301. <dd><p>When PowerPC64 <code>ld</code> links input object files containing
  302. relocations used on power10 prefixed instructions it normally creates
  303. linkage stubs (PLT call and long branch) using power10 instructions
  304. for <code>@notoc</code> PLT calls where <code>r2</code> is not known. The
  305. power10 notoc stubs are smaller and faster, so are preferred for
  306. power10. <samp>--power10-stubs</samp> and <samp>--no-power10-stubs</samp>
  307. allow you to override the linker&rsquo;s selection of stub instructions.
  308. <samp>--power10-stubs=auto</samp> allows the user to select the default
  309. auto mode.
  310. </p></dd>
  311. </dl>
  312. <hr>
  313. <div class="header">
  314. <p>
  315. Next: <a href="S_002f390-ELF.html#S_002f390-ELF" accesskey="n" rel="next">S/390 ELF</a>, Previous: <a href="PowerPC-ELF32.html#PowerPC-ELF32" accesskey="p" rel="previous">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>
  316. </div>
  317. </body>
  318. </html>