include/ChangeLog
[deliverable/binutils-gdb.git] / gold / readsyms.h
CommitLineData
bae7f79e
ILT
1// readsyms.h -- read input file symbols for gold -*- C++ -*-
2
ebdbb458 3// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
6cb15b7f
ILT
4// Written by Ian Lance Taylor <iant@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
bae7f79e
ILT
23#ifndef GOLD_READSYMS_H
24#define GOLD_READSYMS_H
25
ead1e424
ILT
26#include <vector>
27
bae7f79e
ILT
28#include "workqueue.h"
29#include "object.h"
30
31namespace gold
32{
33
54dc6425
ILT
34class Input_objects;
35class Symbol_table;
ead1e424
ILT
36class Input_group;
37class Archive;
54dc6425 38
bae7f79e
ILT
39// This Task is responsible for reading the symbols from an input
40// file. This also includes reading the relocations so that we can
41// check for any that require a PLT and/or a GOT. After the data has
42// been read, this queues up another task to actually add the symbols
43// to the symbol table. The tasks are separated because the file
44// reading can occur in parallel but adding the symbols must be done
45// in the order of the input files.
46
47class Read_symbols : public Task
48{
49 public:
50 // DIRPATH is the list of directories to search for libraries.
ead1e424
ILT
51 // INPUT is the file to read. INPUT_GROUP is not NULL if we are in
52 // the middle of an input group. THIS_BLOCKER is used to prevent
53 // the associated Add_symbols task from running before the previous
54 // one has completed; it will be NULL for the first task.
55 // NEXT_BLOCKER is used to block the next input file from adding
56 // symbols.
f1ed28fb
ILT
57 Read_symbols(Input_objects* input_objects, Symbol_table* symtab,
58 Layout* layout, Dirsearch* dirpath, Mapfile* mapfile,
59 const Input_argument* input_argument,
7d9e3d98
ILT
60 Input_group* input_group, Task_token* this_blocker,
61 Task_token* next_blocker)
f1ed28fb
ILT
62 : input_objects_(input_objects), symtab_(symtab), layout_(layout),
63 dirpath_(dirpath), mapfile_(mapfile), input_argument_(input_argument),
64 input_group_(input_group), this_blocker_(this_blocker),
65 next_blocker_(next_blocker)
bae7f79e
ILT
66 { }
67
68 ~Read_symbols();
69
70 // The standard Task methods.
71
17a1d0a9
ILT
72 Task_token*
73 is_runnable();
bae7f79e 74
17a1d0a9
ILT
75 void
76 locks(Task_locker*);
bae7f79e
ILT
77
78 void
79 run(Workqueue*);
80
c7912668
ILT
81 std::string
82 get_name() const;
83
bae7f79e 84 private:
ead1e424
ILT
85 // Handle an archive group.
86 void
87 do_group(Workqueue*);
88
ee6d2efe
ILT
89 // Open and identify the file.
90 bool
91 do_read_symbols(Workqueue*);
92
54dc6425 93 Input_objects* input_objects_;
14bfc3f5 94 Symbol_table* symtab_;
12e14209 95 Layout* layout_;
17a1d0a9 96 Dirsearch* dirpath_;
7d9e3d98 97 Mapfile* mapfile_;
dbe717ef 98 const Input_argument* input_argument_;
ead1e424 99 Input_group* input_group_;
bae7f79e
ILT
100 Task_token* this_blocker_;
101 Task_token* next_blocker_;
102};
103
104// This Task handles adding the symbols to the symbol table. These
105// tasks must be run in the same order as the arguments appear on the
106// command line.
107
108class Add_symbols : public Task
109{
110 public:
111 // THIS_BLOCKER is used to prevent this task from running before the
112 // one for the previous input file. NEXT_BLOCKER is used to prevent
113 // the next task from running.
7e1edb90
ILT
114 Add_symbols(Input_objects* input_objects, Symbol_table* symtab,
115 Layout* layout, Object* object,
f6ce93d6
ILT
116 Read_symbols_data* sd, Task_token* this_blocker,
117 Task_token* next_blocker)
7e1edb90
ILT
118 : input_objects_(input_objects), symtab_(symtab), layout_(layout),
119 object_(object), sd_(sd), this_blocker_(this_blocker),
ead1e424 120 next_blocker_(next_blocker)
bae7f79e
ILT
121 { }
122
123 ~Add_symbols();
124
125 // The standard Task methods.
126
17a1d0a9
ILT
127 Task_token*
128 is_runnable();
bae7f79e 129
17a1d0a9
ILT
130 void
131 locks(Task_locker*);
bae7f79e
ILT
132
133 void
134 run(Workqueue*);
135
c7912668
ILT
136 std::string
137 get_name() const
138 { return "Add_symbols " + this->object_->name(); }
139
bae7f79e 140private:
ead1e424 141 Input_objects* input_objects_;
14bfc3f5 142 Symbol_table* symtab_;
12e14209 143 Layout* layout_;
bae7f79e 144 Object* object_;
12e14209 145 Read_symbols_data* sd_;
bae7f79e
ILT
146 Task_token* this_blocker_;
147 Task_token* next_blocker_;
148};
149
ead1e424
ILT
150// This class is used to track the archives in a group.
151
152class Input_group
153{
154 public:
155 typedef std::vector<Archive*> Archives;
156 typedef Archives::const_iterator const_iterator;
157
158 Input_group()
159 : archives_()
160 { }
161
162 // Add an archive to the group.
163 void
164 add_archive(Archive* arch)
165 { this->archives_.push_back(arch); }
166
167 // Loop over the archives in the group.
168
169 const_iterator
170 begin() const
171 { return this->archives_.begin(); }
172
173 const_iterator
174 end() const
175 { return this->archives_.end(); }
176
177 private:
178 Archives archives_;
179};
180
181// This class is used to finish up handling a group. It is just a
182// closure.
183
184class Finish_group : public Task
185{
186 public:
7e1edb90 187 Finish_group(Input_objects* input_objects, Symbol_table* symtab,
7d9e3d98 188 Layout* layout, Mapfile* mapfile, Input_group* input_group,
ead1e424
ILT
189 int saw_undefined, Task_token* this_blocker,
190 Task_token* next_blocker)
7e1edb90 191 : input_objects_(input_objects), symtab_(symtab),
7d9e3d98 192 layout_(layout), mapfile_(mapfile), input_group_(input_group),
f6ce93d6
ILT
193 saw_undefined_(saw_undefined), this_blocker_(this_blocker),
194 next_blocker_(next_blocker)
ead1e424
ILT
195 { }
196
197 ~Finish_group();
198
199 // The standard Task methods.
200
17a1d0a9
ILT
201 Task_token*
202 is_runnable();
ead1e424 203
17a1d0a9
ILT
204 void
205 locks(Task_locker*);
ead1e424
ILT
206
207 void
208 run(Workqueue*);
209
c7912668
ILT
210 std::string
211 get_name() const
212 { return "Finish_group"; }
213
ead1e424
ILT
214 private:
215 Input_objects* input_objects_;
216 Symbol_table* symtab_;
217 Layout* layout_;
7d9e3d98 218 Mapfile* mapfile_;
ead1e424
ILT
219 Input_group* input_group_;
220 int saw_undefined_;
221 Task_token* this_blocker_;
222 Task_token* next_blocker_;
223};
224
da769d56
ILT
225// This class is used to read a file which was not recognized as an
226// object or archive. It tries to read it as a linker script, using
227// the tokens to serialize with the calls to Add_symbols.
228
229class Read_script : public Task
230{
231 public:
f1ed28fb
ILT
232 Read_script(Symbol_table* symtab, Layout* layout, Dirsearch* dirpath,
233 Input_objects* input_objects, Mapfile* mapfile,
234 Input_group* input_group, const Input_argument* input_argument,
da769d56
ILT
235 Input_file* input_file, Task_token* this_blocker,
236 Task_token* next_blocker)
f1ed28fb 237 : symtab_(symtab), layout_(layout), dirpath_(dirpath),
7d9e3d98
ILT
238 input_objects_(input_objects), mapfile_(mapfile),
239 input_group_(input_group), input_argument_(input_argument),
240 input_file_(input_file), this_blocker_(this_blocker),
241 next_blocker_(next_blocker)
da769d56
ILT
242 { }
243
244 ~Read_script();
245
246 // The standard Task methods.
247
248 Task_token*
249 is_runnable();
250
251 void
252 locks(Task_locker*);
253
254 void
255 run(Workqueue*);
256
257 std::string
258 get_name() const;
259
260 private:
da769d56
ILT
261 Symbol_table* symtab_;
262 Layout* layout_;
263 Dirsearch* dirpath_;
264 Input_objects* input_objects_;
7d9e3d98 265 Mapfile* mapfile_;
da769d56
ILT
266 Input_group* input_group_;
267 const Input_argument* input_argument_;
268 Input_file* input_file_;
269 Task_token* this_blocker_;
270 Task_token* next_blocker_;
271};
272
bae7f79e
ILT
273} // end namespace gold
274
275#endif // !defined(GOLD_READSYMS_H)
This page took 0.131508 seconds and 4 git commands to generate.