No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

380 líneas
20KB

  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>ARM (LD)</title>
  17. <meta name="description" content="ARM (LD)">
  18. <meta name="keywords" content="ARM (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="HPPA-ELF32.html#HPPA-ELF32" rel="next" title="HPPA ELF32">
  27. <link href="M68HC11_002f68HC12.html#M68HC11_002f68HC12" rel="prev" title="M68HC11/68HC12">
  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="ARM"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="HPPA-ELF32.html#HPPA-ELF32" accesskey="n" rel="next">HPPA ELF32</a>, Previous: <a href="M68HC11_002f68HC12.html#M68HC11_002f68HC12" accesskey="p" rel="prev">M68HC11/68HC12</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-the-ARM-family"></a>
  64. <h3 class="section">4.3 <code>ld</code> and the ARM family</h3>
  65. <a name="index-ARM-interworking-support"></a>
  66. <a name="index-_002d_002dsupport_002dold_002dcode"></a>
  67. <p>For the ARM, <code>ld</code> will generate code stubs to allow functions calls
  68. between ARM and Thumb code. These stubs only work with code that has
  69. been compiled and assembled with the &lsquo;<samp>-mthumb-interwork</samp>&rsquo; command
  70. line option. If it is necessary to link with old ARM object files or
  71. libraries, which have not been compiled with the -mthumb-interwork
  72. option then the &lsquo;<samp>--support-old-code</samp>&rsquo; command-line switch should be
  73. given to the linker. This will make it generate larger stub functions
  74. which will work with non-interworking aware ARM code. Note, however,
  75. the linker does not support generating stubs for function calls to
  76. non-interworking aware Thumb code.
  77. </p>
  78. <a name="index-thumb-entry-point"></a>
  79. <a name="index-entry-point_002c-thumb"></a>
  80. <a name="index-_002d_002dthumb_002dentry_003dentry"></a>
  81. <p>The &lsquo;<samp>--thumb-entry</samp>&rsquo; switch is a duplicate of the generic
  82. &lsquo;<samp>--entry</samp>&rsquo; switch, in that it sets the program&rsquo;s starting address.
  83. But it also sets the bottom bit of the address, so that it can be
  84. branched to using a BX instruction, and the program will start
  85. executing in Thumb mode straight away.
  86. </p>
  87. <a name="index-PE-import-table-prefixing"></a>
  88. <a name="index-_002d_002duse_002dnul_002dprefixed_002dimport_002dtables"></a>
  89. <p>The &lsquo;<samp>--use-nul-prefixed-import-tables</samp>&rsquo; switch is specifying, that
  90. the import tables idata4 and idata5 have to be generated with a zero
  91. element prefix for import libraries. This is the old style to generate
  92. import tables. By default this option is turned off.
  93. </p>
  94. <a name="index-BE8"></a>
  95. <a name="index-_002d_002dbe8"></a>
  96. <p>The &lsquo;<samp>--be8</samp>&rsquo; switch instructs <code>ld</code> to generate BE8 format
  97. executables. This option is only valid when linking big-endian
  98. objects - ie ones which have been assembled with the <samp>-EB</samp>
  99. option. The resulting image will contain big-endian data and
  100. little-endian code.
  101. </p>
  102. <a name="index-TARGET1"></a>
  103. <a name="index-_002d_002dtarget1_002drel"></a>
  104. <a name="index-_002d_002dtarget1_002dabs"></a>
  105. <p>The &lsquo;<samp>R_ARM_TARGET1</samp>&rsquo; relocation is typically used for entries in the
  106. &lsquo;<samp>.init_array</samp>&rsquo; section. It is interpreted as either &lsquo;<samp>R_ARM_REL32</samp>&rsquo;
  107. or &lsquo;<samp>R_ARM_ABS32</samp>&rsquo;, depending on the target. The &lsquo;<samp>--target1-rel</samp>&rsquo;
  108. and &lsquo;<samp>--target1-abs</samp>&rsquo; switches override the default.
  109. </p>
  110. <a name="index-TARGET2"></a>
  111. <a name="index-_002d_002dtarget2_003dtype"></a>
  112. <p>The &lsquo;<samp>--target2=type</samp>&rsquo; switch overrides the default definition of the
  113. &lsquo;<samp>R_ARM_TARGET2</samp>&rsquo; relocation. Valid values for &lsquo;<samp>type</samp>&rsquo;, their
  114. meanings, and target defaults are as follows:
  115. </p><dl compact="compact">
  116. <dt>&lsquo;<samp>rel</samp>&rsquo;</dt>
  117. <dd><p>&lsquo;<samp>R_ARM_REL32</samp>&rsquo; (arm*-*-elf, arm*-*-eabi)
  118. </p></dd>
  119. <dt>&lsquo;<samp>abs</samp>&rsquo;</dt>
  120. <dd><p>&lsquo;<samp>R_ARM_ABS32</samp>&rsquo; (arm*-*-symbianelf)
  121. </p></dd>
  122. <dt>&lsquo;<samp>got-rel</samp>&rsquo;</dt>
  123. <dd><p>&lsquo;<samp>R_ARM_GOT_PREL</samp>&rsquo; (arm*-*-linux, arm*-*-*bsd)
  124. </p></dd>
  125. </dl>
  126. <a name="index-FIX_005fV4BX"></a>
  127. <a name="index-_002d_002dfix_002dv4bx"></a>
  128. <p>The &lsquo;<samp>R_ARM_V4BX</samp>&rsquo; relocation (defined by the ARM AAELF
  129. specification) enables objects compiled for the ARMv4 architecture to be
  130. interworking-safe when linked with other objects compiled for ARMv4t, but
  131. also allows pure ARMv4 binaries to be built from the same ARMv4 objects.
  132. </p>
  133. <p>In the latter case, the switch <samp>--fix-v4bx</samp> must be passed to the
  134. linker, which causes v4t <code>BX rM</code> instructions to be rewritten as
  135. <code>MOV PC,rM</code>, since v4 processors do not have a <code>BX</code> instruction.
  136. </p>
  137. <p>In the former case, the switch should not be used, and &lsquo;<samp>R_ARM_V4BX</samp>&rsquo;
  138. relocations are ignored.
  139. </p>
  140. <a name="index-FIX_005fV4BX_005fINTERWORKING"></a>
  141. <a name="index-_002d_002dfix_002dv4bx_002dinterworking"></a>
  142. <p>Replace <code>BX rM</code> instructions identified by &lsquo;<samp>R_ARM_V4BX</samp>&rsquo;
  143. relocations with a branch to the following veneer:
  144. </p>
  145. <div class="smallexample">
  146. <pre class="smallexample">TST rM, #1
  147. MOVEQ PC, rM
  148. BX Rn
  149. </pre></div>
  150. <p>This allows generation of libraries/applications that work on ARMv4 cores
  151. and are still interworking safe. Note that the above veneer clobbers the
  152. condition flags, so may cause incorrect program behavior in rare cases.
  153. </p>
  154. <a name="index-USE_005fBLX"></a>
  155. <a name="index-_002d_002duse_002dblx"></a>
  156. <p>The &lsquo;<samp>--use-blx</samp>&rsquo; switch enables the linker to use ARM/Thumb
  157. BLX instructions (available on ARMv5t and above) in various
  158. situations. Currently it is used to perform calls via the PLT from Thumb
  159. code using BLX rather than using BX and a mode-switching stub before
  160. each PLT entry. This should lead to such calls executing slightly faster.
  161. </p>
  162. <p>This option is enabled implicitly for SymbianOS, so there is no need to
  163. specify it if you are using that target.
  164. </p>
  165. <a name="index-VFP11_005fDENORM_005fFIX"></a>
  166. <a name="index-_002d_002dvfp11_002ddenorm_002dfix"></a>
  167. <p>The &lsquo;<samp>--vfp11-denorm-fix</samp>&rsquo; switch enables a link-time workaround for a
  168. bug in certain VFP11 coprocessor hardware, which sometimes allows
  169. instructions with denorm operands (which must be handled by support code)
  170. to have those operands overwritten by subsequent instructions before
  171. the support code can read the intended values.
  172. </p>
  173. <p>The bug may be avoided in scalar mode if you allow at least one
  174. intervening instruction between a VFP11 instruction which uses a register
  175. and another instruction which writes to the same register, or at least two
  176. intervening instructions if vector mode is in use. The bug only affects
  177. full-compliance floating-point mode: you do not need this workaround if
  178. you are using &quot;runfast&quot; mode. Please contact ARM for further details.
  179. </p>
  180. <p>If you know you are using buggy VFP11 hardware, you can
  181. enable this workaround by specifying the linker option
  182. &lsquo;<samp>--vfp-denorm-fix=scalar</samp>&rsquo; if you are using the VFP11 scalar
  183. mode only, or &lsquo;<samp>--vfp-denorm-fix=vector</samp>&rsquo; if you are using
  184. vector mode (the latter also works for scalar code). The default is
  185. &lsquo;<samp>--vfp-denorm-fix=none</samp>&rsquo;.
  186. </p>
  187. <p>If the workaround is enabled, instructions are scanned for
  188. potentially-troublesome sequences, and a veneer is created for each
  189. such sequence which may trigger the erratum. The veneer consists of the
  190. first instruction of the sequence and a branch back to the subsequent
  191. instruction. The original instruction is then replaced with a branch to
  192. the veneer. The extra cycles required to call and return from the veneer
  193. are sufficient to avoid the erratum in both the scalar and vector cases.
  194. </p>
  195. <a name="index-ARM1176-erratum-workaround"></a>
  196. <a name="index-_002d_002dfix_002darm1176"></a>
  197. <a name="index-_002d_002dno_002dfix_002darm1176"></a>
  198. <p>The &lsquo;<samp>--fix-arm1176</samp>&rsquo; switch enables a link-time workaround for an erratum
  199. in certain ARM1176 processors. The workaround is enabled by default if you
  200. are targeting ARM v6 (excluding ARM v6T2) or earlier. It can be disabled
  201. unconditionally by specifying &lsquo;<samp>--no-fix-arm1176</samp>&rsquo;.
  202. </p>
  203. <p>Further information is available in the &ldquo;ARM1176JZ-S and ARM1176JZF-S
  204. Programmer Advice Notice&rdquo; available on the ARM documentation website at:
  205. http://infocenter.arm.com/.
  206. </p>
  207. <a name="index-STM32L4xx-erratum-workaround"></a>
  208. <a name="index-_002d_002dfix_002dstm32l4xx_002d629360"></a>
  209. <p>The &lsquo;<samp>--fix-stm32l4xx-629360</samp>&rsquo; switch enables a link-time
  210. workaround for a bug in the bus matrix / memory controller for some of
  211. the STM32 Cortex-M4 based products (STM32L4xx). When accessing
  212. off-chip memory via the affected bus for bus reads of 9 words or more,
  213. the bus can generate corrupt data and/or abort. These are only
  214. core-initiated accesses (not DMA), and might affect any access:
  215. integer loads such as LDM, POP and floating-point loads such as VLDM,
  216. VPOP. Stores are not affected.
  217. </p>
  218. <p>The bug can be avoided by splitting memory accesses into the
  219. necessary chunks to keep bus reads below 8 words.
  220. </p>
  221. <p>The workaround is not enabled by default, this is equivalent to use
  222. &lsquo;<samp>--fix-stm32l4xx-629360=none</samp>&rsquo;. If you know you are using buggy
  223. STM32L4xx hardware, you can enable the workaround by specifying the
  224. linker option &lsquo;<samp>--fix-stm32l4xx-629360</samp>&rsquo;, or the equivalent
  225. &lsquo;<samp>--fix-stm32l4xx-629360=default</samp>&rsquo;.
  226. </p>
  227. <p>If the workaround is enabled, instructions are scanned for
  228. potentially-troublesome sequences, and a veneer is created for each
  229. such sequence which may trigger the erratum. The veneer consists in a
  230. replacement sequence emulating the behaviour of the original one and a
  231. branch back to the subsequent instruction. The original instruction is
  232. then replaced with a branch to the veneer.
  233. </p>
  234. <p>The workaround does not always preserve the memory access order for
  235. the LDMDB instruction, when the instruction loads the PC.
  236. </p>
  237. <p>The workaround is not able to handle problematic instructions when
  238. they are in the middle of an IT block, since a branch is not allowed
  239. there. In that case, the linker reports a warning and no replacement
  240. occurs.
  241. </p>
  242. <p>The workaround is not able to replace problematic instructions with a
  243. PC-relative branch instruction if the &lsquo;<samp>.text</samp>&rsquo; section is too
  244. large. In that case, when the branch that replaces the original code
  245. cannot be encoded, the linker reports a warning and no replacement
  246. occurs.
  247. </p>
  248. <a name="index-NO_005fENUM_005fSIZE_005fWARNING"></a>
  249. <a name="index-_002d_002dno_002denum_002dsize_002dwarning"></a>
  250. <p>The <samp>--no-enum-size-warning</samp> switch prevents the linker from
  251. warning when linking object files that specify incompatible EABI
  252. enumeration size attributes. For example, with this switch enabled,
  253. linking of an object file using 32-bit enumeration values with another
  254. using enumeration values fitted into the smallest possible space will
  255. not be diagnosed.
  256. </p>
  257. <a name="index-NO_005fWCHAR_005fSIZE_005fWARNING"></a>
  258. <a name="index-_002d_002dno_002dwchar_002dsize_002dwarning"></a>
  259. <p>The <samp>--no-wchar-size-warning</samp> switch prevents the linker from
  260. warning when linking object files that specify incompatible EABI
  261. <code>wchar_t</code> size attributes. For example, with this switch enabled,
  262. linking of an object file using 32-bit <code>wchar_t</code> values with another
  263. using 16-bit <code>wchar_t</code> values will not be diagnosed.
  264. </p>
  265. <a name="index-PIC_005fVENEER"></a>
  266. <a name="index-_002d_002dpic_002dveneer"></a>
  267. <p>The &lsquo;<samp>--pic-veneer</samp>&rsquo; switch makes the linker use PIC sequences for
  268. ARM/Thumb interworking veneers, even if the rest of the binary
  269. is not PIC. This avoids problems on uClinux targets where
  270. &lsquo;<samp>--emit-relocs</samp>&rsquo; is used to generate relocatable binaries.
  271. </p>
  272. <a name="index-STUB_005fGROUP_005fSIZE"></a>
  273. <a name="index-_002d_002dstub_002dgroup_002dsize_003dN"></a>
  274. <p>The linker will automatically generate and insert small sequences of
  275. code into a linked ARM ELF executable whenever an attempt is made to
  276. perform a function call to a symbol that is too far away. The
  277. placement of these sequences of instructions - called stubs - is
  278. controlled by the command-line option <samp>--stub-group-size=N</samp>.
  279. The placement is important because a poor choice can create a need for
  280. duplicate stubs, increasing the code size. The linker will try to
  281. group stubs together in order to reduce interruptions to the flow of
  282. code, but it needs guidance as to how big these groups should be and
  283. where they should be placed.
  284. </p>
  285. <p>The value of &lsquo;<samp>N</samp>&rsquo;, the parameter to the
  286. <samp>--stub-group-size=</samp> option controls where the stub groups are
  287. placed. If it is negative then all stubs are placed after the first
  288. branch that needs them. If it is positive then the stubs can be
  289. placed either before or after the branches that need them. If the
  290. value of &lsquo;<samp>N</samp>&rsquo; is 1 (either +1 or -1) then the linker will choose
  291. exactly where to place groups of stubs, using its built in heuristics.
  292. A value of &lsquo;<samp>N</samp>&rsquo; greater than 1 (or smaller than -1) tells the
  293. linker that a single group of stubs can service at most &lsquo;<samp>N</samp>&rsquo; bytes
  294. from the input sections.
  295. </p>
  296. <p>The default, if <samp>--stub-group-size=</samp> is not specified, is
  297. &lsquo;<samp>N = +1</samp>&rsquo;.
  298. </p>
  299. <p>Farcalls stubs insertion is fully supported for the ARM-EABI target
  300. only, because it relies on object files properties not present
  301. otherwise.
  302. </p>
  303. <a name="index-Cortex_002dA8-erratum-workaround"></a>
  304. <a name="index-_002d_002dfix_002dcortex_002da8"></a>
  305. <a name="index-_002d_002dno_002dfix_002dcortex_002da8"></a>
  306. <p>The &lsquo;<samp>--fix-cortex-a8</samp>&rsquo; switch enables a link-time workaround for an erratum in certain Cortex-A8 processors. The workaround is enabled by default if you are targeting the ARM v7-A architecture profile. It can be enabled otherwise by specifying &lsquo;<samp>--fix-cortex-a8</samp>&rsquo;, or disabled unconditionally by specifying &lsquo;<samp>--no-fix-cortex-a8</samp>&rsquo;.
  307. </p>
  308. <p>The erratum only affects Thumb-2 code. Please contact ARM for further details.
  309. </p>
  310. <a name="index-Cortex_002dA53-erratum-835769-workaround"></a>
  311. <a name="index-_002d_002dfix_002dcortex_002da53_002d835769"></a>
  312. <a name="index-_002d_002dno_002dfix_002dcortex_002da53_002d835769"></a>
  313. <p>The &lsquo;<samp>--fix-cortex-a53-835769</samp>&rsquo; switch enables a link-time workaround for erratum 835769 present on certain early revisions of Cortex-A53 processors. The workaround is disabled by default. It can be enabled by specifying &lsquo;<samp>--fix-cortex-a53-835769</samp>&rsquo;, or disabled unconditionally by specifying &lsquo;<samp>--no-fix-cortex-a53-835769</samp>&rsquo;.
  314. </p>
  315. <p>Please contact ARM for further details.
  316. </p>
  317. <a name="index-_002d_002dmerge_002dexidx_002dentries"></a>
  318. <a name="index-_002d_002dno_002dmerge_002dexidx_002dentries-1"></a>
  319. <a name="index-Merging-exidx-entries"></a>
  320. <p>The &lsquo;<samp>--no-merge-exidx-entries</samp>&rsquo; switch disables the merging of adjacent exidx entries in debuginfo.
  321. </p>
  322. <a name="index-_002d_002dlong_002dplt"></a>
  323. <a name="index-32_002dbit-PLT-entries"></a>
  324. <p>The &lsquo;<samp>--long-plt</samp>&rsquo; option enables the use of 16 byte PLT entries
  325. which support up to 4Gb of code. The default is to use 12 byte PLT
  326. entries which only support 512Mb of code.
  327. </p>
  328. <a name="index-_002d_002dno_002dapply_002ddynamic_002drelocs"></a>
  329. <a name="index-AArch64-rela-addend"></a>
  330. <p>The &lsquo;<samp>--no-apply-dynamic-relocs</samp>&rsquo; option makes AArch64 linker do not apply
  331. link-time values for dynamic relocations.
  332. </p>
  333. <a name="index-Placement-of-SG-veneers"></a>
  334. <p>All SG veneers are placed in the special output section <code>.gnu.sgstubs</code>.
  335. Its start address must be set, either with the command-line option
  336. &lsquo;<samp>--section-start</samp>&rsquo; or in a linker script, to indicate where to place these
  337. veneers in memory.
  338. </p>
  339. <a name="index-_002d_002dcmse_002dimplib"></a>
  340. <a name="index-Secure-gateway-import-library"></a>
  341. <p>The &lsquo;<samp>--cmse-implib</samp>&rsquo; option requests that the import libraries
  342. specified by the &lsquo;<samp>--out-implib</samp>&rsquo; and &lsquo;<samp>--in-implib</samp>&rsquo; options are
  343. secure gateway import libraries, suitable for linking a non-secure
  344. executable against secure code as per ARMv8-M Security Extensions.
  345. </p>
  346. <a name="index-_002d_002din_002dimplib_003dfile"></a>
  347. <a name="index-Input-import-library"></a>
  348. <p>The &lsquo;<samp>--in-implib=file</samp>&rsquo; specifies an input import library whose symbols
  349. must keep the same address in the executable being produced. A warning is
  350. given if no &lsquo;<samp>--out-implib</samp>&rsquo; is given but new symbols have been introduced
  351. in the executable that should be listed in its import library. Otherwise, if
  352. &lsquo;<samp>--out-implib</samp>&rsquo; is specified, the symbols are added to the output import
  353. library. A warning is also given if some symbols present in the input import
  354. library have disappeared from the executable. This option is only effective
  355. for Secure Gateway import libraries, ie. when &lsquo;<samp>--cmse-implib</samp>&rsquo; is
  356. specified.
  357. </p>
  358. <hr>
  359. <div class="header">
  360. <p>
  361. Next: <a href="HPPA-ELF32.html#HPPA-ELF32" accesskey="n" rel="next">HPPA ELF32</a>, Previous: <a href="M68HC11_002f68HC12.html#M68HC11_002f68HC12" accesskey="p" rel="prev">M68HC11/68HC12</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>
  362. </div>
  363. </body>
  364. </html>