bfd/
[binutils.git] / gold / readsyms.h
blobd5ada61d25ed834aff40428f1ab2f2de14e12648
1 // readsyms.h -- read input file symbols for gold -*- C++ -*-
3 #ifndef GOLD_READSYMS_H
4 #define GOLD_READSYMS_H
6 #include <vector>
8 #include "workqueue.h"
9 #include "object.h"
11 namespace gold
14 class Input_objects;
15 class Symbol_table;
16 class Input_group;
17 class Archive;
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.
27 class Read_symbols : public Task
29 public:
30 // DIRPATH is the list of directories to search for libraries.
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.
37 Read_symbols(const General_options& options, Input_objects* input_objects,
38 Symbol_table* symtab, Layout* layout, const Dirsearch& dirpath,
39 const Input_argument* input_argument, Input_group* input_group,
40 Task_token* this_blocker, Task_token* next_blocker)
41 : options_(options), input_objects_(input_objects), symtab_(symtab),
42 layout_(layout), dirpath_(dirpath), input_argument_(input_argument),
43 input_group_(input_group), this_blocker_(this_blocker),
44 next_blocker_(next_blocker)
45 { }
47 ~Read_symbols();
49 // The standard Task methods.
51 Is_runnable_type
52 is_runnable(Workqueue*);
54 Task_locker*
55 locks(Workqueue*);
57 void
58 run(Workqueue*);
60 private:
61 // Handle an archive group.
62 void
63 do_group(Workqueue*);
65 const General_options& options_;
66 Input_objects* input_objects_;
67 Symbol_table* symtab_;
68 Layout* layout_;
69 const Dirsearch& dirpath_;
70 const Input_argument* input_argument_;
71 Input_group* input_group_;
72 Task_token* this_blocker_;
73 Task_token* next_blocker_;
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.
80 class Add_symbols : public Task
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.
86 Add_symbols(const General_options& options, Input_objects* input_objects,
87 Symbol_table* symtab, Layout* layout, Object* object,
88 Read_symbols_data* sd, Task_token* this_blocker,
89 Task_token* next_blocker)
90 : options_(options), input_objects_(input_objects), symtab_(symtab),
91 layout_(layout), object_(object), sd_(sd), this_blocker_(this_blocker),
92 next_blocker_(next_blocker)
93 { }
95 ~Add_symbols();
97 // The standard Task methods.
99 Is_runnable_type
100 is_runnable(Workqueue*);
102 Task_locker*
103 locks(Workqueue*);
105 void
106 run(Workqueue*);
108 private:
109 class Add_symbols_locker;
111 const General_options& options_;
112 Input_objects* input_objects_;
113 Symbol_table* symtab_;
114 Layout* layout_;
115 Object* object_;
116 Read_symbols_data* sd_;
117 Task_token* this_blocker_;
118 Task_token* next_blocker_;
121 // This class is used to track the archives in a group.
123 class Input_group
125 public:
126 typedef std::vector<Archive*> Archives;
127 typedef Archives::const_iterator const_iterator;
129 Input_group()
130 : archives_()
133 // Add an archive to the group.
134 void
135 add_archive(Archive* arch)
136 { this->archives_.push_back(arch); }
138 // Loop over the archives in the group.
140 const_iterator
141 begin() const
142 { return this->archives_.begin(); }
144 const_iterator
145 end() const
146 { return this->archives_.end(); }
148 private:
149 Archives archives_;
152 // This class is used to finish up handling a group. It is just a
153 // closure.
155 class Finish_group : public Task
157 public:
158 Finish_group(const General_options& options, Input_objects* input_objects,
159 Symbol_table* symtab, Layout* layout, Input_group* input_group,
160 int saw_undefined, Task_token* this_blocker,
161 Task_token* next_blocker)
162 : options_(options), input_objects_(input_objects), symtab_(symtab),
163 layout_(layout), input_group_(input_group),
164 saw_undefined_(saw_undefined), this_blocker_(this_blocker),
165 next_blocker_(next_blocker)
168 ~Finish_group();
170 // The standard Task methods.
172 Is_runnable_type
173 is_runnable(Workqueue*);
175 Task_locker*
176 locks(Workqueue*);
178 void
179 run(Workqueue*);
181 private:
182 const General_options& options_;
183 Input_objects* input_objects_;
184 Symbol_table* symtab_;
185 Layout* layout_;
186 Input_group* input_group_;
187 int saw_undefined_;
188 Task_token* this_blocker_;
189 Task_token* next_blocker_;
192 } // end namespace gold
194 #endif // !defined(GOLD_READSYMS_H)