您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

331 行
16KB

  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 Arm Embedded Toolchain 10-2020-q4-major)
  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 6.5, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  16. <title>PowerPC64 ELF64 (LD)</title>
  17. <meta name="description" content="PowerPC64 ELF64 (LD)">
  18. <meta name="keywords" content="PowerPC64 ELF64 (LD)">
  19. <meta name="resource-type" content="document">
  20. <meta name="distribution" content="global">
  21. <meta name="Generator" content="makeinfo">
  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="prev" title="PowerPC ELF32">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.indentedblock {margin-right: 0em}
  32. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  33. blockquote.smallquotation {font-size: smaller}
  34. div.display {margin-left: 3.2em}
  35. div.example {margin-left: 3.2em}
  36. div.lisp {margin-left: 3.2em}
  37. div.smalldisplay {margin-left: 3.2em}
  38. div.smallexample {margin-left: 3.2em}
  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.nolinebreak {white-space: nowrap}
  50. span.roman {font-family: initial; 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">
  57. <a name="PowerPC64-ELF64"></a>
  58. <div class="header">
  59. <p>
  60. 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="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>
  61. </div>
  62. <hr>
  63. <a name="ld-and-PowerPC64-64_002dbit-ELF-Support"></a>
  64. <h3 class="section">4.12 <code>ld</code> and PowerPC64 64-bit ELF Support</h3>
  65. <a name="index-PowerPC64-ELF64-options"></a>
  66. <dl compact="compact">
  67. <dd><a name="index-PowerPC64-stub-grouping"></a>
  68. <a name="index-_002d_002dstub_002dgroup_002dsize"></a>
  69. </dd>
  70. <dt><samp>--stub-group-size</samp></dt>
  71. <dd><p>Long branch stubs, PLT call stubs and TOC adjusting stubs are placed
  72. by <code>ld</code> in stub sections located between groups of input sections.
  73. &lsquo;<samp>--stub-group-size</samp>&rsquo; specifies the maximum size of a group of input
  74. sections handled by one stub section. Since branch offsets are signed,
  75. a stub section may serve two groups of input sections, one group before
  76. the stub section, and one group after it. However, when using
  77. conditional branches that require stubs, it may be better (for branch
  78. prediction) that stub sections only serve one group of input sections.
  79. A negative value for &lsquo;<samp>N</samp>&rsquo; chooses this scheme, ensuring that
  80. branches to stubs always use a negative offset. Two special values of
  81. &lsquo;<samp>N</samp>&rsquo; are recognized, &lsquo;<samp>1</samp>&rsquo; and &lsquo;<samp>-1</samp>&rsquo;. These both instruct
  82. <code>ld</code> to automatically size input section groups for the branch types
  83. detected, with the same behaviour regarding stub placement as other
  84. positive or negative values of &lsquo;<samp>N</samp>&rsquo; respectively.
  85. </p>
  86. <p>Note that &lsquo;<samp>--stub-group-size</samp>&rsquo; does not split input sections. A
  87. single input section larger than the group size specified will of course
  88. create a larger group (of one section). If input sections are too
  89. large, it may not be possible for a branch to reach its stub.
  90. </p>
  91. <a name="index-PowerPC64-stub-symbols"></a>
  92. <a name="index-_002d_002demit_002dstub_002dsyms-1"></a>
  93. </dd>
  94. <dt><samp>--emit-stub-syms</samp></dt>
  95. <dd><p>This option causes <code>ld</code> to label linker stubs with a local
  96. symbol that encodes the stub type and destination.
  97. </p>
  98. <a name="index-PowerPC64-dot-symbols"></a>
  99. <a name="index-_002d_002ddotsyms"></a>
  100. <a name="index-_002d_002dno_002ddotsyms"></a>
  101. </dd>
  102. <dt><samp>--dotsyms</samp></dt>
  103. <dt><samp>--no-dotsyms</samp></dt>
  104. <dd><p>These two options control how <code>ld</code> interprets version patterns
  105. in a version script. Older PowerPC64 compilers emitted both a
  106. function descriptor symbol with the same name as the function, and a
  107. code entry symbol with the name prefixed by a dot (&lsquo;<samp>.</samp>&rsquo;). To
  108. properly version a function &lsquo;<samp>foo</samp>&rsquo;, the version script thus needs
  109. to control both &lsquo;<samp>foo</samp>&rsquo; and &lsquo;<samp>.foo</samp>&rsquo;. The option
  110. &lsquo;<samp>--dotsyms</samp>&rsquo;, on by default, automatically adds the required
  111. dot-prefixed patterns. Use &lsquo;<samp>--no-dotsyms</samp>&rsquo; to disable this
  112. feature.
  113. </p>
  114. <a name="index-PowerPC64-register-save_002frestore-functions"></a>
  115. <a name="index-_002d_002dsave_002drestore_002dfuncs"></a>
  116. <a name="index-_002d_002dno_002dsave_002drestore_002dfuncs"></a>
  117. </dd>
  118. <dt><samp>--save-restore-funcs</samp></dt>
  119. <dt><samp>--no-save-restore-funcs</samp></dt>
  120. <dd><p>These two options control whether PowerPC64 <code>ld</code> automatically
  121. provides out-of-line register save and restore functions used by
  122. &lsquo;<samp>-Os</samp>&rsquo; code. The default is to provide any such referenced
  123. function for a normal final link, and to not do so for a relocatable
  124. link.
  125. </p>
  126. <a name="index-PowerPC64-TLS-optimization"></a>
  127. <a name="index-_002d_002dno_002dtls_002doptimize-1"></a>
  128. </dd>
  129. <dt><samp>--no-tls-optimize</samp></dt>
  130. <dd><p>PowerPC64 <code>ld</code> normally performs some optimization of code
  131. sequences used to access Thread-Local Storage. Use this option to
  132. disable the optimization.
  133. </p>
  134. <a name="index-PowerPC64-_005f_005ftls_005fget_005faddr-optimization"></a>
  135. <a name="index-_002d_002dtls_002dget_002daddr_002doptimize"></a>
  136. <a name="index-_002d_002dno_002dtls_002dget_002daddr_002doptimize"></a>
  137. <a name="index-_002d_002dtls_002dget_002daddr_002dregsave"></a>
  138. <a name="index-_002d_002dno_002dtls_002dget_002daddr_002dregsave"></a>
  139. </dd>
  140. <dt><samp>--tls-get-addr-optimize</samp></dt>
  141. <dt><samp>--no-tls-get-addr-optimize</samp></dt>
  142. <dd><p>These options control how PowerPC64 <code>ld</code> uses a special
  143. stub to call __tls_get_addr. PowerPC64 glibc 2.22 and later support
  144. an optimization that allows the second and subsequent calls to
  145. <code>__tls_get_addr</code> for a given symbol to be resolved by the special
  146. stub without calling in to glibc. By default the linker enables
  147. generation of the stub when glibc advertises the availability of
  148. __tls_get_addr_opt.
  149. Using <samp>--tls-get-addr-optimize</samp> with an older glibc won&rsquo;t do
  150. much besides slow down your applications, but may be useful if linking
  151. an application against an older glibc with the expectation that it
  152. will normally be used on systems having a newer glibc.
  153. <samp>--tls-get-addr-regsave</samp> forces generation of a stub that saves
  154. and restores volatile registers around the call into glibc. Normally,
  155. this is done when the linker detects a call to __tls_get_addr_desc.
  156. Such calls then go via the register saving stub to __tls_get_addr_opt.
  157. <samp>--no-tls-get-addr-regsave</samp> disables generation of the
  158. register saves.
  159. </p>
  160. <a name="index-PowerPC64-OPD-optimization"></a>
  161. <a name="index-_002d_002dno_002dopd_002doptimize"></a>
  162. </dd>
  163. <dt><samp>--no-opd-optimize</samp></dt>
  164. <dd><p>PowerPC64 <code>ld</code> normally removes <code>.opd</code> section entries
  165. corresponding to deleted link-once functions, or functions removed by
  166. the action of &lsquo;<samp>--gc-sections</samp>&rsquo; or linker script <code>/DISCARD/</code>.
  167. Use this option to disable <code>.opd</code> optimization.
  168. </p>
  169. <a name="index-PowerPC64-OPD-spacing"></a>
  170. <a name="index-_002d_002dnon_002doverlapping_002dopd"></a>
  171. </dd>
  172. <dt><samp>--non-overlapping-opd</samp></dt>
  173. <dd><p>Some PowerPC64 compilers have an option to generate compressed
  174. <code>.opd</code> entries spaced 16 bytes apart, overlapping the third word,
  175. the static chain pointer (unused in C) with the first word of the next
  176. entry. This option expands such entries to the full 24 bytes.
  177. </p>
  178. <a name="index-PowerPC64-TOC-optimization"></a>
  179. <a name="index-_002d_002dno_002dtoc_002doptimize"></a>
  180. </dd>
  181. <dt><samp>--no-toc-optimize</samp></dt>
  182. <dd><p>PowerPC64 <code>ld</code> normally removes unused <code>.toc</code> section
  183. entries. Such entries are detected by examining relocations that
  184. reference the TOC in code sections. A reloc in a deleted code section
  185. marks a TOC word as unneeded, while a reloc in a kept code section
  186. marks a TOC word as needed. Since the TOC may reference itself, TOC
  187. relocs are also examined. TOC words marked as both needed and
  188. unneeded will of course be kept. TOC words without any referencing
  189. reloc are assumed to be part of a multi-word entry, and are kept or
  190. discarded as per the nearest marked preceding word. This works
  191. reliably for compiler generated code, but may be incorrect if assembly
  192. code is used to insert TOC entries. Use this option to disable the
  193. optimization.
  194. </p>
  195. <a name="index-PowerPC64-inline-PLT-call-optimization"></a>
  196. <a name="index-_002d_002dno_002dinline_002doptimize"></a>
  197. </dd>
  198. <dt><samp>--no-inline-optimize</samp></dt>
  199. <dd><p>PowerPC64 <code>ld</code> normally replaces inline PLT call sequences
  200. marked with <code>R_PPC64_PLTSEQ</code>, <code>R_PPC64_PLTCALL</code>,
  201. <code>R_PPC64_PLT16_HA</code> and <code>R_PPC64_PLT16_LO_DS</code> relocations by
  202. a number of <code>nop</code>s and a direct call when the function is defined
  203. locally and can&rsquo;t be overridden by some other definition. This option
  204. disables that optimization.
  205. </p>
  206. <a name="index-PowerPC64-multi_002dTOC"></a>
  207. <a name="index-_002d_002dno_002dmulti_002dtoc"></a>
  208. </dd>
  209. <dt><samp>--no-multi-toc</samp></dt>
  210. <dd><p>If given any toc option besides <code>-mcmodel=medium</code> or
  211. <code>-mcmodel=large</code>, PowerPC64 GCC generates code for a TOC model
  212. where TOC
  213. entries are accessed with a 16-bit offset from r2. This limits the
  214. total TOC size to 64K. PowerPC64 <code>ld</code> extends this limit by
  215. grouping code sections such that each group uses less than 64K for its
  216. TOC entries, then inserts r2 adjusting stubs between inter-group
  217. calls. <code>ld</code> does not split apart input sections, so cannot
  218. help if a single input file has a <code>.toc</code> section that exceeds
  219. 64K, most likely from linking multiple files with <code>ld -r</code>.
  220. Use this option to turn off this feature.
  221. </p>
  222. <a name="index-PowerPC64-TOC-sorting"></a>
  223. <a name="index-_002d_002dno_002dtoc_002dsort"></a>
  224. </dd>
  225. <dt><samp>--no-toc-sort</samp></dt>
  226. <dd><p>By default, <code>ld</code> sorts TOC sections so that those whose file
  227. happens to have a section called <code>.init</code> or <code>.fini</code> are
  228. placed first, followed by TOC sections referenced by code generated
  229. with PowerPC64 gcc&rsquo;s <code>-mcmodel=small</code>, and lastly TOC sections
  230. referenced only by code generated with PowerPC64 gcc&rsquo;s
  231. <code>-mcmodel=medium</code> or <code>-mcmodel=large</code> options. Doing this
  232. results in better TOC grouping for multi-TOC. Use this option to turn
  233. off this feature.
  234. </p>
  235. <a name="index-PowerPC64-PLT-stub-alignment"></a>
  236. <a name="index-_002d_002dplt_002dalign"></a>
  237. <a name="index-_002d_002dno_002dplt_002dalign"></a>
  238. </dd>
  239. <dt><samp>--plt-align</samp></dt>
  240. <dt><samp>--no-plt-align</samp></dt>
  241. <dd><p>Use these options to control whether individual PLT call stubs are
  242. aligned to a 32-byte boundary, or to the specified power of two
  243. boundary when using <code>--plt-align=</code>. A negative value may be
  244. specified to pad PLT call stubs so that they do not cross the
  245. specified power of two boundary (or the minimum number of boundaries
  246. if a PLT stub is so large that it must cross a boundary). By default
  247. PLT call stubs are aligned to 32-byte boundaries.
  248. </p>
  249. <a name="index-PowerPC64-PLT-call-stub-static-chain"></a>
  250. <a name="index-_002d_002dplt_002dstatic_002dchain"></a>
  251. <a name="index-_002d_002dno_002dplt_002dstatic_002dchain"></a>
  252. </dd>
  253. <dt><samp>--plt-static-chain</samp></dt>
  254. <dt><samp>--no-plt-static-chain</samp></dt>
  255. <dd><p>Use these options to control whether PLT call stubs load the static
  256. chain pointer (r11). <code>ld</code> defaults to not loading the static
  257. chain since there is never any need to do so on a PLT call.
  258. </p>
  259. <a name="index-PowerPC64-PLT-call-stub-thread-safety"></a>
  260. <a name="index-_002d_002dplt_002dthread_002dsafe"></a>
  261. <a name="index-_002d_002dno_002dplt_002dthread_002dsafe"></a>
  262. </dd>
  263. <dt><samp>--plt-thread-safe</samp></dt>
  264. <dt><samp>--no-plt-thread-safe</samp></dt>
  265. <dd><p>With power7&rsquo;s weakly ordered memory model, it is possible when using
  266. lazy binding for ld.so to update a plt entry in one thread and have
  267. another thread see the individual plt entry words update in the wrong
  268. order, despite ld.so carefully writing in the correct order and using
  269. memory write barriers. To avoid this we need some sort of read
  270. barrier in the call stub, or use LD_BIND_NOW=1. By default, <code>ld</code>
  271. looks for calls to commonly used functions that create threads, and if
  272. seen, adds the necessary barriers. Use these options to change the
  273. default behaviour.
  274. </p>
  275. <a name="index-PowerPC64-ELFv2-PLT-localentry-optimization"></a>
  276. <a name="index-_002d_002dplt_002dlocalentry"></a>
  277. <a name="index-_002d_002dno_002dplt_002dlocalentry"></a>
  278. </dd>
  279. <dt><samp>--plt-localentry</samp></dt>
  280. <dt><samp>--no-localentry</samp></dt>
  281. <dd><p>ELFv2 functions with localentry:0 are those with a single entry point,
  282. ie. global entry == local entry, and that have no requirement on r2
  283. (the TOC/GOT pointer) or r12, and guarantee r2 is unchanged on return.
  284. Such an external function can be called via the PLT without saving r2
  285. or restoring it on return, avoiding a common load-hit-store for small
  286. functions. The optimization is attractive, with up to 40% reduction
  287. in execution time for a small function, but can result in symbol
  288. interposition failures. Also, minor changes in a shared library,
  289. including system libraries, can cause a function that was localentry:0
  290. to become localentry:8. This will result in a dynamic loader
  291. complaint and failure to run. The option is experimental, use with
  292. care. <samp>--no-plt-localentry</samp> is the default.
  293. </p>
  294. <a name="index-PowerPC64-Power10-stubs"></a>
  295. <a name="index-_002d_002dpower10_002dstubs"></a>
  296. <a name="index-_002d_002dno_002dpower10_002dstubs"></a>
  297. </dd>
  298. <dt><samp>--power10-stubs</samp></dt>
  299. <dt><samp>--no-power10-stubs</samp></dt>
  300. <dd><p>When PowerPC64 <code>ld</code> links input object files containing
  301. relocations used on power10 prefixed instructions it normally creates
  302. linkage stubs (PLT call and long branch) using power10 instructions
  303. for <code>@notoc</code> PLT calls where <code>r2</code> is not known. The
  304. power10 notoc stubs are smaller and faster, so are preferred for
  305. power10. <samp>--power10-stubs</samp> and <samp>--no-power10-stubs</samp>
  306. allow you to override the linker&rsquo;s selection of stub instructions.
  307. <samp>--power10-stubs=auto</samp> allows the user to select the default
  308. auto mode.
  309. </p></dd>
  310. </dl>
  311. <hr>
  312. <div class="header">
  313. <p>
  314. 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="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>
  315. </div>
  316. </body>
  317. </html>