Rework swapping code.
[deliverable/binutils-gdb.git] / gold / readsyms.h
CommitLineData
bae7f79e
ILT
1// readsyms.h -- read input file symbols for gold -*- C++ -*-
2
3#ifndef GOLD_READSYMS_H
4#define GOLD_READSYMS_H
5
ead1e424
ILT
6#include <vector>
7
bae7f79e
ILT
8#include "workqueue.h"
9#include "object.h"
10
11namespace gold
12{
13
54dc6425
ILT
14class Input_objects;
15class Symbol_table;
ead1e424
ILT
16class Input_group;
17class Archive;
54dc6425 18
bae7f79e
ILT
19// This Task is responsible for reading the symbols from an input
20// file. This also includes reading the relocations so that we can
21// check for any that require a PLT and/or a GOT. After the data has
22// been read, this queues up another task to actually add the symbols
23// to the symbol table. The tasks are separated because the file
24// reading can occur in parallel but adding the symbols must be done
25// in the order of the input files.
26
27class Read_symbols : public Task
28{
29 public:
30 // DIRPATH is the list of directories to search for libraries.
ead1e424
ILT
31 // INPUT is the file to read. INPUT_GROUP is not NULL if we are in
32 // the middle of an input group. THIS_BLOCKER is used to prevent
33 // the associated Add_symbols task from running before the previous
34 // one has completed; it will be NULL for the first task.
35 // NEXT_BLOCKER is used to block the next input file from adding
36 // symbols.
54dc6425 37 Read_symbols(const General_options& options, Input_objects* input_objects,
12e14209 38 Symbol_table* symtab, Layout* layout, const Dirsearch& dirpath,
ead1e424 39 const Input_argument& input, Input_group* input_group,
14bfc3f5 40 Task_token* this_blocker, Task_token* next_blocker)
a2fb1b05 41 : options_(options), input_objects_(input_objects), symtab_(symtab),
12e14209 42 layout_(layout), dirpath_(dirpath), input_(input),
ead1e424
ILT
43 input_group_(input_group), this_blocker_(this_blocker),
44 next_blocker_(next_blocker)
bae7f79e
ILT
45 { }
46
47 ~Read_symbols();
48
49 // The standard Task methods.
50
51 Is_runnable_type
52 is_runnable(Workqueue*);
53
54 Task_locker*
55 locks(Workqueue*);
56
57 void
58 run(Workqueue*);
59
60 private:
ead1e424
ILT
61 // Handle an archive group.
62 void
63 do_group(Workqueue*);
64
bae7f79e 65 const General_options& options_;
54dc6425 66 Input_objects* input_objects_;
14bfc3f5 67 Symbol_table* symtab_;
12e14209 68 Layout* layout_;
bae7f79e
ILT
69 const Dirsearch& dirpath_;
70 const Input_argument& input_;
ead1e424 71 Input_group* input_group_;
bae7f79e
ILT
72 Task_token* this_blocker_;
73 Task_token* next_blocker_;
74};
75
76// This Task handles adding the symbols to the symbol table. These
77// tasks must be run in the same order as the arguments appear on the
78// command line.
79
80class Add_symbols : public Task
81{
82 public:
83 // THIS_BLOCKER is used to prevent this task from running before the
84 // one for the previous input file. NEXT_BLOCKER is used to prevent
85 // the next task from running.
ead1e424
ILT
86 Add_symbols(Input_objects* input_objects, Symbol_table* symtab,
87 Layout* layout, Object* object, Read_symbols_data* sd,
88 Task_token* this_blocker, Task_token* next_blocker)
89 : input_objects_(input_objects), symtab_(symtab), layout_(layout),
90 object_(object), sd_(sd), this_blocker_(this_blocker),
91 next_blocker_(next_blocker)
bae7f79e
ILT
92 { }
93
94 ~Add_symbols();
95
96 // The standard Task methods.
97
98 Is_runnable_type
99 is_runnable(Workqueue*);
100
101 Task_locker*
102 locks(Workqueue*);
103
104 void
105 run(Workqueue*);
106
107private:
a2fb1b05
ILT
108 class Add_symbols_locker;
109
ead1e424 110 Input_objects* input_objects_;
14bfc3f5 111 Symbol_table* symtab_;
12e14209 112 Layout* layout_;
bae7f79e 113 Object* object_;
12e14209 114 Read_symbols_data* sd_;
bae7f79e
ILT
115 Task_token* this_blocker_;
116 Task_token* next_blocker_;
117};
118
ead1e424
ILT
119// This class is used to track the archives in a group.
120
121class Input_group
122{
123 public:
124 typedef std::vector<Archive*> Archives;
125 typedef Archives::const_iterator const_iterator;
126
127 Input_group()
128 : archives_()
129 { }
130
131 // Add an archive to the group.
132 void
133 add_archive(Archive* arch)
134 { this->archives_.push_back(arch); }
135
136 // Loop over the archives in the group.
137
138 const_iterator
139 begin() const
140 { return this->archives_.begin(); }
141
142 const_iterator
143 end() const
144 { return this->archives_.end(); }
145
146 private:
147 Archives archives_;
148};
149
150// This class is used to finish up handling a group. It is just a
151// closure.
152
153class Finish_group : public Task
154{
155 public:
156 Finish_group(Input_objects* input_objects, Symbol_table* symtab,
157 Layout* layout, Input_group* input_group,
158 int saw_undefined, Task_token* this_blocker,
159 Task_token* next_blocker)
160 : input_objects_(input_objects), symtab_(symtab), layout_(layout),
161 input_group_(input_group), saw_undefined_(saw_undefined),
162 this_blocker_(this_blocker), next_blocker_(next_blocker)
163 { }
164
165 ~Finish_group();
166
167 // The standard Task methods.
168
169 Is_runnable_type
170 is_runnable(Workqueue*);
171
172 Task_locker*
173 locks(Workqueue*);
174
175 void
176 run(Workqueue*);
177
178 private:
179 Input_objects* input_objects_;
180 Symbol_table* symtab_;
181 Layout* layout_;
182 Input_group* input_group_;
183 int saw_undefined_;
184 Task_token* this_blocker_;
185 Task_token* next_blocker_;
186};
187
bae7f79e
ILT
188} // end namespace gold
189
190#endif // !defined(GOLD_READSYMS_H)
This page took 0.036449 seconds and 4 git commands to generate.