You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
162 lines
7.4 KiB
HTML
162 lines
7.4 KiB
HTML
<html lang="en">
|
|
<head>
|
|
<title>LTO object file layout - GNU Compiler Collection (GCC) Internals</title>
|
|
<meta http-equiv="Content-Type" content="text/html">
|
|
<meta name="description" content="GNU Compiler Collection (GCC) Internals">
|
|
<meta name="generator" content="makeinfo 4.13">
|
|
<link title="Top" rel="start" href="index.html#Top">
|
|
<link rel="up" href="LTO.html#LTO" title="LTO">
|
|
<link rel="prev" href="LTO-Overview.html#LTO-Overview" title="LTO Overview">
|
|
<link rel="next" href="IPA.html#IPA" title="IPA">
|
|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
|
|
<!--
|
|
Copyright (C) 1988-2015 Free Software Foundation, Inc.
|
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
|
any later version published by the Free Software Foundation; with the
|
|
Invariant Sections being ``Funding Free Software'', the Front-Cover
|
|
Texts being (a) (see below), and with the Back-Cover Texts being (b)
|
|
(see below). A copy of the license is included in the section entitled
|
|
``GNU Free Documentation License''.
|
|
|
|
(a) The FSF's Front-Cover Text is:
|
|
|
|
A GNU Manual
|
|
|
|
(b) The FSF's Back-Cover Text is:
|
|
|
|
You have freedom to copy and modify this GNU Manual, like GNU
|
|
software. Copies published by the Free Software Foundation raise
|
|
funds for GNU development.-->
|
|
<meta http-equiv="Content-Style-Type" content="text/css">
|
|
<style type="text/css"><!--
|
|
pre.display { font-family:inherit }
|
|
pre.format { font-family:inherit }
|
|
pre.smalldisplay { font-family:inherit; font-size:smaller }
|
|
pre.smallformat { font-family:inherit; font-size:smaller }
|
|
pre.smallexample { font-size:smaller }
|
|
pre.smalllisp { font-size:smaller }
|
|
span.sc { font-variant:small-caps }
|
|
span.roman { font-family:serif; font-weight:normal; }
|
|
span.sansserif { font-family:sans-serif; font-weight:normal; }
|
|
--></style>
|
|
</head>
|
|
<body>
|
|
<div class="node">
|
|
<a name="LTO-object-file-layout"></a>
|
|
<p>
|
|
Next: <a rel="next" accesskey="n" href="IPA.html#IPA">IPA</a>,
|
|
Previous: <a rel="previous" accesskey="p" href="LTO-Overview.html#LTO-Overview">LTO Overview</a>,
|
|
Up: <a rel="up" accesskey="u" href="LTO.html#LTO">LTO</a>
|
|
<hr>
|
|
</div>
|
|
|
|
<h3 class="section">24.2 LTO file sections</h3>
|
|
|
|
<p>LTO information is stored in several ELF sections inside object files.
|
|
Data structures and enum codes for sections are defined in
|
|
<samp><span class="file">lto-streamer.h</span></samp>.
|
|
|
|
<p>These sections are emitted from <samp><span class="file">lto-streamer-out.c</span></samp> and mapped
|
|
in all at once from <samp><span class="file">lto/lto.c</span></samp>:<code>lto_file_read</code>. The
|
|
individual functions dealing with the reading/writing of each section
|
|
are described below.
|
|
|
|
<ul>
|
|
<li>Command line options (<code>.gnu.lto_.opts</code>)
|
|
|
|
<p>This section contains the command line options used to generate the
|
|
object files. This is used at link time to determine the optimization
|
|
level and other settings when they are not explicitly specified at the
|
|
linker command line.
|
|
|
|
<p>Currently, GCC does not support combining LTO object files compiled
|
|
with different set of the command line options into a single binary.
|
|
At link time, the options given on the command line and the options
|
|
saved on all the files in a link-time set are applied globally. No
|
|
attempt is made at validating the combination of flags (other than the
|
|
usual validation done by option processing). This is implemented in
|
|
<samp><span class="file">lto/lto.c</span></samp>:<code>lto_read_all_file_options</code>.
|
|
|
|
<li>Symbol table (<code>.gnu.lto_.symtab</code>)
|
|
|
|
<p>This table replaces the ELF symbol table for functions and variables
|
|
represented in the LTO IL. Symbols used and exported by the optimized
|
|
assembly code of “fat” objects might not match the ones used and
|
|
exported by the intermediate code. This table is necessary because
|
|
the intermediate code is less optimized and thus requires a separate
|
|
symbol table.
|
|
|
|
<p>Additionally, the binary code in the “fat” object will lack a call
|
|
to a function, since the call was optimized out at compilation time
|
|
after the intermediate language was streamed out. In some special
|
|
cases, the same optimization may not happen during link-time
|
|
optimization. This would lead to an undefined symbol if only one
|
|
symbol table was used.
|
|
|
|
<p>The symbol table is emitted in
|
|
<samp><span class="file">lto-streamer-out.c</span></samp>:<code>produce_symtab</code>.
|
|
|
|
<li>Global declarations and types (<code>.gnu.lto_.decls</code>)
|
|
|
|
<p>This section contains an intermediate language dump of all
|
|
declarations and types required to represent the callgraph, static
|
|
variables and top-level debug info.
|
|
|
|
<p>The contents of this section are emitted in
|
|
<samp><span class="file">lto-streamer-out.c</span></samp>:<code>produce_asm_for_decls</code>. Types and
|
|
symbols are emitted in a topological order that preserves the sharing
|
|
of pointers when the file is read back in
|
|
(<samp><span class="file">lto.c</span></samp>:<code>read_cgraph_and_symbols</code>).
|
|
|
|
<li>The callgraph (<code>.gnu.lto_.cgraph</code>)
|
|
|
|
<p>This section contains the basic data structure used by the GCC
|
|
inter-procedural optimization infrastructure. This section stores an
|
|
annotated multi-graph which represents the functions and call sites as
|
|
well as the variables, aliases and top-level <code>asm</code> statements.
|
|
|
|
<p>This section is emitted in
|
|
<samp><span class="file">lto-streamer-out.c</span></samp>:<code>output_cgraph</code> and read in
|
|
<samp><span class="file">lto-cgraph.c</span></samp>:<code>input_cgraph</code>.
|
|
|
|
<li>IPA references (<code>.gnu.lto_.refs</code>)
|
|
|
|
<p>This section contains references between function and static
|
|
variables. It is emitted by <samp><span class="file">lto-cgraph.c</span></samp>:<code>output_refs</code>
|
|
and read by <samp><span class="file">lto-cgraph.c</span></samp>:<code>input_refs</code>.
|
|
|
|
<li>Function bodies (<code>.gnu.lto_.function_body.<name></code>)
|
|
|
|
<p>This section contains function bodies in the intermediate language
|
|
representation. Every function body is in a separate section to allow
|
|
copying of the section independently to different object files or
|
|
reading the function on demand.
|
|
|
|
<p>Functions are emitted in
|
|
<samp><span class="file">lto-streamer-out.c</span></samp>:<code>output_function</code> and read in
|
|
<samp><span class="file">lto-streamer-in.c</span></samp>:<code>input_function</code>.
|
|
|
|
<li>Static variable initializers (<code>.gnu.lto_.vars</code>)
|
|
|
|
<p>This section contains all the symbols in the global variable pool. It
|
|
is emitted by <samp><span class="file">lto-cgraph.c</span></samp>:<code>output_varpool</code> and read in
|
|
<samp><span class="file">lto-cgraph.c</span></samp>:<code>input_cgraph</code>.
|
|
|
|
<li>Summaries and optimization summaries used by IPA passes
|
|
(<code>.gnu.lto_.<xxx></code>, where <code><xxx></code> is one of <code>jmpfuncs</code>,
|
|
<code>pureconst</code> or <code>reference</code>)
|
|
|
|
<p>These sections are used by IPA passes that need to emit summary
|
|
information during LTO generation to be read and aggregated at
|
|
link time. Each pass is responsible for implementing two pass manager
|
|
hooks: one for writing the summary and another for reading it in. The
|
|
format of these sections is entirely up to each individual pass. The
|
|
only requirement is that the writer and reader hooks agree on the
|
|
format.
|
|
</ul>
|
|
|
|
</body></html>
|
|
|