You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 satır
6.1KB

  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>Basic Script Concepts (LD)</title>
  17. <meta name="description" content="Basic Script Concepts (LD)">
  18. <meta name="keywords" content="Basic Script Concepts (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="Scripts.html#Scripts" rel="up" title="Scripts">
  26. <link href="Script-Format.html#Script-Format" rel="next" title="Script Format">
  27. <link href="Scripts.html#Scripts" rel="prev" title="Scripts">
  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="Basic-Script-Concepts"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Script-Format.html#Script-Format" accesskey="n" rel="next">Script Format</a>, Up: <a href="Scripts.html#Scripts" accesskey="u" rel="up">Scripts</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="Basic-Linker-Script-Concepts"></a>
  64. <h3 class="section">3.1 Basic Linker Script Concepts</h3>
  65. <a name="index-linker-script-concepts"></a>
  66. <p>We need to define some basic concepts and vocabulary in order to
  67. describe the linker script language.
  68. </p>
  69. <p>The linker combines input files into a single output file. The output
  70. file and each input file are in a special data format known as an
  71. <em>object file format</em>. Each file is called an <em>object file</em>.
  72. The output file is often called an <em>executable</em>, but for our
  73. purposes we will also call it an object file. Each object file has,
  74. among other things, a list of <em>sections</em>. We sometimes refer to a
  75. section in an input file as an <em>input section</em>; similarly, a section
  76. in the output file is an <em>output section</em>.
  77. </p>
  78. <p>Each section in an object file has a name and a size. Most sections
  79. also have an associated block of data, known as the <em>section
  80. contents</em>. A section may be marked as <em>loadable</em>, which means that
  81. the contents should be loaded into memory when the output file is run.
  82. A section with no contents may be <em>allocatable</em>, which means that an
  83. area in memory should be set aside, but nothing in particular should be
  84. loaded there (in some cases this memory must be zeroed out). A section
  85. which is neither loadable nor allocatable typically contains some sort
  86. of debugging information.
  87. </p>
  88. <p>Every loadable or allocatable output section has two addresses. The
  89. first is the <em>VMA</em>, or virtual memory address. This is the address
  90. the section will have when the output file is run. The second is the
  91. <em>LMA</em>, or load memory address. This is the address at which the
  92. section will be loaded. In most cases the two addresses will be the
  93. same. An example of when they might be different is when a data section
  94. is loaded into ROM, and then copied into RAM when the program starts up
  95. (this technique is often used to initialize global variables in a ROM
  96. based system). In this case the ROM address would be the LMA, and the
  97. RAM address would be the VMA.
  98. </p>
  99. <p>You can see the sections in an object file by using the <code>objdump</code>
  100. program with the &lsquo;<samp>-h</samp>&rsquo; option.
  101. </p>
  102. <p>Every object file also has a list of <em>symbols</em>, known as the
  103. <em>symbol table</em>. A symbol may be defined or undefined. Each symbol
  104. has a name, and each defined symbol has an address, among other
  105. information. If you compile a C or C++ program into an object file, you
  106. will get a defined symbol for every defined function and global or
  107. static variable. Every undefined function or global variable which is
  108. referenced in the input file will become an undefined symbol.
  109. </p>
  110. <p>You can see the symbols in an object file by using the <code>nm</code>
  111. program, or by using the <code>objdump</code> program with the &lsquo;<samp>-t</samp>&rsquo;
  112. option.
  113. </p>
  114. <hr>
  115. <div class="header">
  116. <p>
  117. Next: <a href="Script-Format.html#Script-Format" accesskey="n" rel="next">Script Format</a>, Up: <a href="Scripts.html#Scripts" accesskey="u" rel="up">Scripts</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>
  118. </div>
  119. </body>
  120. </html>