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.

199 lines
8.5KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>LTO object file layout (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="LTO object file layout (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="LTO object file layout (GNU Compiler Collection (GCC) Internals)">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="LTO.html#LTO" rel="up" title="LTO">
  30. <link href="IPA.html#IPA" rel="next" title="IPA">
  31. <link href="LTO-Overview.html#LTO-Overview" rel="prev" title="LTO Overview">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style: oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="LTO-object-file-layout"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="IPA.html#IPA" accesskey="n" rel="next">IPA</a>, Previous: <a href="LTO-Overview.html#LTO-Overview" accesskey="p" rel="prev">LTO Overview</a>, Up: <a href="LTO.html#LTO" accesskey="u" rel="up">LTO</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  65. </div>
  66. <hr>
  67. <a name="LTO-file-sections"></a>
  68. <h3 class="section">25.2 LTO file sections</h3>
  69. <p>LTO information is stored in several ELF sections inside object files.
  70. Data structures and enum codes for sections are defined in
  71. <samp>lto-streamer.h</samp>.
  72. </p>
  73. <p>These sections are emitted from <samp>lto-streamer-out.c</samp> and mapped
  74. in all at once from <samp>lto/lto.c</samp>:<code>lto_file_read</code>. The
  75. individual functions dealing with the reading/writing of each section
  76. are described below.
  77. </p>
  78. <ul>
  79. <li> Command line options (<code>.gnu.lto_.opts</code>)
  80. <p>This section contains the command line options used to generate the
  81. object files. This is used at link time to determine the optimization
  82. level and other settings when they are not explicitly specified at the
  83. linker command line.
  84. </p>
  85. <p>Currently, GCC does not support combining LTO object files compiled
  86. with different set of the command line options into a single binary.
  87. At link time, the options given on the command line and the options
  88. saved on all the files in a link-time set are applied globally. No
  89. attempt is made at validating the combination of flags (other than the
  90. usual validation done by option processing). This is implemented in
  91. <samp>lto/lto.c</samp>:<code>lto_read_all_file_options</code>.
  92. </p>
  93. </li><li> Symbol table (<code>.gnu.lto_.symtab</code>)
  94. <p>This table replaces the ELF symbol table for functions and variables
  95. represented in the LTO IL. Symbols used and exported by the optimized
  96. assembly code of &ldquo;fat&rdquo; objects might not match the ones used and
  97. exported by the intermediate code. This table is necessary because
  98. the intermediate code is less optimized and thus requires a separate
  99. symbol table.
  100. </p>
  101. <p>Additionally, the binary code in the &ldquo;fat&rdquo; object will lack a call
  102. to a function, since the call was optimized out at compilation time
  103. after the intermediate language was streamed out. In some special
  104. cases, the same optimization may not happen during link-time
  105. optimization. This would lead to an undefined symbol if only one
  106. symbol table was used.
  107. </p>
  108. <p>The symbol table is emitted in
  109. <samp>lto-streamer-out.c</samp>:<code>produce_symtab</code>.
  110. </p>
  111. </li><li> Global declarations and types (<code>.gnu.lto_.decls</code>)
  112. <p>This section contains an intermediate language dump of all
  113. declarations and types required to represent the callgraph, static
  114. variables and top-level debug info.
  115. </p>
  116. <p>The contents of this section are emitted in
  117. <samp>lto-streamer-out.c</samp>:<code>produce_asm_for_decls</code>. Types and
  118. symbols are emitted in a topological order that preserves the sharing
  119. of pointers when the file is read back in
  120. (<samp>lto.c</samp>:<code>read_cgraph_and_symbols</code>).
  121. </p>
  122. </li><li> The callgraph (<code>.gnu.lto_.cgraph</code>)
  123. <p>This section contains the basic data structure used by the GCC
  124. inter-procedural optimization infrastructure. This section stores an
  125. annotated multi-graph which represents the functions and call sites as
  126. well as the variables, aliases and top-level <code>asm</code> statements.
  127. </p>
  128. <p>This section is emitted in
  129. <samp>lto-streamer-out.c</samp>:<code>output_cgraph</code> and read in
  130. <samp>lto-cgraph.c</samp>:<code>input_cgraph</code>.
  131. </p>
  132. </li><li> IPA references (<code>.gnu.lto_.refs</code>)
  133. <p>This section contains references between function and static
  134. variables. It is emitted by <samp>lto-cgraph.c</samp>:<code>output_refs</code>
  135. and read by <samp>lto-cgraph.c</samp>:<code>input_refs</code>.
  136. </p>
  137. </li><li> Function bodies (<code>.gnu.lto_.function_body.&lt;name&gt;</code>)
  138. <p>This section contains function bodies in the intermediate language
  139. representation. Every function body is in a separate section to allow
  140. copying of the section independently to different object files or
  141. reading the function on demand.
  142. </p>
  143. <p>Functions are emitted in
  144. <samp>lto-streamer-out.c</samp>:<code>output_function</code> and read in
  145. <samp>lto-streamer-in.c</samp>:<code>input_function</code>.
  146. </p>
  147. </li><li> Static variable initializers (<code>.gnu.lto_.vars</code>)
  148. <p>This section contains all the symbols in the global variable pool. It
  149. is emitted by <samp>lto-cgraph.c</samp>:<code>output_varpool</code> and read in
  150. <samp>lto-cgraph.c</samp>:<code>input_cgraph</code>.
  151. </p>
  152. </li><li> Summaries and optimization summaries used by IPA passes
  153. (<code>.gnu.lto_.&lt;xxx&gt;</code>, where <code>&lt;xxx&gt;</code> is one of <code>jmpfuncs</code>,
  154. <code>pureconst</code> or <code>reference</code>)
  155. <p>These sections are used by IPA passes that need to emit summary
  156. information during LTO generation to be read and aggregated at
  157. link time. Each pass is responsible for implementing two pass manager
  158. hooks: one for writing the summary and another for reading it in. The
  159. format of these sections is entirely up to each individual pass. The
  160. only requirement is that the writer and reader hooks agree on the
  161. format.
  162. </p></li></ul>
  163. <hr>
  164. <div class="header">
  165. <p>
  166. Next: <a href="IPA.html#IPA" accesskey="n" rel="next">IPA</a>, Previous: <a href="LTO-Overview.html#LTO-Overview" accesskey="p" rel="prev">LTO Overview</a>, Up: <a href="LTO.html#LTO" accesskey="u" rel="up">LTO</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  167. </div>
  168. </body>
  169. </html>