1 // inremental.h -- incremental linking support for gold -*- C++ -*-
3 // Copyright 2009 Free Software Foundation, Inc.
4 // Written by Mikolaj Zalewski <mikolajz@google.com>.
6 // This file is part of gold.
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 3 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 // MA 02110-1301, USA.
23 #ifndef GOLD_INCREMENTAL_H
24 #define GOLD_INCREMENTAL_H
29 #include "stringpool.h"
30 #include "workqueue.h"
37 class Incremental_inputs_checker
;
39 class Output_section_data
;
41 // Incremental input type as stored in .gnu_incremental_inputs.
43 enum Incremental_input_type
45 INCREMENTAL_INPUT_INVALID
= 0,
46 INCREMENTAL_INPUT_OBJECT
= 1,
47 INCREMENTAL_INPUT_ARCHIVE
= 2,
48 INCREMENTAL_INPUT_SHARED_LIBRARY
= 3,
49 INCREMENTAL_INPUT_SCRIPT
= 4
52 // This class contains the information needed during an incremental
53 // build about the inputs necessary to build the .gnu_incremental_inputs.
54 class Incremental_inputs
58 : lock_(new Lock()), inputs_(NULL
), command_line_key_(0),
59 strtab_(new Stringpool())
61 ~Incremental_inputs() { delete this->strtab_
; }
63 // Record the command line.
65 report_command_line(int argc
, const char* const* argv
);
67 // Record the input arguments obtained from parsing the command line.
69 report_inputs(const Input_arguments
& inputs
)
70 { this->inputs_
= &inputs
; }
72 // Record that the input argument INPUT is an archive ARCHIVE.
74 report_archive(const Input_argument
* input
, Archive
* archive
);
76 // Record that the input argument INPUT is to an object OBJ.
78 report_object(const Input_argument
* input
, Object
* obj
);
80 // Record that the input argument INPUT is to an script SCRIPT.
82 report_script(const Input_argument
* input
, Script_info
* script
);
84 // Prepare for layout. Called from Layout::finalize.
88 // Create the content of the .gnu_incremental_inputs section.
90 create_incremental_inputs_section_data();
92 // Return the .gnu_incremental_strtab stringpool.
95 { return this->strtab_
; }
98 // Code for each of the four possible variants of create_inputs_section_data.
99 template<int size
, bool big_endian
>
101 sized_create_inputs_section_data();
103 // Compute indexes in the order in which the inputs should appear in
104 // .gnu_incremental_inputs and put file names to the stringtable.
105 // This needs to be done after all the scripts are parsed.
108 finalize_inputs(Input_argument_list::const_iterator begin
,
109 Input_argument_list::const_iterator end
,
110 unsigned int* index
);
112 // Additional data about an input needed for an incremental link.
113 // None of these pointers is owned by the structure.
117 : type(INCREMENTAL_INPUT_INVALID
), archive(NULL
), object(NULL
),
118 script(NULL
), filename_key(0), index(0)
121 // Type of the file pointed by this argument.
122 Incremental_input_type type
;
124 // Present if type == INCREMENTAL_INPUT_ARCHIVE.
127 // Present if type == INCREMENTAL_INPUT_OBJECT or
128 // INCREMENTAL_INPUT_SHARED_LIBRARY.
131 // Present if type == INCREMENTAL_INPUT_SCRIPT.
134 // Key of the filename string in the section stringtable.
135 Stringpool::Key filename_key
;
137 // Position of the entry information in the output section.
141 typedef std::map
<const Input_argument
*, Input_info
> Inputs_info_map
;
143 // A lock guarding access to inputs_ during the first phase of linking, when
144 // report_ function may be called from multiple threads.
147 // The list of input arguments obtained from parsing the command line.
148 const Input_arguments
* inputs_
;
150 // A map containing additional information about the input elements.
151 Inputs_info_map inputs_map_
;
153 // The key of the command line string in the string pool.
154 Stringpool::Key command_line_key_
;
155 // The .gnu_incremental_strtab string pool associated with the
156 // .gnu_incremental_inputs.
160 } // End namespace gold.
162 #endif // !defined(GOLD_INCREMENTAL_H)