Commit | Line | Data |
---|---|---|
6d03d481 | 1 | // plugin.cc -- plugin manager for gold -*- C++ -*- |
89fc3421 | 2 | |
dde3f402 | 3 | // Copyright 2008, 2009, 2010 Free Software Foundation, Inc. |
89fc3421 CC |
4 | // Written by Cary Coutant <ccoutant@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 | ||
1c7814ed ILT |
23 | #include "gold.h" |
24 | ||
89fc3421 CC |
25 | #include <cstdio> |
26 | #include <cstdarg> | |
27 | #include <cstring> | |
28 | #include <string> | |
29 | #include <vector> | |
bc06c745 ILT |
30 | |
31 | #ifdef ENABLE_PLUGINS | |
89fc3421 | 32 | #include <dlfcn.h> |
bc06c745 | 33 | #endif |
89fc3421 | 34 | |
89fc3421 CC |
35 | #include "parameters.h" |
36 | #include "errors.h" | |
37 | #include "fileread.h" | |
38 | #include "layout.h" | |
39 | #include "options.h" | |
40 | #include "plugin.h" | |
41 | #include "target.h" | |
42 | #include "readsyms.h" | |
43 | #include "symtab.h" | |
44 | #include "elfcpp.h" | |
45 | ||
46 | namespace gold | |
47 | { | |
48 | ||
49 | #ifdef ENABLE_PLUGINS | |
50 | ||
51 | // The linker's exported interfaces. | |
52 | ||
53 | extern "C" | |
54 | { | |
55 | ||
56 | static enum ld_plugin_status | |
57 | register_claim_file(ld_plugin_claim_file_handler handler); | |
58 | ||
59 | static enum ld_plugin_status | |
60 | register_all_symbols_read(ld_plugin_all_symbols_read_handler handler); | |
61 | ||
62 | static enum ld_plugin_status | |
63 | register_cleanup(ld_plugin_cleanup_handler handler); | |
64 | ||
65 | static enum ld_plugin_status | |
66 | add_symbols(void *handle, int nsyms, const struct ld_plugin_symbol *syms); | |
67 | ||
0f7c0701 CC |
68 | static enum ld_plugin_status |
69 | get_input_file(const void *handle, struct ld_plugin_input_file *file); | |
70 | ||
71 | static enum ld_plugin_status | |
72 | release_input_file(const void *handle); | |
73 | ||
89fc3421 CC |
74 | static enum ld_plugin_status |
75 | get_symbols(const void *handle, int nsyms, struct ld_plugin_symbol *syms); | |
76 | ||
77 | static enum ld_plugin_status | |
6508b958 | 78 | add_input_file(const char *pathname); |
89fc3421 | 79 | |
e99daf92 | 80 | static enum ld_plugin_status |
6508b958 | 81 | add_input_library(const char *pathname); |
e99daf92 | 82 | |
42218b9f RÁE |
83 | static enum ld_plugin_status |
84 | set_extra_library_path(const char *path); | |
85 | ||
89fc3421 | 86 | static enum ld_plugin_status |
6c52134c | 87 | message(int level, const char *format, ...); |
89fc3421 CC |
88 | |
89 | }; | |
90 | ||
91 | #endif // ENABLE_PLUGINS | |
92 | ||
93 | static Pluginobj* make_sized_plugin_object(Input_file* input_file, | |
0f7c0701 | 94 | off_t offset, off_t filesize); |
89fc3421 CC |
95 | |
96 | // Plugin methods. | |
97 | ||
98 | // Load one plugin library. | |
99 | ||
100 | void | |
101 | Plugin::load() | |
102 | { | |
103 | #ifdef ENABLE_PLUGINS | |
89fc3421 CC |
104 | // Load the plugin library. |
105 | // FIXME: Look for the library in standard locations. | |
4674ecfc | 106 | this->handle_ = dlopen(this->filename_.c_str(), RTLD_NOW); |
89fc3421 CC |
107 | if (this->handle_ == NULL) |
108 | { | |
4802450a RÁE |
109 | gold_error(_("%s: could not load plugin library: %s"), |
110 | this->filename_.c_str(), dlerror()); | |
89fc3421 CC |
111 | return; |
112 | } | |
113 | ||
114 | // Find the plugin's onload entry point. | |
b59befec ILT |
115 | void* ptr = dlsym(this->handle_, "onload"); |
116 | if (ptr == NULL) | |
89fc3421 | 117 | { |
4674ecfc CC |
118 | gold_error(_("%s: could not find onload entry point"), |
119 | this->filename_.c_str()); | |
89fc3421 CC |
120 | return; |
121 | } | |
b59befec ILT |
122 | ld_plugin_onload onload; |
123 | gold_assert(sizeof(onload) == sizeof(ptr)); | |
124 | memcpy(&onload, &ptr, sizeof(ptr)); | |
89fc3421 CC |
125 | |
126 | // Get the linker's version number. | |
127 | const char* ver = get_version_string(); | |
128 | int major = 0; | |
129 | int minor = 0; | |
130 | sscanf(ver, "%d.%d", &major, &minor); | |
131 | ||
132 | // Allocate and populate a transfer vector. | |
42218b9f | 133 | const int tv_fixed_size = 16; |
4674ecfc | 134 | int tv_size = this->args_.size() + tv_fixed_size; |
ca09d69a | 135 | ld_plugin_tv* tv = new ld_plugin_tv[tv_size]; |
89fc3421 | 136 | |
abc8dcba CC |
137 | // Put LDPT_MESSAGE at the front of the list so the plugin can use it |
138 | // while processing subsequent entries. | |
89fc3421 | 139 | int i = 0; |
abc8dcba CC |
140 | tv[i].tv_tag = LDPT_MESSAGE; |
141 | tv[i].tv_u.tv_message = message; | |
142 | ||
143 | ++i; | |
89fc3421 CC |
144 | tv[i].tv_tag = LDPT_API_VERSION; |
145 | tv[i].tv_u.tv_val = LD_PLUGIN_API_VERSION; | |
146 | ||
147 | ++i; | |
148 | tv[i].tv_tag = LDPT_GOLD_VERSION; | |
149 | tv[i].tv_u.tv_val = major * 100 + minor; | |
150 | ||
151 | ++i; | |
152 | tv[i].tv_tag = LDPT_LINKER_OUTPUT; | |
153 | if (parameters->options().relocatable()) | |
154 | tv[i].tv_u.tv_val = LDPO_REL; | |
155 | else if (parameters->options().shared()) | |
156 | tv[i].tv_u.tv_val = LDPO_DYN; | |
157 | else | |
158 | tv[i].tv_u.tv_val = LDPO_EXEC; | |
159 | ||
3537c84b RÁE |
160 | ++i; |
161 | tv[i].tv_tag = LDPT_OUTPUT_NAME; | |
162 | tv[i].tv_u.tv_string = parameters->options().output(); | |
163 | ||
4674ecfc | 164 | for (unsigned int j = 0; j < this->args_.size(); ++j) |
89fc3421 CC |
165 | { |
166 | ++i; | |
167 | tv[i].tv_tag = LDPT_OPTION; | |
4674ecfc | 168 | tv[i].tv_u.tv_string = this->args_[j].c_str(); |
89fc3421 CC |
169 | } |
170 | ||
171 | ++i; | |
172 | tv[i].tv_tag = LDPT_REGISTER_CLAIM_FILE_HOOK; | |
173 | tv[i].tv_u.tv_register_claim_file = register_claim_file; | |
174 | ||
175 | ++i; | |
176 | tv[i].tv_tag = LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK; | |
177 | tv[i].tv_u.tv_register_all_symbols_read = register_all_symbols_read; | |
178 | ||
179 | ++i; | |
180 | tv[i].tv_tag = LDPT_REGISTER_CLEANUP_HOOK; | |
181 | tv[i].tv_u.tv_register_cleanup = register_cleanup; | |
182 | ||
183 | ++i; | |
184 | tv[i].tv_tag = LDPT_ADD_SYMBOLS; | |
185 | tv[i].tv_u.tv_add_symbols = add_symbols; | |
186 | ||
0f7c0701 CC |
187 | ++i; |
188 | tv[i].tv_tag = LDPT_GET_INPUT_FILE; | |
189 | tv[i].tv_u.tv_get_input_file = get_input_file; | |
190 | ||
191 | ++i; | |
192 | tv[i].tv_tag = LDPT_RELEASE_INPUT_FILE; | |
193 | tv[i].tv_u.tv_release_input_file = release_input_file; | |
194 | ||
89fc3421 CC |
195 | ++i; |
196 | tv[i].tv_tag = LDPT_GET_SYMBOLS; | |
197 | tv[i].tv_u.tv_get_symbols = get_symbols; | |
198 | ||
199 | ++i; | |
200 | tv[i].tv_tag = LDPT_ADD_INPUT_FILE; | |
201 | tv[i].tv_u.tv_add_input_file = add_input_file; | |
202 | ||
e99daf92 ILT |
203 | ++i; |
204 | tv[i].tv_tag = LDPT_ADD_INPUT_LIBRARY; | |
205 | tv[i].tv_u.tv_add_input_library = add_input_library; | |
206 | ||
42218b9f RÁE |
207 | ++i; |
208 | tv[i].tv_tag = LDPT_SET_EXTRA_LIBRARY_PATH; | |
209 | tv[i].tv_u.tv_set_extra_library_path = set_extra_library_path; | |
210 | ||
89fc3421 CC |
211 | ++i; |
212 | tv[i].tv_tag = LDPT_NULL; | |
213 | tv[i].tv_u.tv_val = 0; | |
214 | ||
215 | gold_assert(i == tv_size - 1); | |
216 | ||
217 | // Call the onload entry point. | |
218 | (*onload)(tv); | |
219 | ||
6c52134c | 220 | delete[] tv; |
89fc3421 CC |
221 | #endif // ENABLE_PLUGINS |
222 | } | |
223 | ||
224 | // Call the plugin claim-file handler. | |
225 | ||
226 | inline bool | |
ca09d69a | 227 | Plugin::claim_file(struct ld_plugin_input_file* plugin_input_file) |
89fc3421 CC |
228 | { |
229 | int claimed = 0; | |
230 | ||
231 | if (this->claim_file_handler_ != NULL) | |
232 | { | |
233 | (*this->claim_file_handler_)(plugin_input_file, &claimed); | |
234 | if (claimed) | |
235 | return true; | |
236 | } | |
237 | return false; | |
238 | } | |
239 | ||
240 | // Call the all-symbols-read handler. | |
241 | ||
242 | inline void | |
243 | Plugin::all_symbols_read() | |
244 | { | |
245 | if (this->all_symbols_read_handler_ != NULL) | |
246 | (*this->all_symbols_read_handler_)(); | |
247 | } | |
248 | ||
249 | // Call the cleanup handler. | |
250 | ||
251 | inline void | |
252 | Plugin::cleanup() | |
253 | { | |
40f36857 CC |
254 | if (this->cleanup_handler_ != NULL && !this->cleanup_done_) |
255 | { | |
256 | // Set this flag before calling to prevent a recursive plunge | |
257 | // in the event that a plugin's cleanup handler issues a | |
258 | // fatal error. | |
259 | this->cleanup_done_ = true; | |
260 | (*this->cleanup_handler_)(); | |
261 | } | |
89fc3421 CC |
262 | } |
263 | ||
264 | // Plugin_manager methods. | |
265 | ||
266 | Plugin_manager::~Plugin_manager() | |
267 | { | |
268 | for (Plugin_list::iterator p = this->plugins_.begin(); | |
269 | p != this->plugins_.end(); | |
270 | ++p) | |
271 | delete *p; | |
272 | this->plugins_.clear(); | |
273 | for (Object_list::iterator obj = this->objects_.begin(); | |
274 | obj != this->objects_.end(); | |
275 | ++obj) | |
276 | delete *obj; | |
277 | this->objects_.clear(); | |
278 | } | |
279 | ||
280 | // Load all plugin libraries. | |
281 | ||
282 | void | |
283 | Plugin_manager::load_plugins() | |
284 | { | |
285 | for (this->current_ = this->plugins_.begin(); | |
286 | this->current_ != this->plugins_.end(); | |
287 | ++this->current_) | |
288 | (*this->current_)->load(); | |
289 | } | |
290 | ||
291 | // Call the plugin claim-file handlers in turn to see if any claim the file. | |
292 | ||
293 | Pluginobj* | |
294 | Plugin_manager::claim_file(Input_file* input_file, off_t offset, | |
295 | off_t filesize) | |
296 | { | |
297 | if (this->in_replacement_phase_) | |
298 | return NULL; | |
299 | ||
300 | unsigned int handle = this->objects_.size(); | |
301 | this->input_file_ = input_file; | |
302 | this->plugin_input_file_.name = input_file->filename().c_str(); | |
303 | this->plugin_input_file_.fd = input_file->file().descriptor(); | |
304 | this->plugin_input_file_.offset = offset; | |
305 | this->plugin_input_file_.filesize = filesize; | |
306 | this->plugin_input_file_.handle = reinterpret_cast<void*>(handle); | |
307 | ||
308 | for (this->current_ = this->plugins_.begin(); | |
309 | this->current_ != this->plugins_.end(); | |
310 | ++this->current_) | |
311 | { | |
312 | if ((*this->current_)->claim_file(&this->plugin_input_file_)) | |
313 | { | |
abc8dcba CC |
314 | if (this->objects_.size() > handle) |
315 | return this->objects_[handle]; | |
316 | ||
317 | // If the plugin claimed the file but did not call the | |
318 | // add_symbols callback, we need to create the Pluginobj now. | |
319 | Pluginobj* obj = this->make_plugin_object(handle); | |
320 | return obj; | |
89fc3421 CC |
321 | } |
322 | } | |
323 | ||
324 | return NULL; | |
325 | } | |
326 | ||
327 | // Call the all-symbols-read handlers. | |
328 | ||
329 | void | |
0f7c0701 | 330 | Plugin_manager::all_symbols_read(Workqueue* workqueue, Task* task, |
89fc3421 | 331 | Input_objects* input_objects, |
2ea97941 | 332 | Symbol_table* symtab, Layout* layout, |
89fc3421 CC |
333 | Dirsearch* dirpath, Mapfile* mapfile, |
334 | Task_token** last_blocker) | |
335 | { | |
336 | this->in_replacement_phase_ = true; | |
337 | this->workqueue_ = workqueue; | |
0f7c0701 | 338 | this->task_ = task; |
89fc3421 CC |
339 | this->input_objects_ = input_objects; |
340 | this->symtab_ = symtab; | |
2ea97941 | 341 | this->layout_ = layout; |
89fc3421 CC |
342 | this->dirpath_ = dirpath; |
343 | this->mapfile_ = mapfile; | |
344 | this->this_blocker_ = NULL; | |
345 | ||
346 | for (this->current_ = this->plugins_.begin(); | |
347 | this->current_ != this->plugins_.end(); | |
348 | ++this->current_) | |
349 | (*this->current_)->all_symbols_read(); | |
350 | ||
351 | *last_blocker = this->this_blocker_; | |
352 | } | |
353 | ||
483620e8 | 354 | // Layout deferred objects. |
89fc3421 CC |
355 | |
356 | void | |
483620e8 | 357 | Plugin_manager::layout_deferred_objects() |
89fc3421 | 358 | { |
5995b570 CC |
359 | Deferred_layout_list::iterator obj; |
360 | ||
361 | for (obj = this->deferred_layout_objects_.begin(); | |
362 | obj != this->deferred_layout_objects_.end(); | |
363 | ++obj) | |
5f9bcf58 CC |
364 | { |
365 | // Lock the object so we can read from it. This is only called | |
366 | // single-threaded from queue_middle_tasks, so it is OK to lock. | |
367 | // Unfortunately we have no way to pass in a Task token. | |
368 | const Task* dummy_task = reinterpret_cast<const Task*>(-1); | |
369 | Task_lock_obj<Object> tl(dummy_task, *obj); | |
370 | (*obj)->layout_deferred_sections(this->layout_); | |
371 | } | |
483620e8 CC |
372 | } |
373 | ||
374 | // Call the cleanup handlers. | |
5995b570 | 375 | |
483620e8 CC |
376 | void |
377 | Plugin_manager::cleanup() | |
378 | { | |
89fc3421 CC |
379 | for (this->current_ = this->plugins_.begin(); |
380 | this->current_ != this->plugins_.end(); | |
381 | ++this->current_) | |
382 | (*this->current_)->cleanup(); | |
383 | } | |
384 | ||
385 | // Make a new Pluginobj object. This is called when the plugin calls | |
386 | // the add_symbols API. | |
387 | ||
388 | Pluginobj* | |
389 | Plugin_manager::make_plugin_object(unsigned int handle) | |
390 | { | |
391 | // Make sure we aren't asked to make an object for the same handle twice. | |
392 | if (this->objects_.size() != handle) | |
393 | return NULL; | |
394 | ||
395 | Pluginobj* obj = make_sized_plugin_object(this->input_file_, | |
0f7c0701 CC |
396 | this->plugin_input_file_.offset, |
397 | this->plugin_input_file_.filesize); | |
89fc3421 CC |
398 | this->objects_.push_back(obj); |
399 | return obj; | |
400 | } | |
401 | ||
0f7c0701 CC |
402 | // Get the input file information with an open (possibly re-opened) |
403 | // file descriptor. | |
404 | ||
405 | ld_plugin_status | |
406 | Plugin_manager::get_input_file(unsigned int handle, | |
ca09d69a | 407 | struct ld_plugin_input_file* file) |
0f7c0701 CC |
408 | { |
409 | Pluginobj* obj = this->object(handle); | |
410 | if (obj == NULL) | |
411 | return LDPS_BAD_HANDLE; | |
412 | ||
413 | obj->lock(this->task_); | |
414 | file->name = obj->filename().c_str(); | |
415 | file->fd = obj->descriptor(); | |
416 | file->offset = obj->offset(); | |
417 | file->filesize = obj->filesize(); | |
418 | file->handle = reinterpret_cast<void*>(handle); | |
419 | return LDPS_OK; | |
420 | } | |
421 | ||
422 | // Release the input file. | |
423 | ||
424 | ld_plugin_status | |
425 | Plugin_manager::release_input_file(unsigned int handle) | |
426 | { | |
427 | Pluginobj* obj = this->object(handle); | |
428 | if (obj == NULL) | |
429 | return LDPS_BAD_HANDLE; | |
430 | ||
431 | obj->unlock(this->task_); | |
432 | return LDPS_OK; | |
433 | } | |
434 | ||
42218b9f RÁE |
435 | // Add a new library path. |
436 | ||
437 | ld_plugin_status | |
ca09d69a | 438 | Plugin_manager::set_extra_library_path(const char* path) |
42218b9f RÁE |
439 | { |
440 | this->extra_search_path_ = std::string(path); | |
441 | return LDPS_OK; | |
442 | } | |
443 | ||
89fc3421 CC |
444 | // Add a new input file. |
445 | ||
446 | ld_plugin_status | |
ca09d69a | 447 | Plugin_manager::add_input_file(const char* pathname, bool is_lib) |
89fc3421 | 448 | { |
ae3b5189 CD |
449 | Input_file_argument file(pathname, |
450 | (is_lib | |
451 | ? Input_file_argument::INPUT_FILE_TYPE_LIBRARY | |
452 | : Input_file_argument::INPUT_FILE_TYPE_FILE), | |
42218b9f RÁE |
453 | (is_lib |
454 | ? this->extra_search_path_.c_str() | |
455 | : ""), | |
456 | false, | |
457 | this->options_); | |
89fc3421 CC |
458 | Input_argument* input_argument = new Input_argument(file); |
459 | Task_token* next_blocker = new Task_token(true); | |
460 | next_blocker->add_blocker(); | |
8c21d9d3 | 461 | if (parameters->incremental()) |
40f36857 CC |
462 | gold_error(_("input files added by plug-ins in --incremental mode not " |
463 | "supported yet")); | |
f1ed28fb | 464 | this->workqueue_->queue_soon(new Read_symbols(this->input_objects_, |
89fc3421 CC |
465 | this->symtab_, |
466 | this->layout_, | |
467 | this->dirpath_, | |
15f8229b | 468 | 0, |
89fc3421 CC |
469 | this->mapfile_, |
470 | input_argument, | |
471 | NULL, | |
b0193076 | 472 | NULL, |
89fc3421 CC |
473 | this->this_blocker_, |
474 | next_blocker)); | |
475 | this->this_blocker_ = next_blocker; | |
476 | return LDPS_OK; | |
477 | } | |
478 | ||
479 | // Class Pluginobj. | |
480 | ||
2ea97941 ILT |
481 | Pluginobj::Pluginobj(const std::string& name, Input_file* input_file, |
482 | off_t offset, off_t filesize) | |
483 | : Object(name, input_file, false, offset), | |
484 | nsyms_(0), syms_(NULL), symbols_(), filesize_(filesize), comdat_map_() | |
89fc3421 CC |
485 | { |
486 | } | |
487 | ||
d66a9eb3 CC |
488 | // Return TRUE if a defined symbol might be reachable from outside the |
489 | // universe of claimed objects. | |
490 | ||
491 | static inline bool | |
492 | is_visible_from_outside(Symbol* lsym) | |
493 | { | |
494 | if (lsym->in_real_elf()) | |
495 | return true; | |
496 | if (parameters->options().relocatable()) | |
497 | return true; | |
498 | if (parameters->options().export_dynamic() || parameters->options().shared()) | |
499 | return lsym->is_externally_visible(); | |
500 | return false; | |
501 | } | |
502 | ||
89fc3421 CC |
503 | // Get symbol resolution info. |
504 | ||
505 | ld_plugin_status | |
506 | Pluginobj::get_symbol_resolution_info(int nsyms, ld_plugin_symbol* syms) const | |
507 | { | |
abc8dcba | 508 | if (nsyms > this->nsyms_) |
89fc3421 | 509 | return LDPS_NO_SYMS; |
b0193076 RÁE |
510 | |
511 | if (static_cast<size_t>(nsyms) > this->symbols_.size()) | |
512 | { | |
513 | // We never decided to include this object. We mark all symbols as | |
514 | // preempted. | |
ca09d69a | 515 | gold_assert(this->symbols_.size() == 0); |
b0193076 RÁE |
516 | for (int i = 0; i < nsyms; i++) |
517 | syms[i].resolution = LDPR_PREEMPTED_REG; | |
518 | return LDPS_OK; | |
519 | } | |
520 | ||
89fc3421 CC |
521 | for (int i = 0; i < nsyms; i++) |
522 | { | |
523 | ld_plugin_symbol* isym = &syms[i]; | |
524 | Symbol* lsym = this->symbols_[i]; | |
525 | ld_plugin_symbol_resolution res = LDPR_UNKNOWN; | |
526 | ||
527 | if (lsym->is_undefined()) | |
528 | // The symbol remains undefined. | |
529 | res = LDPR_UNDEF; | |
530 | else if (isym->def == LDPK_UNDEF | |
531 | || isym->def == LDPK_WEAKUNDEF | |
532 | || isym->def == LDPK_COMMON) | |
533 | { | |
534 | // The original symbol was undefined or common. | |
535 | if (lsym->source() != Symbol::FROM_OBJECT) | |
536 | res = LDPR_RESOLVED_EXEC; | |
be234d88 CC |
537 | else if (lsym->object()->pluginobj() == this) |
538 | res = (is_visible_from_outside(lsym) | |
539 | ? LDPR_PREVAILING_DEF | |
540 | : LDPR_PREVAILING_DEF_IRONLY); | |
89fc3421 CC |
541 | else if (lsym->object()->pluginobj() != NULL) |
542 | res = LDPR_RESOLVED_IR; | |
543 | else if (lsym->object()->is_dynamic()) | |
544 | res = LDPR_RESOLVED_DYN; | |
545 | else | |
546 | res = LDPR_RESOLVED_EXEC; | |
547 | } | |
548 | else | |
549 | { | |
550 | // The original symbol was a definition. | |
551 | if (lsym->source() != Symbol::FROM_OBJECT) | |
552 | res = LDPR_PREEMPTED_REG; | |
553 | else if (lsym->object() == static_cast<const Object*>(this)) | |
d66a9eb3 | 554 | res = (is_visible_from_outside(lsym) |
89fc3421 CC |
555 | ? LDPR_PREVAILING_DEF |
556 | : LDPR_PREVAILING_DEF_IRONLY); | |
557 | else | |
558 | res = (lsym->object()->pluginobj() != NULL | |
559 | ? LDPR_PREEMPTED_IR | |
560 | : LDPR_PREEMPTED_REG); | |
561 | } | |
562 | isym->resolution = res; | |
563 | } | |
564 | return LDPS_OK; | |
565 | } | |
566 | ||
567 | // Return TRUE if the comdat group with key COMDAT_KEY from this object | |
568 | // should be kept. | |
569 | ||
570 | bool | |
2ea97941 | 571 | Pluginobj::include_comdat_group(std::string comdat_key, Layout* layout) |
89fc3421 CC |
572 | { |
573 | std::pair<Comdat_map::iterator, bool> ins = | |
574 | this->comdat_map_.insert(std::make_pair(comdat_key, false)); | |
575 | ||
576 | // If this is the first time we've seen this comdat key, ask the | |
577 | // layout object whether it should be included. | |
578 | if (ins.second) | |
2ea97941 ILT |
579 | ins.first->second = layout->find_or_add_kept_section(comdat_key, |
580 | NULL, 0, true, | |
581 | true, NULL); | |
89fc3421 CC |
582 | |
583 | return ins.first->second; | |
584 | } | |
585 | ||
586 | // Class Sized_pluginobj. | |
587 | ||
588 | template<int size, bool big_endian> | |
589 | Sized_pluginobj<size, big_endian>::Sized_pluginobj( | |
2ea97941 ILT |
590 | const std::string& name, |
591 | Input_file* input_file, | |
592 | off_t offset, | |
593 | off_t filesize) | |
594 | : Pluginobj(name, input_file, offset, filesize) | |
89fc3421 CC |
595 | { |
596 | } | |
597 | ||
598 | // Read the symbols. Not used for plugin objects. | |
599 | ||
600 | template<int size, bool big_endian> | |
601 | void | |
602 | Sized_pluginobj<size, big_endian>::do_read_symbols(Read_symbols_data*) | |
603 | { | |
604 | gold_unreachable(); | |
605 | } | |
606 | ||
607 | // Lay out the input sections. Not used for plugin objects. | |
608 | ||
609 | template<int size, bool big_endian> | |
610 | void | |
611 | Sized_pluginobj<size, big_endian>::do_layout(Symbol_table*, Layout*, | |
612 | Read_symbols_data*) | |
613 | { | |
614 | gold_unreachable(); | |
615 | } | |
616 | ||
617 | // Add the symbols to the symbol table. | |
618 | ||
89fc3421 CC |
619 | template<int size, bool big_endian> |
620 | void | |
621 | Sized_pluginobj<size, big_endian>::do_add_symbols(Symbol_table* symtab, | |
f488e4b0 | 622 | Read_symbols_data*, |
2ea97941 | 623 | Layout* layout) |
89fc3421 CC |
624 | { |
625 | const int sym_size = elfcpp::Elf_sizes<size>::sym_size; | |
626 | unsigned char symbuf[sym_size]; | |
627 | elfcpp::Sym<size, big_endian> sym(symbuf); | |
628 | elfcpp::Sym_write<size, big_endian> osym(symbuf); | |
629 | ||
630 | typedef typename elfcpp::Elf_types<size>::Elf_WXword Elf_size_type; | |
631 | ||
632 | this->symbols_.resize(this->nsyms_); | |
633 | ||
634 | for (int i = 0; i < this->nsyms_; ++i) | |
635 | { | |
ca09d69a | 636 | const struct ld_plugin_symbol* isym = &this->syms_[i]; |
2ea97941 | 637 | const char* name = isym->name; |
89fc3421 CC |
638 | const char* ver = isym->version; |
639 | elfcpp::Elf_Half shndx; | |
640 | elfcpp::STB bind; | |
641 | elfcpp::STV vis; | |
642 | ||
2ea97941 ILT |
643 | if (name != NULL && name[0] == '\0') |
644 | name = NULL; | |
89fc3421 CC |
645 | if (ver != NULL && ver[0] == '\0') |
646 | ver = NULL; | |
647 | ||
648 | switch (isym->def) | |
649 | { | |
650 | case LDPK_WEAKDEF: | |
651 | case LDPK_WEAKUNDEF: | |
652 | bind = elfcpp::STB_WEAK; | |
653 | break; | |
654 | case LDPK_DEF: | |
655 | case LDPK_UNDEF: | |
656 | case LDPK_COMMON: | |
657 | default: | |
658 | bind = elfcpp::STB_GLOBAL; | |
659 | break; | |
660 | } | |
661 | ||
662 | switch (isym->def) | |
663 | { | |
664 | case LDPK_DEF: | |
665 | case LDPK_WEAKDEF: | |
666 | shndx = elfcpp::SHN_ABS; | |
667 | break; | |
668 | case LDPK_COMMON: | |
669 | shndx = elfcpp::SHN_COMMON; | |
670 | break; | |
671 | case LDPK_UNDEF: | |
672 | case LDPK_WEAKUNDEF: | |
673 | default: | |
674 | shndx = elfcpp::SHN_UNDEF; | |
675 | break; | |
676 | } | |
677 | ||
678 | switch (isym->visibility) | |
679 | { | |
680 | case LDPV_PROTECTED: | |
105b6afd | 681 | vis = elfcpp::STV_PROTECTED; |
89fc3421 CC |
682 | break; |
683 | case LDPV_INTERNAL: | |
105b6afd | 684 | vis = elfcpp::STV_INTERNAL; |
89fc3421 CC |
685 | break; |
686 | case LDPV_HIDDEN: | |
105b6afd | 687 | vis = elfcpp::STV_HIDDEN; |
89fc3421 CC |
688 | break; |
689 | case LDPV_DEFAULT: | |
690 | default: | |
691 | vis = elfcpp::STV_DEFAULT; | |
692 | break; | |
693 | } | |
694 | ||
695 | if (isym->comdat_key != NULL | |
696 | && isym->comdat_key[0] != '\0' | |
2ea97941 | 697 | && !this->include_comdat_group(isym->comdat_key, layout)) |
89fc3421 CC |
698 | shndx = elfcpp::SHN_UNDEF; |
699 | ||
700 | osym.put_st_name(0); | |
701 | osym.put_st_value(0); | |
702 | osym.put_st_size(static_cast<Elf_size_type>(isym->size)); | |
703 | osym.put_st_info(bind, elfcpp::STT_NOTYPE); | |
704 | osym.put_st_other(vis, 0); | |
705 | osym.put_st_shndx(shndx); | |
706 | ||
707 | this->symbols_[i] = | |
2ea97941 | 708 | symtab->add_from_pluginobj<size, big_endian>(this, name, ver, &sym); |
89fc3421 CC |
709 | } |
710 | } | |
711 | ||
b0193076 RÁE |
712 | template<int size, bool big_endian> |
713 | Archive::Should_include | |
714 | Sized_pluginobj<size, big_endian>::do_should_include_member( | |
88a4108b ILT |
715 | Symbol_table* symtab, |
716 | Layout* layout, | |
717 | Read_symbols_data*, | |
718 | std::string* why) | |
b0193076 RÁE |
719 | { |
720 | char* tmpbuf = NULL; | |
721 | size_t tmpbuflen = 0; | |
722 | ||
88a4108b ILT |
723 | for (int i = 0; i < this->nsyms_; ++i) |
724 | { | |
725 | const struct ld_plugin_symbol& sym = this->syms_[i]; | |
726 | const char* name = sym.name; | |
727 | Symbol* symbol; | |
728 | Archive::Should_include t = Archive::should_include_member(symtab, | |
729 | layout, | |
730 | name, | |
731 | &symbol, why, | |
732 | &tmpbuf, | |
733 | &tmpbuflen); | |
b0193076 RÁE |
734 | if (t == Archive::SHOULD_INCLUDE_YES) |
735 | { | |
736 | if (tmpbuf != NULL) | |
737 | free(tmpbuf); | |
738 | return t; | |
739 | } | |
88a4108b | 740 | } |
b0193076 RÁE |
741 | if (tmpbuf != NULL) |
742 | free(tmpbuf); | |
743 | return Archive::SHOULD_INCLUDE_UNKNOWN; | |
744 | } | |
745 | ||
89fc3421 CC |
746 | // Get the size of a section. Not used for plugin objects. |
747 | ||
748 | template<int size, bool big_endian> | |
749 | uint64_t | |
750 | Sized_pluginobj<size, big_endian>::do_section_size(unsigned int) | |
751 | { | |
752 | gold_unreachable(); | |
753 | return 0; | |
754 | } | |
755 | ||
756 | // Get the name of a section. Not used for plugin objects. | |
757 | ||
758 | template<int size, bool big_endian> | |
759 | std::string | |
760 | Sized_pluginobj<size, big_endian>::do_section_name(unsigned int) | |
761 | { | |
762 | gold_unreachable(); | |
763 | return std::string(); | |
764 | } | |
765 | ||
766 | // Return a view of the contents of a section. Not used for plugin objects. | |
767 | ||
768 | template<int size, bool big_endian> | |
769 | Object::Location | |
770 | Sized_pluginobj<size, big_endian>::do_section_contents(unsigned int) | |
771 | { | |
772 | Location loc(0, 0); | |
773 | ||
774 | gold_unreachable(); | |
775 | return loc; | |
776 | } | |
777 | ||
778 | // Return section flags. Not used for plugin objects. | |
779 | ||
780 | template<int size, bool big_endian> | |
781 | uint64_t | |
782 | Sized_pluginobj<size, big_endian>::do_section_flags(unsigned int) | |
783 | { | |
784 | gold_unreachable(); | |
785 | return 0; | |
786 | } | |
787 | ||
ef15dade ST |
788 | // Return section entsize. Not used for plugin objects. |
789 | ||
790 | template<int size, bool big_endian> | |
791 | uint64_t | |
792 | Sized_pluginobj<size, big_endian>::do_section_entsize(unsigned int) | |
793 | { | |
794 | gold_unreachable(); | |
795 | return 0; | |
796 | } | |
797 | ||
89fc3421 CC |
798 | // Return section address. Not used for plugin objects. |
799 | ||
800 | template<int size, bool big_endian> | |
801 | uint64_t | |
802 | Sized_pluginobj<size, big_endian>::do_section_address(unsigned int) | |
803 | { | |
804 | gold_unreachable(); | |
805 | return 0; | |
806 | } | |
807 | ||
808 | // Return section type. Not used for plugin objects. | |
809 | ||
810 | template<int size, bool big_endian> | |
811 | unsigned int | |
812 | Sized_pluginobj<size, big_endian>::do_section_type(unsigned int) | |
813 | { | |
814 | gold_unreachable(); | |
815 | return 0; | |
816 | } | |
817 | ||
818 | // Return the section link field. Not used for plugin objects. | |
819 | ||
820 | template<int size, bool big_endian> | |
821 | unsigned int | |
822 | Sized_pluginobj<size, big_endian>::do_section_link(unsigned int) | |
823 | { | |
824 | gold_unreachable(); | |
825 | return 0; | |
826 | } | |
827 | ||
828 | // Return the section link field. Not used for plugin objects. | |
829 | ||
830 | template<int size, bool big_endian> | |
831 | unsigned int | |
832 | Sized_pluginobj<size, big_endian>::do_section_info(unsigned int) | |
833 | { | |
834 | gold_unreachable(); | |
835 | return 0; | |
836 | } | |
837 | ||
838 | // Return the section alignment. Not used for plugin objects. | |
839 | ||
840 | template<int size, bool big_endian> | |
841 | uint64_t | |
842 | Sized_pluginobj<size, big_endian>::do_section_addralign(unsigned int) | |
843 | { | |
844 | gold_unreachable(); | |
845 | return 0; | |
846 | } | |
847 | ||
848 | // Return the Xindex structure to use. Not used for plugin objects. | |
849 | ||
850 | template<int size, bool big_endian> | |
851 | Xindex* | |
852 | Sized_pluginobj<size, big_endian>::do_initialize_xindex() | |
853 | { | |
854 | gold_unreachable(); | |
855 | return NULL; | |
856 | } | |
857 | ||
858 | // Get symbol counts. Not used for plugin objects. | |
859 | ||
860 | template<int size, bool big_endian> | |
861 | void | |
862 | Sized_pluginobj<size, big_endian>::do_get_global_symbol_counts(const Symbol_table*, | |
863 | size_t*, size_t*) const | |
864 | { | |
865 | gold_unreachable(); | |
866 | } | |
867 | ||
dde3f402 ILT |
868 | // Get symbols. Not used for plugin objects. |
869 | ||
870 | template<int size, bool big_endian> | |
871 | const Object::Symbols* | |
872 | Sized_pluginobj<size, big_endian>::do_get_global_symbols() const | |
873 | { | |
874 | gold_unreachable(); | |
875 | } | |
876 | ||
5995b570 | 877 | // Class Plugin_finish. This task runs after all replacement files have |
78384e8f CC |
878 | // been added. For now, it's a placeholder for a possible plugin API |
879 | // to allow the plugin to release most of its resources. The cleanup | |
880 | // handlers must be called later, because they can remove the temporary | |
881 | // object files that are needed until the end of the link. | |
89fc3421 | 882 | |
5995b570 | 883 | class Plugin_finish : public Task |
89fc3421 CC |
884 | { |
885 | public: | |
5995b570 | 886 | Plugin_finish(Task_token* this_blocker, Task_token* next_blocker) |
89fc3421 CC |
887 | : this_blocker_(this_blocker), next_blocker_(next_blocker) |
888 | { } | |
889 | ||
5995b570 | 890 | ~Plugin_finish() |
89fc3421 CC |
891 | { |
892 | if (this->this_blocker_ != NULL) | |
893 | delete this->this_blocker_; | |
894 | } | |
895 | ||
896 | Task_token* | |
897 | is_runnable() | |
898 | { | |
899 | if (this->this_blocker_ != NULL && this->this_blocker_->is_blocked()) | |
900 | return this->this_blocker_; | |
901 | return NULL; | |
902 | } | |
903 | ||
904 | void | |
905 | locks(Task_locker* tl) | |
906 | { tl->add(this, this->next_blocker_); } | |
907 | ||
908 | void | |
909 | run(Workqueue*) | |
483620e8 | 910 | { |
78384e8f | 911 | // We could call early cleanup handlers here. |
483620e8 | 912 | } |
89fc3421 CC |
913 | |
914 | std::string | |
915 | get_name() const | |
5995b570 | 916 | { return "Plugin_finish"; } |
89fc3421 CC |
917 | |
918 | private: | |
919 | Task_token* this_blocker_; | |
920 | Task_token* next_blocker_; | |
921 | }; | |
922 | ||
923 | // Class Plugin_hook. | |
924 | ||
925 | Plugin_hook::~Plugin_hook() | |
926 | { | |
927 | } | |
928 | ||
929 | // Return whether a Plugin_hook task is runnable. | |
930 | ||
931 | Task_token* | |
932 | Plugin_hook::is_runnable() | |
933 | { | |
934 | if (this->this_blocker_ != NULL && this->this_blocker_->is_blocked()) | |
935 | return this->this_blocker_; | |
936 | return NULL; | |
937 | } | |
938 | ||
939 | // Return a Task_locker for a Plugin_hook task. We don't need any | |
940 | // locks here. | |
941 | ||
942 | void | |
943 | Plugin_hook::locks(Task_locker*) | |
944 | { | |
945 | } | |
946 | ||
89fc3421 CC |
947 | // Run the "all symbols read" plugin hook. |
948 | ||
949 | void | |
5995b570 | 950 | Plugin_hook::run(Workqueue* workqueue) |
89fc3421 CC |
951 | { |
952 | gold_assert(this->options_.has_plugins()); | |
91ff43fe RÁE |
953 | Symbol* start_sym; |
954 | if (parameters->options().entry()) | |
955 | start_sym = this->symtab_->lookup(parameters->options().entry()); | |
956 | else | |
957 | start_sym = this->symtab_->lookup("_start"); | |
958 | if (start_sym != NULL) | |
959 | start_sym->set_in_real_elf(); | |
960 | ||
89fc3421 | 961 | this->options_.plugins()->all_symbols_read(workqueue, |
0f7c0701 | 962 | this, |
89fc3421 CC |
963 | this->input_objects_, |
964 | this->symtab_, | |
965 | this->layout_, | |
966 | this->dirpath_, | |
967 | this->mapfile_, | |
968 | &this->this_blocker_); | |
5995b570 CC |
969 | workqueue->queue_soon(new Plugin_finish(this->this_blocker_, |
970 | this->next_blocker_)); | |
89fc3421 CC |
971 | } |
972 | ||
973 | // The C interface routines called by the plugins. | |
974 | ||
975 | #ifdef ENABLE_PLUGINS | |
976 | ||
977 | // Register a claim-file handler. | |
978 | ||
979 | static enum ld_plugin_status | |
980 | register_claim_file(ld_plugin_claim_file_handler handler) | |
981 | { | |
982 | gold_assert(parameters->options().has_plugins()); | |
983 | parameters->options().plugins()->set_claim_file_handler(handler); | |
984 | return LDPS_OK; | |
985 | } | |
986 | ||
987 | // Register an all-symbols-read handler. | |
988 | ||
989 | static enum ld_plugin_status | |
990 | register_all_symbols_read(ld_plugin_all_symbols_read_handler handler) | |
991 | { | |
992 | gold_assert(parameters->options().has_plugins()); | |
993 | parameters->options().plugins()->set_all_symbols_read_handler(handler); | |
994 | return LDPS_OK; | |
995 | } | |
996 | ||
997 | // Register a cleanup handler. | |
998 | ||
999 | static enum ld_plugin_status | |
1000 | register_cleanup(ld_plugin_cleanup_handler handler) | |
1001 | { | |
1002 | gold_assert(parameters->options().has_plugins()); | |
1003 | parameters->options().plugins()->set_cleanup_handler(handler); | |
1004 | return LDPS_OK; | |
1005 | } | |
1006 | ||
1007 | // Add symbols from a plugin-claimed input file. | |
1008 | ||
1009 | static enum ld_plugin_status | |
ca09d69a | 1010 | add_symbols(void* handle, int nsyms, const ld_plugin_symbol* syms) |
89fc3421 CC |
1011 | { |
1012 | gold_assert(parameters->options().has_plugins()); | |
1013 | Pluginobj* obj = parameters->options().plugins()->make_plugin_object( | |
1014 | static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle))); | |
1015 | if (obj == NULL) | |
1016 | return LDPS_ERR; | |
1017 | obj->store_incoming_symbols(nsyms, syms); | |
1018 | return LDPS_OK; | |
1019 | } | |
1020 | ||
0f7c0701 CC |
1021 | // Get the input file information with an open (possibly re-opened) |
1022 | // file descriptor. | |
1023 | ||
1024 | static enum ld_plugin_status | |
ca09d69a | 1025 | get_input_file(const void* handle, struct ld_plugin_input_file* file) |
0f7c0701 CC |
1026 | { |
1027 | gold_assert(parameters->options().has_plugins()); | |
1028 | unsigned int obj_index = | |
1029 | static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle)); | |
1030 | return parameters->options().plugins()->get_input_file(obj_index, file); | |
1031 | } | |
1032 | ||
1033 | // Release the input file. | |
1034 | ||
1035 | static enum ld_plugin_status | |
ca09d69a | 1036 | release_input_file(const void* handle) |
0f7c0701 CC |
1037 | { |
1038 | gold_assert(parameters->options().has_plugins()); | |
1039 | unsigned int obj_index = | |
1040 | static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle)); | |
1041 | return parameters->options().plugins()->release_input_file(obj_index); | |
1042 | } | |
1043 | ||
89fc3421 CC |
1044 | // Get the symbol resolution info for a plugin-claimed input file. |
1045 | ||
1046 | static enum ld_plugin_status | |
ca09d69a | 1047 | get_symbols(const void* handle, int nsyms, ld_plugin_symbol* syms) |
89fc3421 CC |
1048 | { |
1049 | gold_assert(parameters->options().has_plugins()); | |
1050 | Pluginobj* obj = parameters->options().plugins()->object( | |
1051 | static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle))); | |
1052 | if (obj == NULL) | |
1053 | return LDPS_ERR; | |
1054 | return obj->get_symbol_resolution_info(nsyms, syms); | |
1055 | } | |
1056 | ||
1057 | // Add a new (real) input file generated by a plugin. | |
1058 | ||
1059 | static enum ld_plugin_status | |
ca09d69a | 1060 | add_input_file(const char* pathname) |
89fc3421 CC |
1061 | { |
1062 | gold_assert(parameters->options().has_plugins()); | |
e99daf92 ILT |
1063 | return parameters->options().plugins()->add_input_file(pathname, false); |
1064 | } | |
1065 | ||
1066 | // Add a new (real) library required by a plugin. | |
1067 | ||
1068 | static enum ld_plugin_status | |
ca09d69a | 1069 | add_input_library(const char* pathname) |
e99daf92 ILT |
1070 | { |
1071 | gold_assert(parameters->options().has_plugins()); | |
1072 | return parameters->options().plugins()->add_input_file(pathname, true); | |
89fc3421 CC |
1073 | } |
1074 | ||
42218b9f RÁE |
1075 | // Set the extra library path to be used by libraries added via |
1076 | // add_input_library | |
1077 | ||
1078 | static enum ld_plugin_status | |
ca09d69a | 1079 | set_extra_library_path(const char* path) |
42218b9f RÁE |
1080 | { |
1081 | gold_assert(parameters->options().has_plugins()); | |
1082 | return parameters->options().plugins()->set_extra_library_path(path); | |
1083 | } | |
1084 | ||
89fc3421 CC |
1085 | // Issue a diagnostic message from a plugin. |
1086 | ||
1087 | static enum ld_plugin_status | |
ca09d69a | 1088 | message(int level, const char* format, ...) |
89fc3421 CC |
1089 | { |
1090 | va_list args; | |
1091 | va_start(args, format); | |
1092 | ||
1093 | switch (level) | |
1094 | { | |
1095 | case LDPL_INFO: | |
1096 | parameters->errors()->info(format, args); | |
1097 | break; | |
1098 | case LDPL_WARNING: | |
1099 | parameters->errors()->warning(format, args); | |
1100 | break; | |
1101 | case LDPL_ERROR: | |
1102 | default: | |
1103 | parameters->errors()->error(format, args); | |
1104 | break; | |
1105 | case LDPL_FATAL: | |
1106 | parameters->errors()->fatal(format, args); | |
1107 | break; | |
1108 | } | |
1109 | ||
1110 | va_end(args); | |
1111 | return LDPS_OK; | |
1112 | } | |
1113 | ||
1114 | #endif // ENABLE_PLUGINS | |
1115 | ||
1116 | // Allocate a Pluginobj object of the appropriate size and endianness. | |
1117 | ||
1118 | static Pluginobj* | |
0f7c0701 | 1119 | make_sized_plugin_object(Input_file* input_file, off_t offset, off_t filesize) |
89fc3421 | 1120 | { |
89fc3421 CC |
1121 | Pluginobj* obj = NULL; |
1122 | ||
029ba973 ILT |
1123 | parameters_force_valid_target(); |
1124 | const Target& target(parameters->target()); | |
89fc3421 | 1125 | |
029ba973 | 1126 | if (target.get_size() == 32) |
89fc3421 | 1127 | { |
029ba973 | 1128 | if (target.is_big_endian()) |
92f03fcb | 1129 | #ifdef HAVE_TARGET_32_BIG |
89fc3421 | 1130 | obj = new Sized_pluginobj<32, true>(input_file->filename(), |
0f7c0701 | 1131 | input_file, offset, filesize); |
92f03fcb CC |
1132 | #else |
1133 | gold_error(_("%s: not configured to support " | |
1134 | "32-bit big-endian object"), | |
1135 | input_file->filename().c_str()); | |
89fc3421 | 1136 | #endif |
89fc3421 | 1137 | else |
92f03fcb | 1138 | #ifdef HAVE_TARGET_32_LITTLE |
89fc3421 | 1139 | obj = new Sized_pluginobj<32, false>(input_file->filename(), |
0f7c0701 | 1140 | input_file, offset, filesize); |
92f03fcb CC |
1141 | #else |
1142 | gold_error(_("%s: not configured to support " | |
1143 | "32-bit little-endian object"), | |
1144 | input_file->filename().c_str()); | |
89fc3421 CC |
1145 | #endif |
1146 | } | |
029ba973 | 1147 | else if (target.get_size() == 64) |
89fc3421 | 1148 | { |
029ba973 | 1149 | if (target.is_big_endian()) |
92f03fcb | 1150 | #ifdef HAVE_TARGET_64_BIG |
89fc3421 | 1151 | obj = new Sized_pluginobj<64, true>(input_file->filename(), |
0f7c0701 | 1152 | input_file, offset, filesize); |
92f03fcb CC |
1153 | #else |
1154 | gold_error(_("%s: not configured to support " | |
1155 | "64-bit big-endian object"), | |
1156 | input_file->filename().c_str()); | |
89fc3421 | 1157 | #endif |
89fc3421 | 1158 | else |
92f03fcb | 1159 | #ifdef HAVE_TARGET_64_LITTLE |
89fc3421 | 1160 | obj = new Sized_pluginobj<64, false>(input_file->filename(), |
0f7c0701 | 1161 | input_file, offset, filesize); |
92f03fcb CC |
1162 | #else |
1163 | gold_error(_("%s: not configured to support " | |
1164 | "64-bit little-endian object"), | |
1165 | input_file->filename().c_str()); | |
89fc3421 CC |
1166 | #endif |
1167 | } | |
1168 | ||
1169 | gold_assert(obj != NULL); | |
89fc3421 CC |
1170 | return obj; |
1171 | } | |
1172 | ||
1173 | } // End namespace gold. |