<gas changes>
[deliverable/binutils-gdb.git] / gold / incremental.h
CommitLineData
3ce2c28e
ILT
1// inremental.h -- incremental linking support for gold -*- C++ -*-
2
3// Copyright 2009 Free Software Foundation, Inc.
4// Written by Mikolaj Zalewski <mikolajz@google.com>.
5
6// This file is part of gold.
7
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.
12
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.
17
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.
22
23#ifndef GOLD_INCREMENTAL_H
24#define GOLD_INCREMENTAL_H
25
072fe7ce 26#include <map>
3ce2c28e
ILT
27#include <vector>
28
29#include "stringpool.h"
30#include "workqueue.h"
31
32namespace gold
33{
34
35class Archive;
36class Input_argument;
37class Incremental_inputs_checker;
38class Object;
39class Output_section_data;
40
072fe7ce
ILT
41// Incremental input type as stored in .gnu_incremental_inputs.
42
43enum Incremental_input_type
44{
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
50};
51
3ce2c28e
ILT
52// This class contains the information needed during an incremental
53// build about the inputs necessary to build the .gnu_incremental_inputs.
54class Incremental_inputs
55{
56 public:
57 Incremental_inputs()
072fe7ce
ILT
58 : lock_(new Lock()), inputs_(NULL), command_line_key_(0),
59 strtab_(new Stringpool())
3ce2c28e
ILT
60 { }
61 ~Incremental_inputs() { delete this->strtab_; }
62
63 // Record the command line.
64 void
65 report_command_line(int argc, const char* const* argv);
072fe7ce
ILT
66
67 // Record the input arguments obtained from parsing the command line.
68 void
69 report_inputs(const Input_arguments& inputs)
70 { this->inputs_ = &inputs; }
71
72 // Record that the input argument INPUT is an archive ARCHIVE.
73 void
74 report_archive(const Input_argument* input, Archive* archive);
75
76 // Record that the input argument INPUT is to an object OBJ.
77 void
78 report_object(const Input_argument* input, Object* obj);
79
80 // Record that the input argument INPUT is to an script SCRIPT.
81 void
82 report_script(const Input_argument* input, Script_info* script);
83
3ce2c28e
ILT
84 // Prepare for layout. Called from Layout::finalize.
85 void
86 finalize();
87
88 // Create the content of the .gnu_incremental_inputs section.
89 Output_section_data*
90 create_incremental_inputs_section_data();
072fe7ce
ILT
91
92 // Return the .gnu_incremental_strtab stringpool.
3ce2c28e
ILT
93 Stringpool*
94 get_stringpool()
95 { return this->strtab_; }
96
97 private:
98 // Code for each of the four possible variants of create_inputs_section_data.
99 template<int size, bool big_endian>
100 Output_section_data*
072fe7ce
ILT
101 sized_create_inputs_section_data();
102
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.
106
107 void
108 finalize_inputs(Input_argument_list::const_iterator begin,
109 Input_argument_list::const_iterator end,
110 unsigned int* index);
111
112 // Additional data about an input needed for an incremental link.
113 // None of these pointers is owned by the structure.
114 struct Input_info
115 {
116 Input_info()
117 : type(INCREMENTAL_INPUT_INVALID), archive(NULL), object(NULL),
118 script(NULL), filename_key(0), index(0)
119 { }
120
121 // Type of the file pointed by this argument.
122 Incremental_input_type type;
123
124 // Present if type == INCREMENTAL_INPUT_ARCHIVE.
125 Archive* archive;
126
127 // Present if type == INCREMENTAL_INPUT_OBJECT or
128 // INCREMENTAL_INPUT_SHARED_LIBRARY.
129 Object* object;
130
131 // Present if type == INCREMENTAL_INPUT_SCRIPT.
132 Script_info* script;
133
134 // Key of the filename string in the section stringtable.
135 Stringpool::Key filename_key;
136
137 // Position of the entry information in the output section.
138 unsigned int index;
139 };
140
141 typedef std::map<const Input_argument*, Input_info> Inputs_info_map;
142
143 // A lock guarding access to inputs_ during the first phase of linking, when
144 // report_ function may be called from multiple threads.
145 Lock* lock_;
146
147 // The list of input arguments obtained from parsing the command line.
148 const Input_arguments* inputs_;
149
150 // A map containing additional information about the input elements.
151 Inputs_info_map inputs_map_;
3ce2c28e
ILT
152
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.
157 Stringpool* strtab_;
158};
159
160} // End namespace gold.
161
162#endif // !defined(GOLD_INCREMENTAL_H)
This page took 0.038578 seconds and 4 git commands to generate.