1 // plugin.cc -- plugin manager for gold -*- C++ -*-
3 // Copyright 2008, 2009 Free Software Foundation, Inc.
4 // Written by Cary Coutant <ccoutant@google.com>.
6 // This file is part of gold.
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.
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.
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.
34 #include "parameters.h"
50 // The linker's exported interfaces.
55 static enum ld_plugin_status
56 register_claim_file(ld_plugin_claim_file_handler handler
);
58 static enum ld_plugin_status
59 register_all_symbols_read(ld_plugin_all_symbols_read_handler handler
);
61 static enum ld_plugin_status
62 register_cleanup(ld_plugin_cleanup_handler handler
);
64 static enum ld_plugin_status
65 add_symbols(void *handle
, int nsyms
, const struct ld_plugin_symbol
*syms
);
67 static enum ld_plugin_status
68 get_input_file(const void *handle
, struct ld_plugin_input_file
*file
);
70 static enum ld_plugin_status
71 release_input_file(const void *handle
);
73 static enum ld_plugin_status
74 get_symbols(const void *handle
, int nsyms
, struct ld_plugin_symbol
*syms
);
76 static enum ld_plugin_status
77 add_input_file(char *pathname
);
79 static enum ld_plugin_status
80 add_input_library(char *pathname
);
82 static enum ld_plugin_status
83 message(int level
, const char *format
, ...);
87 #endif // ENABLE_PLUGINS
89 static Pluginobj
* make_sized_plugin_object(Input_file
* input_file
,
90 off_t offset
, off_t filesize
);
94 // Load one plugin library.
100 // Load the plugin library.
101 // FIXME: Look for the library in standard locations.
102 this->handle_
= dlopen(this->filename_
.c_str(), RTLD_NOW
);
103 if (this->handle_
== NULL
)
105 gold_error(_("%s: could not load plugin library"),
106 this->filename_
.c_str());
110 // Find the plugin's onload entry point.
111 ld_plugin_onload onload
= reinterpret_cast<ld_plugin_onload
>
112 (dlsym(this->handle_
, "onload"));
115 gold_error(_("%s: could not find onload entry point"),
116 this->filename_
.c_str());
120 // Get the linker's version number.
121 const char* ver
= get_version_string();
124 sscanf(ver
, "%d.%d", &major
, &minor
);
126 // Allocate and populate a transfer vector.
127 const int tv_fixed_size
= 14;
128 int tv_size
= this->args_
.size() + tv_fixed_size
;
129 ld_plugin_tv
*tv
= new ld_plugin_tv
[tv_size
];
131 // Put LDPT_MESSAGE at the front of the list so the plugin can use it
132 // while processing subsequent entries.
134 tv
[i
].tv_tag
= LDPT_MESSAGE
;
135 tv
[i
].tv_u
.tv_message
= message
;
138 tv
[i
].tv_tag
= LDPT_API_VERSION
;
139 tv
[i
].tv_u
.tv_val
= LD_PLUGIN_API_VERSION
;
142 tv
[i
].tv_tag
= LDPT_GOLD_VERSION
;
143 tv
[i
].tv_u
.tv_val
= major
* 100 + minor
;
146 tv
[i
].tv_tag
= LDPT_LINKER_OUTPUT
;
147 if (parameters
->options().relocatable())
148 tv
[i
].tv_u
.tv_val
= LDPO_REL
;
149 else if (parameters
->options().shared())
150 tv
[i
].tv_u
.tv_val
= LDPO_DYN
;
152 tv
[i
].tv_u
.tv_val
= LDPO_EXEC
;
154 for (unsigned int j
= 0; j
< this->args_
.size(); ++j
)
157 tv
[i
].tv_tag
= LDPT_OPTION
;
158 tv
[i
].tv_u
.tv_string
= this->args_
[j
].c_str();
162 tv
[i
].tv_tag
= LDPT_REGISTER_CLAIM_FILE_HOOK
;
163 tv
[i
].tv_u
.tv_register_claim_file
= register_claim_file
;
166 tv
[i
].tv_tag
= LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK
;
167 tv
[i
].tv_u
.tv_register_all_symbols_read
= register_all_symbols_read
;
170 tv
[i
].tv_tag
= LDPT_REGISTER_CLEANUP_HOOK
;
171 tv
[i
].tv_u
.tv_register_cleanup
= register_cleanup
;
174 tv
[i
].tv_tag
= LDPT_ADD_SYMBOLS
;
175 tv
[i
].tv_u
.tv_add_symbols
= add_symbols
;
178 tv
[i
].tv_tag
= LDPT_GET_INPUT_FILE
;
179 tv
[i
].tv_u
.tv_get_input_file
= get_input_file
;
182 tv
[i
].tv_tag
= LDPT_RELEASE_INPUT_FILE
;
183 tv
[i
].tv_u
.tv_release_input_file
= release_input_file
;
186 tv
[i
].tv_tag
= LDPT_GET_SYMBOLS
;
187 tv
[i
].tv_u
.tv_get_symbols
= get_symbols
;
190 tv
[i
].tv_tag
= LDPT_ADD_INPUT_FILE
;
191 tv
[i
].tv_u
.tv_add_input_file
= add_input_file
;
194 tv
[i
].tv_tag
= LDPT_ADD_INPUT_LIBRARY
;
195 tv
[i
].tv_u
.tv_add_input_library
= add_input_library
;
198 tv
[i
].tv_tag
= LDPT_NULL
;
199 tv
[i
].tv_u
.tv_val
= 0;
201 gold_assert(i
== tv_size
- 1);
203 // Call the onload entry point.
207 #endif // ENABLE_PLUGINS
210 // Call the plugin claim-file handler.
213 Plugin::claim_file(struct ld_plugin_input_file
*plugin_input_file
)
217 if (this->claim_file_handler_
!= NULL
)
219 (*this->claim_file_handler_
)(plugin_input_file
, &claimed
);
226 // Call the all-symbols-read handler.
229 Plugin::all_symbols_read()
231 if (this->all_symbols_read_handler_
!= NULL
)
232 (*this->all_symbols_read_handler_
)();
235 // Call the cleanup handler.
240 if (this->cleanup_handler_
!= NULL
)
241 (*this->cleanup_handler_
)();
244 // Plugin_manager methods.
246 Plugin_manager::~Plugin_manager()
248 for (Plugin_list::iterator p
= this->plugins_
.begin();
249 p
!= this->plugins_
.end();
252 this->plugins_
.clear();
253 for (Object_list::iterator obj
= this->objects_
.begin();
254 obj
!= this->objects_
.end();
257 this->objects_
.clear();
260 // Load all plugin libraries.
263 Plugin_manager::load_plugins()
265 for (this->current_
= this->plugins_
.begin();
266 this->current_
!= this->plugins_
.end();
268 (*this->current_
)->load();
271 // Call the plugin claim-file handlers in turn to see if any claim the file.
274 Plugin_manager::claim_file(Input_file
* input_file
, off_t offset
,
277 if (this->in_replacement_phase_
)
280 unsigned int handle
= this->objects_
.size();
281 this->input_file_
= input_file
;
282 this->plugin_input_file_
.name
= input_file
->filename().c_str();
283 this->plugin_input_file_
.fd
= input_file
->file().descriptor();
284 this->plugin_input_file_
.offset
= offset
;
285 this->plugin_input_file_
.filesize
= filesize
;
286 this->plugin_input_file_
.handle
= reinterpret_cast<void*>(handle
);
288 for (this->current_
= this->plugins_
.begin();
289 this->current_
!= this->plugins_
.end();
292 if ((*this->current_
)->claim_file(&this->plugin_input_file_
))
294 if (this->objects_
.size() > handle
)
295 return this->objects_
[handle
];
297 // If the plugin claimed the file but did not call the
298 // add_symbols callback, we need to create the Pluginobj now.
299 Pluginobj
* obj
= this->make_plugin_object(handle
);
307 // Call the all-symbols-read handlers.
310 Plugin_manager::all_symbols_read(Workqueue
* workqueue
, Task
* task
,
311 Input_objects
* input_objects
,
312 Symbol_table
* symtab
, Layout
* layout
,
313 Dirsearch
* dirpath
, Mapfile
* mapfile
,
314 Task_token
** last_blocker
)
316 this->in_replacement_phase_
= true;
317 this->workqueue_
= workqueue
;
319 this->input_objects_
= input_objects
;
320 this->symtab_
= symtab
;
321 this->layout_
= layout
;
322 this->dirpath_
= dirpath
;
323 this->mapfile_
= mapfile
;
324 this->this_blocker_
= NULL
;
326 for (this->current_
= this->plugins_
.begin();
327 this->current_
!= this->plugins_
.end();
329 (*this->current_
)->all_symbols_read();
331 *last_blocker
= this->this_blocker_
;
334 // Layout deferred objects.
337 Plugin_manager::layout_deferred_objects()
339 Deferred_layout_list::iterator obj
;
341 for (obj
= this->deferred_layout_objects_
.begin();
342 obj
!= this->deferred_layout_objects_
.end();
344 (*obj
)->layout_deferred_sections(this->layout_
);
347 // Call the cleanup handlers.
350 Plugin_manager::cleanup()
352 if (this->cleanup_done_
)
354 for (this->current_
= this->plugins_
.begin();
355 this->current_
!= this->plugins_
.end();
357 (*this->current_
)->cleanup();
358 this->cleanup_done_
= true;
361 // Make a new Pluginobj object. This is called when the plugin calls
362 // the add_symbols API.
365 Plugin_manager::make_plugin_object(unsigned int handle
)
367 // Make sure we aren't asked to make an object for the same handle twice.
368 if (this->objects_
.size() != handle
)
371 Pluginobj
* obj
= make_sized_plugin_object(this->input_file_
,
372 this->plugin_input_file_
.offset
,
373 this->plugin_input_file_
.filesize
);
374 this->objects_
.push_back(obj
);
378 // Get the input file information with an open (possibly re-opened)
382 Plugin_manager::get_input_file(unsigned int handle
,
383 struct ld_plugin_input_file
*file
)
385 Pluginobj
* obj
= this->object(handle
);
387 return LDPS_BAD_HANDLE
;
389 obj
->lock(this->task_
);
390 file
->name
= obj
->filename().c_str();
391 file
->fd
= obj
->descriptor();
392 file
->offset
= obj
->offset();
393 file
->filesize
= obj
->filesize();
394 file
->handle
= reinterpret_cast<void*>(handle
);
398 // Release the input file.
401 Plugin_manager::release_input_file(unsigned int handle
)
403 Pluginobj
* obj
= this->object(handle
);
405 return LDPS_BAD_HANDLE
;
407 obj
->unlock(this->task_
);
411 // Add a new input file.
414 Plugin_manager::add_input_file(char *pathname
, bool is_lib
)
416 Input_file_argument
file(pathname
, is_lib
, "", false, this->options_
);
417 Input_argument
* input_argument
= new Input_argument(file
);
418 Task_token
* next_blocker
= new Task_token(true);
419 next_blocker
->add_blocker();
420 if (this->layout_
->incremental_inputs())
421 gold_error(_("Input files added by plug-ins in --incremental mode not "
422 "supported yet.\n"));
423 this->workqueue_
->queue_soon(new Read_symbols(this->input_objects_
,
433 this->this_blocker_
= next_blocker
;
439 Pluginobj::Pluginobj(const std::string
& name
, Input_file
* input_file
,
440 off_t offset
, off_t filesize
)
441 : Object(name
, input_file
, false, offset
),
442 nsyms_(0), syms_(NULL
), symbols_(), filesize_(filesize
), comdat_map_()
446 // Return TRUE if a defined symbol might be reachable from outside the
447 // universe of claimed objects.
450 is_visible_from_outside(Symbol
* lsym
)
452 if (lsym
->in_real_elf())
454 if (parameters
->options().relocatable())
456 if (parameters
->options().export_dynamic() || parameters
->options().shared())
457 return lsym
->is_externally_visible();
461 // Get symbol resolution info.
464 Pluginobj::get_symbol_resolution_info(int nsyms
, ld_plugin_symbol
* syms
) const
466 if (nsyms
> this->nsyms_
)
468 for (int i
= 0; i
< nsyms
; i
++)
470 ld_plugin_symbol
* isym
= &syms
[i
];
471 Symbol
* lsym
= this->symbols_
[i
];
472 ld_plugin_symbol_resolution res
= LDPR_UNKNOWN
;
474 if (lsym
->is_undefined())
475 // The symbol remains undefined.
477 else if (isym
->def
== LDPK_UNDEF
478 || isym
->def
== LDPK_WEAKUNDEF
479 || isym
->def
== LDPK_COMMON
)
481 // The original symbol was undefined or common.
482 if (lsym
->source() != Symbol::FROM_OBJECT
)
483 res
= LDPR_RESOLVED_EXEC
;
484 else if (lsym
->object()->pluginobj() != NULL
)
485 res
= LDPR_RESOLVED_IR
;
486 else if (lsym
->object()->is_dynamic())
487 res
= LDPR_RESOLVED_DYN
;
489 res
= LDPR_RESOLVED_EXEC
;
493 // The original symbol was a definition.
494 if (lsym
->source() != Symbol::FROM_OBJECT
)
495 res
= LDPR_PREEMPTED_REG
;
496 else if (lsym
->object() == static_cast<const Object
*>(this))
497 res
= (is_visible_from_outside(lsym
)
498 ? LDPR_PREVAILING_DEF
499 : LDPR_PREVAILING_DEF_IRONLY
);
501 res
= (lsym
->object()->pluginobj() != NULL
503 : LDPR_PREEMPTED_REG
);
505 isym
->resolution
= res
;
510 // Return TRUE if the comdat group with key COMDAT_KEY from this object
514 Pluginobj::include_comdat_group(std::string comdat_key
, Layout
* layout
)
516 std::pair
<Comdat_map::iterator
, bool> ins
=
517 this->comdat_map_
.insert(std::make_pair(comdat_key
, false));
519 // If this is the first time we've seen this comdat key, ask the
520 // layout object whether it should be included.
522 ins
.first
->second
= layout
->find_or_add_kept_section(comdat_key
,
526 return ins
.first
->second
;
529 // Class Sized_pluginobj.
531 template<int size
, bool big_endian
>
532 Sized_pluginobj
<size
, big_endian
>::Sized_pluginobj(
533 const std::string
& name
,
534 Input_file
* input_file
,
537 : Pluginobj(name
, input_file
, offset
, filesize
)
541 // Read the symbols. Not used for plugin objects.
543 template<int size
, bool big_endian
>
545 Sized_pluginobj
<size
, big_endian
>::do_read_symbols(Read_symbols_data
*)
550 // Lay out the input sections. Not used for plugin objects.
552 template<int size
, bool big_endian
>
554 Sized_pluginobj
<size
, big_endian
>::do_layout(Symbol_table
*, Layout
*,
560 // Add the symbols to the symbol table.
562 template<int size
, bool big_endian
>
564 Sized_pluginobj
<size
, big_endian
>::do_add_symbols(Symbol_table
* symtab
,
568 const int sym_size
= elfcpp::Elf_sizes
<size
>::sym_size
;
569 unsigned char symbuf
[sym_size
];
570 elfcpp::Sym
<size
, big_endian
> sym(symbuf
);
571 elfcpp::Sym_write
<size
, big_endian
> osym(symbuf
);
573 typedef typename
elfcpp::Elf_types
<size
>::Elf_WXword Elf_size_type
;
575 this->symbols_
.resize(this->nsyms_
);
577 for (int i
= 0; i
< this->nsyms_
; ++i
)
579 const struct ld_plugin_symbol
*isym
= &this->syms_
[i
];
580 const char* name
= isym
->name
;
581 const char* ver
= isym
->version
;
582 elfcpp::Elf_Half shndx
;
586 if (name
!= NULL
&& name
[0] == '\0')
588 if (ver
!= NULL
&& ver
[0] == '\0')
595 bind
= elfcpp::STB_WEAK
;
601 bind
= elfcpp::STB_GLOBAL
;
609 shndx
= elfcpp::SHN_ABS
;
612 shndx
= elfcpp::SHN_COMMON
;
617 shndx
= elfcpp::SHN_UNDEF
;
621 switch (isym
->visibility
)
624 vis
= elfcpp::STV_DEFAULT
;
627 vis
= elfcpp::STV_DEFAULT
;
630 vis
= elfcpp::STV_DEFAULT
;
634 vis
= elfcpp::STV_DEFAULT
;
638 if (isym
->comdat_key
!= NULL
639 && isym
->comdat_key
[0] != '\0'
640 && !this->include_comdat_group(isym
->comdat_key
, layout
))
641 shndx
= elfcpp::SHN_UNDEF
;
644 osym
.put_st_value(0);
645 osym
.put_st_size(static_cast<Elf_size_type
>(isym
->size
));
646 osym
.put_st_info(bind
, elfcpp::STT_NOTYPE
);
647 osym
.put_st_other(vis
, 0);
648 osym
.put_st_shndx(shndx
);
651 symtab
->add_from_pluginobj
<size
, big_endian
>(this, name
, ver
, &sym
);
655 // Get the size of a section. Not used for plugin objects.
657 template<int size
, bool big_endian
>
659 Sized_pluginobj
<size
, big_endian
>::do_section_size(unsigned int)
665 // Get the name of a section. Not used for plugin objects.
667 template<int size
, bool big_endian
>
669 Sized_pluginobj
<size
, big_endian
>::do_section_name(unsigned int)
672 return std::string();
675 // Return a view of the contents of a section. Not used for plugin objects.
677 template<int size
, bool big_endian
>
679 Sized_pluginobj
<size
, big_endian
>::do_section_contents(unsigned int)
687 // Return section flags. Not used for plugin objects.
689 template<int size
, bool big_endian
>
691 Sized_pluginobj
<size
, big_endian
>::do_section_flags(unsigned int)
697 // Return section entsize. Not used for plugin objects.
699 template<int size
, bool big_endian
>
701 Sized_pluginobj
<size
, big_endian
>::do_section_entsize(unsigned int)
707 // Return section address. Not used for plugin objects.
709 template<int size
, bool big_endian
>
711 Sized_pluginobj
<size
, big_endian
>::do_section_address(unsigned int)
717 // Return section type. Not used for plugin objects.
719 template<int size
, bool big_endian
>
721 Sized_pluginobj
<size
, big_endian
>::do_section_type(unsigned int)
727 // Return the section link field. Not used for plugin objects.
729 template<int size
, bool big_endian
>
731 Sized_pluginobj
<size
, big_endian
>::do_section_link(unsigned int)
737 // Return the section link field. Not used for plugin objects.
739 template<int size
, bool big_endian
>
741 Sized_pluginobj
<size
, big_endian
>::do_section_info(unsigned int)
747 // Return the section alignment. Not used for plugin objects.
749 template<int size
, bool big_endian
>
751 Sized_pluginobj
<size
, big_endian
>::do_section_addralign(unsigned int)
757 // Return the Xindex structure to use. Not used for plugin objects.
759 template<int size
, bool big_endian
>
761 Sized_pluginobj
<size
, big_endian
>::do_initialize_xindex()
767 // Get symbol counts. Not used for plugin objects.
769 template<int size
, bool big_endian
>
771 Sized_pluginobj
<size
, big_endian
>::do_get_global_symbol_counts(const Symbol_table
*,
772 size_t*, size_t*) const
777 // Class Plugin_finish. This task runs after all replacement files have
778 // been added. It calls each plugin's cleanup handler.
780 class Plugin_finish
: public Task
783 Plugin_finish(Task_token
* this_blocker
, Task_token
* next_blocker
)
784 : this_blocker_(this_blocker
), next_blocker_(next_blocker
)
789 if (this->this_blocker_
!= NULL
)
790 delete this->this_blocker_
;
796 if (this->this_blocker_
!= NULL
&& this->this_blocker_
->is_blocked())
797 return this->this_blocker_
;
802 locks(Task_locker
* tl
)
803 { tl
->add(this, this->next_blocker_
); }
808 Plugin_manager
* plugins
= parameters
->options().plugins();
809 gold_assert(plugins
!= NULL
);
815 { return "Plugin_finish"; }
818 Task_token
* this_blocker_
;
819 Task_token
* next_blocker_
;
822 // Class Plugin_hook.
824 Plugin_hook::~Plugin_hook()
828 // Return whether a Plugin_hook task is runnable.
831 Plugin_hook::is_runnable()
833 if (this->this_blocker_
!= NULL
&& this->this_blocker_
->is_blocked())
834 return this->this_blocker_
;
838 // Return a Task_locker for a Plugin_hook task. We don't need any
842 Plugin_hook::locks(Task_locker
*)
846 // Run the "all symbols read" plugin hook.
849 Plugin_hook::run(Workqueue
* workqueue
)
851 gold_assert(this->options_
.has_plugins());
852 this->options_
.plugins()->all_symbols_read(workqueue
,
854 this->input_objects_
,
859 &this->this_blocker_
);
860 workqueue
->queue_soon(new Plugin_finish(this->this_blocker_
,
861 this->next_blocker_
));
864 // The C interface routines called by the plugins.
866 #ifdef ENABLE_PLUGINS
868 // Register a claim-file handler.
870 static enum ld_plugin_status
871 register_claim_file(ld_plugin_claim_file_handler handler
)
873 gold_assert(parameters
->options().has_plugins());
874 parameters
->options().plugins()->set_claim_file_handler(handler
);
878 // Register an all-symbols-read handler.
880 static enum ld_plugin_status
881 register_all_symbols_read(ld_plugin_all_symbols_read_handler handler
)
883 gold_assert(parameters
->options().has_plugins());
884 parameters
->options().plugins()->set_all_symbols_read_handler(handler
);
888 // Register a cleanup handler.
890 static enum ld_plugin_status
891 register_cleanup(ld_plugin_cleanup_handler handler
)
893 gold_assert(parameters
->options().has_plugins());
894 parameters
->options().plugins()->set_cleanup_handler(handler
);
898 // Add symbols from a plugin-claimed input file.
900 static enum ld_plugin_status
901 add_symbols(void* handle
, int nsyms
, const ld_plugin_symbol
*syms
)
903 gold_assert(parameters
->options().has_plugins());
904 Pluginobj
* obj
= parameters
->options().plugins()->make_plugin_object(
905 static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle
)));
908 obj
->store_incoming_symbols(nsyms
, syms
);
912 // Get the input file information with an open (possibly re-opened)
915 static enum ld_plugin_status
916 get_input_file(const void *handle
, struct ld_plugin_input_file
*file
)
918 gold_assert(parameters
->options().has_plugins());
919 unsigned int obj_index
=
920 static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle
));
921 return parameters
->options().plugins()->get_input_file(obj_index
, file
);
924 // Release the input file.
926 static enum ld_plugin_status
927 release_input_file(const void *handle
)
929 gold_assert(parameters
->options().has_plugins());
930 unsigned int obj_index
=
931 static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle
));
932 return parameters
->options().plugins()->release_input_file(obj_index
);
935 // Get the symbol resolution info for a plugin-claimed input file.
937 static enum ld_plugin_status
938 get_symbols(const void * handle
, int nsyms
, ld_plugin_symbol
* syms
)
940 gold_assert(parameters
->options().has_plugins());
941 Pluginobj
* obj
= parameters
->options().plugins()->object(
942 static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle
)));
945 return obj
->get_symbol_resolution_info(nsyms
, syms
);
948 // Add a new (real) input file generated by a plugin.
950 static enum ld_plugin_status
951 add_input_file(char *pathname
)
953 gold_assert(parameters
->options().has_plugins());
954 return parameters
->options().plugins()->add_input_file(pathname
, false);
957 // Add a new (real) library required by a plugin.
959 static enum ld_plugin_status
960 add_input_library(char *pathname
)
962 gold_assert(parameters
->options().has_plugins());
963 return parameters
->options().plugins()->add_input_file(pathname
, true);
966 // Issue a diagnostic message from a plugin.
968 static enum ld_plugin_status
969 message(int level
, const char * format
, ...)
972 va_start(args
, format
);
977 parameters
->errors()->info(format
, args
);
980 parameters
->errors()->warning(format
, args
);
984 parameters
->errors()->error(format
, args
);
987 parameters
->errors()->fatal(format
, args
);
995 #endif // ENABLE_PLUGINS
997 // Allocate a Pluginobj object of the appropriate size and endianness.
1000 make_sized_plugin_object(Input_file
* input_file
, off_t offset
, off_t filesize
)
1002 Pluginobj
* obj
= NULL
;
1004 parameters_force_valid_target();
1005 const Target
& target(parameters
->target());
1007 if (target
.get_size() == 32)
1009 if (target
.is_big_endian())
1010 #ifdef HAVE_TARGET_32_BIG
1011 obj
= new Sized_pluginobj
<32, true>(input_file
->filename(),
1012 input_file
, offset
, filesize
);
1014 gold_error(_("%s: not configured to support "
1015 "32-bit big-endian object"),
1016 input_file
->filename().c_str());
1019 #ifdef HAVE_TARGET_32_LITTLE
1020 obj
= new Sized_pluginobj
<32, false>(input_file
->filename(),
1021 input_file
, offset
, filesize
);
1023 gold_error(_("%s: not configured to support "
1024 "32-bit little-endian object"),
1025 input_file
->filename().c_str());
1028 else if (target
.get_size() == 64)
1030 if (target
.is_big_endian())
1031 #ifdef HAVE_TARGET_64_BIG
1032 obj
= new Sized_pluginobj
<64, true>(input_file
->filename(),
1033 input_file
, offset
, filesize
);
1035 gold_error(_("%s: not configured to support "
1036 "64-bit big-endian object"),
1037 input_file
->filename().c_str());
1040 #ifdef HAVE_TARGET_64_LITTLE
1041 obj
= new Sized_pluginobj
<64, false>(input_file
->filename(),
1042 input_file
, offset
, filesize
);
1044 gold_error(_("%s: not configured to support "
1045 "64-bit little-endian object"),
1046 input_file
->filename().c_str());
1050 gold_assert(obj
!= NULL
);
1054 } // End namespace gold.