Scripts.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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: Scripts</title>
  16. <meta name="description" content="LD: Scripts">
  17. <meta name="keywords" content="LD: Scripts">
  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="index.html#Top" rel="up" title="Top">
  26. <link href="Basic-Script-Concepts.html#Basic-Script-Concepts" rel="next" title="Basic Script Concepts">
  27. <link href="Environment.html#Environment" rel="prev" title="Environment">
  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="Scripts"></a>
  59. <div class="header">
  60. <p>
  61. Next: <a href="Machine-Dependent.html#Machine-Dependent" accesskey="n" rel="next">Machine Dependent</a>, Previous: <a href="Invocation.html#Invocation" accesskey="p" rel="prev">Invocation</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</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="Linker-Scripts"></a>
  65. <h2 class="chapter">3 Linker Scripts</h2>
  66. <a name="index-scripts"></a>
  67. <a name="index-linker-scripts"></a>
  68. <a name="index-command-files"></a>
  69. <p>Every link is controlled by a <em>linker script</em>. This script is
  70. written in the linker command language.
  71. </p>
  72. <p>The main purpose of the linker script is to describe how the sections in
  73. the input files should be mapped into the output file, and to control
  74. the memory layout of the output file. Most linker scripts do nothing
  75. more than this. However, when necessary, the linker script can also
  76. direct the linker to perform many other operations, using the commands
  77. described below.
  78. </p>
  79. <p>The linker always uses a linker script. If you do not supply one
  80. yourself, the linker will use a default script that is compiled into the
  81. linker executable. You can use the &lsquo;<samp>--verbose</samp>&rsquo; command line option
  82. to display the default linker script. Certain command line options,
  83. such as &lsquo;<samp>-r</samp>&rsquo; or &lsquo;<samp>-N</samp>&rsquo;, will affect the default linker script.
  84. </p>
  85. <p>You may supply your own linker script by using the &lsquo;<samp>-T</samp>&rsquo; command
  86. line option. When you do this, your linker script will replace the
  87. default linker script.
  88. </p>
  89. <p>You may also use linker scripts implicitly by naming them as input files
  90. to the linker, as though they were files to be linked. See <a href="Implicit-Linker-Scripts.html#Implicit-Linker-Scripts">Implicit Linker Scripts</a>.
  91. </p>
  92. <table class="menu" border="0" cellspacing="0">
  93. <tr><td align="left" valign="top">&bull; <a href="Basic-Script-Concepts.html#Basic-Script-Concepts" accesskey="1">Basic Script Concepts</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Basic Linker Script Concepts
  94. </td></tr>
  95. <tr><td align="left" valign="top">&bull; <a href="Script-Format.html#Script-Format" accesskey="2">Script Format</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Linker Script Format
  96. </td></tr>
  97. <tr><td align="left" valign="top">&bull; <a href="Simple-Example.html#Simple-Example" accesskey="3">Simple Example</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Simple Linker Script Example
  98. </td></tr>
  99. <tr><td align="left" valign="top">&bull; <a href="Simple-Commands.html#Simple-Commands" accesskey="4">Simple Commands</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Simple Linker Script Commands
  100. </td></tr>
  101. <tr><td align="left" valign="top">&bull; <a href="Assignments.html#Assignments" accesskey="5">Assignments</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Assigning Values to Symbols
  102. </td></tr>
  103. <tr><td align="left" valign="top">&bull; <a href="SECTIONS.html#SECTIONS" accesskey="6">SECTIONS</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">SECTIONS Command
  104. </td></tr>
  105. <tr><td align="left" valign="top">&bull; <a href="MEMORY.html#MEMORY" accesskey="7">MEMORY</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">MEMORY Command
  106. </td></tr>
  107. <tr><td align="left" valign="top">&bull; <a href="PHDRS.html#PHDRS" accesskey="8">PHDRS</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">PHDRS Command
  108. </td></tr>
  109. <tr><td align="left" valign="top">&bull; <a href="VERSION.html#VERSION" accesskey="9">VERSION</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">VERSION Command
  110. </td></tr>
  111. <tr><td align="left" valign="top">&bull; <a href="Expressions.html#Expressions">Expressions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Expressions in Linker Scripts
  112. </td></tr>
  113. <tr><td align="left" valign="top">&bull; <a href="Implicit-Linker-Scripts.html#Implicit-Linker-Scripts">Implicit Linker Scripts</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Implicit Linker Scripts
  114. </td></tr>
  115. </table>
  116. <hr>
  117. <div class="header">
  118. <p>
  119. Next: <a href="Machine-Dependent.html#Machine-Dependent" accesskey="n" rel="next">Machine Dependent</a>, Previous: <a href="Invocation.html#Invocation" accesskey="p" rel="prev">Invocation</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</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>
  120. </div>
  121. </body>
  122. </html>