Xtensa.html 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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: Xtensa</title>
  16. <meta name="description" content="LD: Xtensa">
  17. <meta name="keywords" content="LD: Xtensa">
  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="BFD.html#BFD" rel="next" title="BFD">
  27. <link href="WIN32.html#WIN32" rel="prev" title="WIN32">
  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="Xtensa"></a>
  59. <div class="header">
  60. <p>
  61. Previous: <a href="WIN32.html#WIN32" accesskey="p" rel="prev">WIN32</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-Xtensa-Processors"></a>
  65. <h3 class="section">4.17 <code>ld</code> and Xtensa Processors</h3>
  66. <a name="index-Xtensa-processors"></a>
  67. <p>The default <code>ld</code> behavior for Xtensa processors is to interpret
  68. <code>SECTIONS</code> commands so that lists of explicitly named sections in a
  69. specification with a wildcard file will be interleaved when necessary to
  70. keep literal pools within the range of PC-relative load offsets. For
  71. example, with the command:
  72. </p>
  73. <div class="smallexample">
  74. <pre class="smallexample">SECTIONS
  75. {
  76. .text : {
  77. *(.literal .text)
  78. }
  79. }
  80. </pre></div>
  81. <p><code>ld</code> may interleave some of the <code>.literal</code>
  82. and <code>.text</code> sections from different object files to ensure that the
  83. literal pools are within the range of PC-relative load offsets. A valid
  84. interleaving might place the <code>.literal</code> sections from an initial
  85. group of files followed by the <code>.text</code> sections of that group of
  86. files. Then, the <code>.literal</code> sections from the rest of the files
  87. and the <code>.text</code> sections from the rest of the files would follow.
  88. </p>
  89. <a name="index-_002d_002drelax-on-Xtensa"></a>
  90. <a name="index-relaxing-on-Xtensa"></a>
  91. <p>Relaxation is enabled by default for the Xtensa version of <code>ld</code> and
  92. provides two important link-time optimizations. The first optimization
  93. is to combine identical literal values to reduce code size. A redundant
  94. literal will be removed and all the <code>L32R</code> instructions that use it
  95. will be changed to reference an identical literal, as long as the
  96. location of the replacement literal is within the offset range of all
  97. the <code>L32R</code> instructions. The second optimization is to remove
  98. unnecessary overhead from assembler-generated &ldquo;longcall&rdquo; sequences of
  99. <code>L32R</code>/<code>CALLX<var>n</var></code> when the target functions are within
  100. range of direct <code>CALL<var>n</var></code> instructions.
  101. </p>
  102. <p>For each of these cases where an indirect call sequence can be optimized
  103. to a direct call, the linker will change the <code>CALLX<var>n</var></code>
  104. instruction to a <code>CALL<var>n</var></code> instruction, remove the <code>L32R</code>
  105. instruction, and remove the literal referenced by the <code>L32R</code>
  106. instruction if it is not used for anything else. Removing the
  107. <code>L32R</code> instruction always reduces code size but can potentially
  108. hurt performance by changing the alignment of subsequent branch targets.
  109. By default, the linker will always preserve alignments, either by
  110. switching some instructions between 24-bit encodings and the equivalent
  111. density instructions or by inserting a no-op in place of the <code>L32R</code>
  112. instruction that was removed. If code size is more important than
  113. performance, the <samp>--size-opt</samp> option can be used to prevent the
  114. linker from widening density instructions or inserting no-ops, except in
  115. a few cases where no-ops are required for correctness.
  116. </p>
  117. <p>The following Xtensa-specific command-line options can be used to
  118. control the linker:
  119. </p>
  120. <a name="index-Xtensa-options"></a>
  121. <dl compact="compact">
  122. <dt><samp>--size-opt</samp></dt>
  123. <dd><p>When optimizing indirect calls to direct calls, optimize for code size
  124. more than performance. With this option, the linker will not insert
  125. no-ops or widen density instructions to preserve branch target
  126. alignment. There may still be some cases where no-ops are required to
  127. preserve the correctness of the code.
  128. </p></dd>
  129. </dl>
  130. <hr>
  131. <div class="header">
  132. <p>
  133. Previous: <a href="WIN32.html#WIN32" accesskey="p" rel="prev">WIN32</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>
  134. </div>
  135. </body>
  136. </html>