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.
31 #include "parameters.h"
47 // The linker's exported interfaces.
52 static enum ld_plugin_status
53 register_claim_file(ld_plugin_claim_file_handler handler
);
55 static enum ld_plugin_status
56 register_all_symbols_read(ld_plugin_all_symbols_read_handler handler
);
58 static enum ld_plugin_status
59 register_cleanup(ld_plugin_cleanup_handler handler
);
61 static enum ld_plugin_status
62 add_symbols(void *handle
, int nsyms
, const struct ld_plugin_symbol
*syms
);
64 static enum ld_plugin_status
65 get_input_file(const void *handle
, struct ld_plugin_input_file
*file
);
67 static enum ld_plugin_status
68 release_input_file(const void *handle
);
70 static enum ld_plugin_status
71 get_symbols(const void *handle
, int nsyms
, struct ld_plugin_symbol
*syms
);
73 static enum ld_plugin_status
74 add_input_file(char *pathname
);
76 static enum ld_plugin_status
77 add_input_library(char *pathname
);
79 static enum ld_plugin_status
80 message(int level
, const char *format
, ...);
84 #endif // ENABLE_PLUGINS
86 static Pluginobj
* make_sized_plugin_object(Input_file
* input_file
,
87 off_t offset
, off_t filesize
);
91 // Load one plugin library.
97 // Load the plugin library.
98 // FIXME: Look for the library in standard locations.
99 this->handle_
= dlopen(this->filename_
.c_str(), RTLD_NOW
);
100 if (this->handle_
== NULL
)
102 gold_error(_("%s: could not load plugin library"),
103 this->filename_
.c_str());
107 // Find the plugin's onload entry point.
108 ld_plugin_onload onload
= reinterpret_cast<ld_plugin_onload
>
109 (dlsym(this->handle_
, "onload"));
112 gold_error(_("%s: could not find onload entry point"),
113 this->filename_
.c_str());
117 // Get the linker's version number.
118 const char* ver
= get_version_string();
121 sscanf(ver
, "%d.%d", &major
, &minor
);
123 // Allocate and populate a transfer vector.
124 const int tv_fixed_size
= 14;
125 int tv_size
= this->args_
.size() + tv_fixed_size
;
126 ld_plugin_tv
*tv
= new ld_plugin_tv
[tv_size
];
128 // Put LDPT_MESSAGE at the front of the list so the plugin can use it
129 // while processing subsequent entries.
131 tv
[i
].tv_tag
= LDPT_MESSAGE
;
132 tv
[i
].tv_u
.tv_message
= message
;
135 tv
[i
].tv_tag
= LDPT_API_VERSION
;
136 tv
[i
].tv_u
.tv_val
= LD_PLUGIN_API_VERSION
;
139 tv
[i
].tv_tag
= LDPT_GOLD_VERSION
;
140 tv
[i
].tv_u
.tv_val
= major
* 100 + minor
;
143 tv
[i
].tv_tag
= LDPT_LINKER_OUTPUT
;
144 if (parameters
->options().relocatable())
145 tv
[i
].tv_u
.tv_val
= LDPO_REL
;
146 else if (parameters
->options().shared())
147 tv
[i
].tv_u
.tv_val
= LDPO_DYN
;
149 tv
[i
].tv_u
.tv_val
= LDPO_EXEC
;
151 for (unsigned int j
= 0; j
< this->args_
.size(); ++j
)
154 tv
[i
].tv_tag
= LDPT_OPTION
;
155 tv
[i
].tv_u
.tv_string
= this->args_
[j
].c_str();
159 tv
[i
].tv_tag
= LDPT_REGISTER_CLAIM_FILE_HOOK
;
160 tv
[i
].tv_u
.tv_register_claim_file
= register_claim_file
;
163 tv
[i
].tv_tag
= LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK
;
164 tv
[i
].tv_u
.tv_register_all_symbols_read
= register_all_symbols_read
;
167 tv
[i
].tv_tag
= LDPT_REGISTER_CLEANUP_HOOK
;
168 tv
[i
].tv_u
.tv_register_cleanup
= register_cleanup
;
171 tv
[i
].tv_tag
= LDPT_ADD_SYMBOLS
;
172 tv
[i
].tv_u
.tv_add_symbols
= add_symbols
;
175 tv
[i
].tv_tag
= LDPT_GET_INPUT_FILE
;
176 tv
[i
].tv_u
.tv_get_input_file
= get_input_file
;
179 tv
[i
].tv_tag
= LDPT_RELEASE_INPUT_FILE
;
180 tv
[i
].tv_u
.tv_release_input_file
= release_input_file
;
183 tv
[i
].tv_tag
= LDPT_GET_SYMBOLS
;
184 tv
[i
].tv_u
.tv_get_symbols
= get_symbols
;
187 tv
[i
].tv_tag
= LDPT_ADD_INPUT_FILE
;
188 tv
[i
].tv_u
.tv_add_input_file
= add_input_file
;
191 tv
[i
].tv_tag
= LDPT_ADD_INPUT_LIBRARY
;
192 tv
[i
].tv_u
.tv_add_input_library
= add_input_library
;
195 tv
[i
].tv_tag
= LDPT_NULL
;
196 tv
[i
].tv_u
.tv_val
= 0;
198 gold_assert(i
== tv_size
- 1);
200 // Call the onload entry point.
204 #endif // ENABLE_PLUGINS
207 // Call the plugin claim-file handler.
210 Plugin::claim_file(struct ld_plugin_input_file
*plugin_input_file
)
214 if (this->claim_file_handler_
!= NULL
)
216 (*this->claim_file_handler_
)(plugin_input_file
, &claimed
);
223 // Call the all-symbols-read handler.
226 Plugin::all_symbols_read()
228 if (this->all_symbols_read_handler_
!= NULL
)
229 (*this->all_symbols_read_handler_
)();
232 // Call the cleanup handler.
237 if (this->cleanup_handler_
!= NULL
)
238 (*this->cleanup_handler_
)();
241 // Plugin_manager methods.
243 Plugin_manager::~Plugin_manager()
245 for (Plugin_list::iterator p
= this->plugins_
.begin();
246 p
!= this->plugins_
.end();
249 this->plugins_
.clear();
250 for (Object_list::iterator obj
= this->objects_
.begin();
251 obj
!= this->objects_
.end();
254 this->objects_
.clear();
257 // Load all plugin libraries.
260 Plugin_manager::load_plugins()
262 for (this->current_
= this->plugins_
.begin();
263 this->current_
!= this->plugins_
.end();
265 (*this->current_
)->load();
268 // Call the plugin claim-file handlers in turn to see if any claim the file.
271 Plugin_manager::claim_file(Input_file
* input_file
, off_t offset
,
274 if (this->in_replacement_phase_
)
277 unsigned int handle
= this->objects_
.size();
278 this->input_file_
= input_file
;
279 this->plugin_input_file_
.name
= input_file
->filename().c_str();
280 this->plugin_input_file_
.fd
= input_file
->file().descriptor();
281 this->plugin_input_file_
.offset
= offset
;
282 this->plugin_input_file_
.filesize
= filesize
;
283 this->plugin_input_file_
.handle
= reinterpret_cast<void*>(handle
);
285 for (this->current_
= this->plugins_
.begin();
286 this->current_
!= this->plugins_
.end();
289 if ((*this->current_
)->claim_file(&this->plugin_input_file_
))
291 if (this->objects_
.size() > handle
)
292 return this->objects_
[handle
];
294 // If the plugin claimed the file but did not call the
295 // add_symbols callback, we need to create the Pluginobj now.
296 Pluginobj
* obj
= this->make_plugin_object(handle
);
304 // Call the all-symbols-read handlers.
307 Plugin_manager::all_symbols_read(Workqueue
* workqueue
, Task
* task
,
308 Input_objects
* input_objects
,
309 Symbol_table
* symtab
, Layout
* layout
,
310 Dirsearch
* dirpath
, Mapfile
* mapfile
,
311 Task_token
** last_blocker
)
313 this->in_replacement_phase_
= true;
314 this->workqueue_
= workqueue
;
316 this->input_objects_
= input_objects
;
317 this->symtab_
= symtab
;
318 this->layout_
= layout
;
319 this->dirpath_
= dirpath
;
320 this->mapfile_
= mapfile
;
321 this->this_blocker_
= NULL
;
323 for (this->current_
= this->plugins_
.begin();
324 this->current_
!= this->plugins_
.end();
326 (*this->current_
)->all_symbols_read();
328 *last_blocker
= this->this_blocker_
;
331 // Layout deferred objects.
334 Plugin_manager::layout_deferred_objects()
336 Deferred_layout_list::iterator obj
;
338 for (obj
= this->deferred_layout_objects_
.begin();
339 obj
!= this->deferred_layout_objects_
.end();
341 (*obj
)->layout_deferred_sections(this->layout_
);
344 // Call the cleanup handlers.
347 Plugin_manager::cleanup()
349 if (this->cleanup_done_
)
351 for (this->current_
= this->plugins_
.begin();
352 this->current_
!= this->plugins_
.end();
354 (*this->current_
)->cleanup();
355 this->cleanup_done_
= true;
358 // Make a new Pluginobj object. This is called when the plugin calls
359 // the add_symbols API.
362 Plugin_manager::make_plugin_object(unsigned int handle
)
364 // Make sure we aren't asked to make an object for the same handle twice.
365 if (this->objects_
.size() != handle
)
368 Pluginobj
* obj
= make_sized_plugin_object(this->input_file_
,
369 this->plugin_input_file_
.offset
,
370 this->plugin_input_file_
.filesize
);
371 this->objects_
.push_back(obj
);
375 // Get the input file information with an open (possibly re-opened)
379 Plugin_manager::get_input_file(unsigned int handle
,
380 struct ld_plugin_input_file
*file
)
382 Pluginobj
* obj
= this->object(handle
);
384 return LDPS_BAD_HANDLE
;
386 obj
->lock(this->task_
);
387 file
->name
= obj
->filename().c_str();
388 file
->fd
= obj
->descriptor();
389 file
->offset
= obj
->offset();
390 file
->filesize
= obj
->filesize();
391 file
->handle
= reinterpret_cast<void*>(handle
);
395 // Release the input file.
398 Plugin_manager::release_input_file(unsigned int handle
)
400 Pluginobj
* obj
= this->object(handle
);
402 return LDPS_BAD_HANDLE
;
404 obj
->unlock(this->task_
);
408 // Add a new input file.
411 Plugin_manager::add_input_file(char *pathname
, bool is_lib
)
413 Input_file_argument
file(pathname
, is_lib
, "", false, this->options_
);
414 Input_argument
* input_argument
= new Input_argument(file
);
415 Task_token
* next_blocker
= new Task_token(true);
416 next_blocker
->add_blocker();
417 if (this->layout_
->incremental_inputs())
418 gold_error(_("Input files added by plug-ins in --incremental mode not "
419 "supported yet.\n"));
420 this->workqueue_
->queue_soon(new Read_symbols(this->input_objects_
,
430 this->this_blocker_
= next_blocker
;
436 Pluginobj::Pluginobj(const std::string
& name
, Input_file
* input_file
,
437 off_t offset
, off_t filesize
)
438 : Object(name
, input_file
, false, offset
),
439 nsyms_(0), syms_(NULL
), symbols_(), filesize_(filesize
), comdat_map_()
443 // Return TRUE if a defined symbol might be reachable from outside the
444 // universe of claimed objects.
447 is_visible_from_outside(Symbol
* lsym
)
449 if (lsym
->in_real_elf())
451 if (parameters
->options().relocatable())
453 if (parameters
->options().export_dynamic() || parameters
->options().shared())
454 return lsym
->is_externally_visible();
458 // Get symbol resolution info.
461 Pluginobj::get_symbol_resolution_info(int nsyms
, ld_plugin_symbol
* syms
) const
463 if (nsyms
> this->nsyms_
)
465 for (int i
= 0; i
< nsyms
; i
++)
467 ld_plugin_symbol
* isym
= &syms
[i
];
468 Symbol
* lsym
= this->symbols_
[i
];
469 ld_plugin_symbol_resolution res
= LDPR_UNKNOWN
;
471 if (lsym
->is_undefined())
472 // The symbol remains undefined.
474 else if (isym
->def
== LDPK_UNDEF
475 || isym
->def
== LDPK_WEAKUNDEF
476 || isym
->def
== LDPK_COMMON
)
478 // The original symbol was undefined or common.
479 if (lsym
->source() != Symbol::FROM_OBJECT
)
480 res
= LDPR_RESOLVED_EXEC
;
481 else if (lsym
->object()->pluginobj() != NULL
)
482 res
= LDPR_RESOLVED_IR
;
483 else if (lsym
->object()->is_dynamic())
484 res
= LDPR_RESOLVED_DYN
;
486 res
= LDPR_RESOLVED_EXEC
;
490 // The original symbol was a definition.
491 if (lsym
->source() != Symbol::FROM_OBJECT
)
492 res
= LDPR_PREEMPTED_REG
;
493 else if (lsym
->object() == static_cast<const Object
*>(this))
494 res
= (is_visible_from_outside(lsym
)
495 ? LDPR_PREVAILING_DEF
496 : LDPR_PREVAILING_DEF_IRONLY
);
498 res
= (lsym
->object()->pluginobj() != NULL
500 : LDPR_PREEMPTED_REG
);
502 isym
->resolution
= res
;
507 // Return TRUE if the comdat group with key COMDAT_KEY from this object
511 Pluginobj::include_comdat_group(std::string comdat_key
, Layout
* layout
)
513 std::pair
<Comdat_map::iterator
, bool> ins
=
514 this->comdat_map_
.insert(std::make_pair(comdat_key
, false));
516 // If this is the first time we've seen this comdat key, ask the
517 // layout object whether it should be included.
519 ins
.first
->second
= layout
->find_or_add_kept_section(comdat_key
,
523 return ins
.first
->second
;
526 // Class Sized_pluginobj.
528 template<int size
, bool big_endian
>
529 Sized_pluginobj
<size
, big_endian
>::Sized_pluginobj(
530 const std::string
& name
,
531 Input_file
* input_file
,
534 : Pluginobj(name
, input_file
, offset
, filesize
)
538 // Read the symbols. Not used for plugin objects.
540 template<int size
, bool big_endian
>
542 Sized_pluginobj
<size
, big_endian
>::do_read_symbols(Read_symbols_data
*)
547 // Lay out the input sections. Not used for plugin objects.
549 template<int size
, bool big_endian
>
551 Sized_pluginobj
<size
, big_endian
>::do_layout(Symbol_table
*, Layout
*,
557 // Add the symbols to the symbol table.
559 template<int size
, bool big_endian
>
561 Sized_pluginobj
<size
, big_endian
>::do_add_symbols(Symbol_table
* symtab
,
565 const int sym_size
= elfcpp::Elf_sizes
<size
>::sym_size
;
566 unsigned char symbuf
[sym_size
];
567 elfcpp::Sym
<size
, big_endian
> sym(symbuf
);
568 elfcpp::Sym_write
<size
, big_endian
> osym(symbuf
);
570 typedef typename
elfcpp::Elf_types
<size
>::Elf_WXword Elf_size_type
;
572 this->symbols_
.resize(this->nsyms_
);
574 for (int i
= 0; i
< this->nsyms_
; ++i
)
576 const struct ld_plugin_symbol
*isym
= &this->syms_
[i
];
577 const char* name
= isym
->name
;
578 const char* ver
= isym
->version
;
579 elfcpp::Elf_Half shndx
;
583 if (name
!= NULL
&& name
[0] == '\0')
585 if (ver
!= NULL
&& ver
[0] == '\0')
592 bind
= elfcpp::STB_WEAK
;
598 bind
= elfcpp::STB_GLOBAL
;
606 shndx
= elfcpp::SHN_ABS
;
609 shndx
= elfcpp::SHN_COMMON
;
614 shndx
= elfcpp::SHN_UNDEF
;
618 switch (isym
->visibility
)
621 vis
= elfcpp::STV_DEFAULT
;
624 vis
= elfcpp::STV_DEFAULT
;
627 vis
= elfcpp::STV_DEFAULT
;
631 vis
= elfcpp::STV_DEFAULT
;
635 if (isym
->comdat_key
!= NULL
636 && isym
->comdat_key
[0] != '\0'
637 && !this->include_comdat_group(isym
->comdat_key
, layout
))
638 shndx
= elfcpp::SHN_UNDEF
;
641 osym
.put_st_value(0);
642 osym
.put_st_size(static_cast<Elf_size_type
>(isym
->size
));
643 osym
.put_st_info(bind
, elfcpp::STT_NOTYPE
);
644 osym
.put_st_other(vis
, 0);
645 osym
.put_st_shndx(shndx
);
648 symtab
->add_from_pluginobj
<size
, big_endian
>(this, name
, ver
, &sym
);
652 // Get the size of a section. Not used for plugin objects.
654 template<int size
, bool big_endian
>
656 Sized_pluginobj
<size
, big_endian
>::do_section_size(unsigned int)
662 // Get the name of a section. Not used for plugin objects.
664 template<int size
, bool big_endian
>
666 Sized_pluginobj
<size
, big_endian
>::do_section_name(unsigned int)
669 return std::string();
672 // Return a view of the contents of a section. Not used for plugin objects.
674 template<int size
, bool big_endian
>
676 Sized_pluginobj
<size
, big_endian
>::do_section_contents(unsigned int)
684 // Return section flags. Not used for plugin objects.
686 template<int size
, bool big_endian
>
688 Sized_pluginobj
<size
, big_endian
>::do_section_flags(unsigned int)
694 // Return section entsize. Not used for plugin objects.
696 template<int size
, bool big_endian
>
698 Sized_pluginobj
<size
, big_endian
>::do_section_entsize(unsigned int)
704 // Return section address. Not used for plugin objects.
706 template<int size
, bool big_endian
>
708 Sized_pluginobj
<size
, big_endian
>::do_section_address(unsigned int)
714 // Return section type. Not used for plugin objects.
716 template<int size
, bool big_endian
>
718 Sized_pluginobj
<size
, big_endian
>::do_section_type(unsigned int)
724 // Return the section link field. Not used for plugin objects.
726 template<int size
, bool big_endian
>
728 Sized_pluginobj
<size
, big_endian
>::do_section_link(unsigned int)
734 // Return the section link field. Not used for plugin objects.
736 template<int size
, bool big_endian
>
738 Sized_pluginobj
<size
, big_endian
>::do_section_info(unsigned int)
744 // Return the section alignment. Not used for plugin objects.
746 template<int size
, bool big_endian
>
748 Sized_pluginobj
<size
, big_endian
>::do_section_addralign(unsigned int)
754 // Return the Xindex structure to use. Not used for plugin objects.
756 template<int size
, bool big_endian
>
758 Sized_pluginobj
<size
, big_endian
>::do_initialize_xindex()
764 // Get symbol counts. Not used for plugin objects.
766 template<int size
, bool big_endian
>
768 Sized_pluginobj
<size
, big_endian
>::do_get_global_symbol_counts(const Symbol_table
*,
769 size_t*, size_t*) const
774 // Class Plugin_finish. This task runs after all replacement files have
775 // been added. It calls each plugin's cleanup handler.
777 class Plugin_finish
: public Task
780 Plugin_finish(Task_token
* this_blocker
, Task_token
* next_blocker
)
781 : this_blocker_(this_blocker
), next_blocker_(next_blocker
)
786 if (this->this_blocker_
!= NULL
)
787 delete this->this_blocker_
;
793 if (this->this_blocker_
!= NULL
&& this->this_blocker_
->is_blocked())
794 return this->this_blocker_
;
799 locks(Task_locker
* tl
)
800 { tl
->add(this, this->next_blocker_
); }
805 Plugin_manager
* plugins
= parameters
->options().plugins();
806 gold_assert(plugins
!= NULL
);
812 { return "Plugin_finish"; }
815 Task_token
* this_blocker_
;
816 Task_token
* next_blocker_
;
819 // Class Plugin_hook.
821 Plugin_hook::~Plugin_hook()
825 // Return whether a Plugin_hook task is runnable.
828 Plugin_hook::is_runnable()
830 if (this->this_blocker_
!= NULL
&& this->this_blocker_
->is_blocked())
831 return this->this_blocker_
;
835 // Return a Task_locker for a Plugin_hook task. We don't need any
839 Plugin_hook::locks(Task_locker
*)
843 // Run the "all symbols read" plugin hook.
846 Plugin_hook::run(Workqueue
* workqueue
)
848 gold_assert(this->options_
.has_plugins());
849 this->options_
.plugins()->all_symbols_read(workqueue
,
851 this->input_objects_
,
856 &this->this_blocker_
);
857 workqueue
->queue_soon(new Plugin_finish(this->this_blocker_
,
858 this->next_blocker_
));
861 // The C interface routines called by the plugins.
863 #ifdef ENABLE_PLUGINS
865 // Register a claim-file handler.
867 static enum ld_plugin_status
868 register_claim_file(ld_plugin_claim_file_handler handler
)
870 gold_assert(parameters
->options().has_plugins());
871 parameters
->options().plugins()->set_claim_file_handler(handler
);
875 // Register an all-symbols-read handler.
877 static enum ld_plugin_status
878 register_all_symbols_read(ld_plugin_all_symbols_read_handler handler
)
880 gold_assert(parameters
->options().has_plugins());
881 parameters
->options().plugins()->set_all_symbols_read_handler(handler
);
885 // Register a cleanup handler.
887 static enum ld_plugin_status
888 register_cleanup(ld_plugin_cleanup_handler handler
)
890 gold_assert(parameters
->options().has_plugins());
891 parameters
->options().plugins()->set_cleanup_handler(handler
);
895 // Add symbols from a plugin-claimed input file.
897 static enum ld_plugin_status
898 add_symbols(void* handle
, int nsyms
, const ld_plugin_symbol
*syms
)
900 gold_assert(parameters
->options().has_plugins());
901 Pluginobj
* obj
= parameters
->options().plugins()->make_plugin_object(
902 static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle
)));
905 obj
->store_incoming_symbols(nsyms
, syms
);
909 // Get the input file information with an open (possibly re-opened)
912 static enum ld_plugin_status
913 get_input_file(const void *handle
, struct ld_plugin_input_file
*file
)
915 gold_assert(parameters
->options().has_plugins());
916 unsigned int obj_index
=
917 static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle
));
918 return parameters
->options().plugins()->get_input_file(obj_index
, file
);
921 // Release the input file.
923 static enum ld_plugin_status
924 release_input_file(const void *handle
)
926 gold_assert(parameters
->options().has_plugins());
927 unsigned int obj_index
=
928 static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle
));
929 return parameters
->options().plugins()->release_input_file(obj_index
);
932 // Get the symbol resolution info for a plugin-claimed input file.
934 static enum ld_plugin_status
935 get_symbols(const void * handle
, int nsyms
, ld_plugin_symbol
* syms
)
937 gold_assert(parameters
->options().has_plugins());
938 Pluginobj
* obj
= parameters
->options().plugins()->object(
939 static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle
)));
942 return obj
->get_symbol_resolution_info(nsyms
, syms
);
945 // Add a new (real) input file generated by a plugin.
947 static enum ld_plugin_status
948 add_input_file(char *pathname
)
950 gold_assert(parameters
->options().has_plugins());
951 return parameters
->options().plugins()->add_input_file(pathname
, false);
954 // Add a new (real) library required by a plugin.
956 static enum ld_plugin_status
957 add_input_library(char *pathname
)
959 gold_assert(parameters
->options().has_plugins());
960 return parameters
->options().plugins()->add_input_file(pathname
, true);
963 // Issue a diagnostic message from a plugin.
965 static enum ld_plugin_status
966 message(int level
, const char * format
, ...)
969 va_start(args
, format
);
974 parameters
->errors()->info(format
, args
);
977 parameters
->errors()->warning(format
, args
);
981 parameters
->errors()->error(format
, args
);
984 parameters
->errors()->fatal(format
, args
);
992 #endif // ENABLE_PLUGINS
994 // Allocate a Pluginobj object of the appropriate size and endianness.
997 make_sized_plugin_object(Input_file
* input_file
, off_t offset
, off_t filesize
)
999 Pluginobj
* obj
= NULL
;
1001 parameters_force_valid_target();
1002 const Target
& target(parameters
->target());
1004 if (target
.get_size() == 32)
1006 if (target
.is_big_endian())
1007 #ifdef HAVE_TARGET_32_BIG
1008 obj
= new Sized_pluginobj
<32, true>(input_file
->filename(),
1009 input_file
, offset
, filesize
);
1011 gold_error(_("%s: not configured to support "
1012 "32-bit big-endian object"),
1013 input_file
->filename().c_str());
1016 #ifdef HAVE_TARGET_32_LITTLE
1017 obj
= new Sized_pluginobj
<32, false>(input_file
->filename(),
1018 input_file
, offset
, filesize
);
1020 gold_error(_("%s: not configured to support "
1021 "32-bit little-endian object"),
1022 input_file
->filename().c_str());
1025 else if (target
.get_size() == 64)
1027 if (target
.is_big_endian())
1028 #ifdef HAVE_TARGET_64_BIG
1029 obj
= new Sized_pluginobj
<64, true>(input_file
->filename(),
1030 input_file
, offset
, filesize
);
1032 gold_error(_("%s: not configured to support "
1033 "64-bit big-endian object"),
1034 input_file
->filename().c_str());
1037 #ifdef HAVE_TARGET_64_LITTLE
1038 obj
= new Sized_pluginobj
<64, false>(input_file
->filename(),
1039 input_file
, offset
, filesize
);
1041 gold_error(_("%s: not configured to support "
1042 "64-bit little-endian object"),
1043 input_file
->filename().c_str());
1047 gold_assert(obj
!= NULL
);
1051 } // End namespace gold.