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
,
418 ? Input_file_argument::INPUT_FILE_TYPE_LIBRARY
419 : Input_file_argument::INPUT_FILE_TYPE_FILE
),
420 "", false, this->options_
);
421 Input_argument
* input_argument
= new Input_argument(file
);
422 Task_token
* next_blocker
= new Task_token(true);
423 next_blocker
->add_blocker();
424 if (this->layout_
->incremental_inputs())
425 gold_error(_("Input files added by plug-ins in --incremental mode not "
426 "supported yet.\n"));
427 this->workqueue_
->queue_soon(new Read_symbols(this->input_objects_
,
437 this->this_blocker_
= next_blocker
;
443 Pluginobj::Pluginobj(const std::string
& name
, Input_file
* input_file
,
444 off_t offset
, off_t filesize
)
445 : Object(name
, input_file
, false, offset
),
446 nsyms_(0), syms_(NULL
), symbols_(), filesize_(filesize
), comdat_map_()
450 // Return TRUE if a defined symbol might be reachable from outside the
451 // universe of claimed objects.
454 is_visible_from_outside(Symbol
* lsym
)
456 if (lsym
->in_real_elf())
458 if (parameters
->options().relocatable())
460 if (parameters
->options().export_dynamic() || parameters
->options().shared())
461 return lsym
->is_externally_visible();
465 // Get symbol resolution info.
468 Pluginobj::get_symbol_resolution_info(int nsyms
, ld_plugin_symbol
* syms
) const
470 if (nsyms
> this->nsyms_
)
472 for (int i
= 0; i
< nsyms
; i
++)
474 ld_plugin_symbol
* isym
= &syms
[i
];
475 Symbol
* lsym
= this->symbols_
[i
];
476 ld_plugin_symbol_resolution res
= LDPR_UNKNOWN
;
478 if (lsym
->is_undefined())
479 // The symbol remains undefined.
481 else if (isym
->def
== LDPK_UNDEF
482 || isym
->def
== LDPK_WEAKUNDEF
483 || isym
->def
== LDPK_COMMON
)
485 // The original symbol was undefined or common.
486 if (lsym
->source() != Symbol::FROM_OBJECT
)
487 res
= LDPR_RESOLVED_EXEC
;
488 else if (lsym
->object()->pluginobj() != NULL
)
489 res
= LDPR_RESOLVED_IR
;
490 else if (lsym
->object()->is_dynamic())
491 res
= LDPR_RESOLVED_DYN
;
493 res
= LDPR_RESOLVED_EXEC
;
497 // The original symbol was a definition.
498 if (lsym
->source() != Symbol::FROM_OBJECT
)
499 res
= LDPR_PREEMPTED_REG
;
500 else if (lsym
->object() == static_cast<const Object
*>(this))
501 res
= (is_visible_from_outside(lsym
)
502 ? LDPR_PREVAILING_DEF
503 : LDPR_PREVAILING_DEF_IRONLY
);
505 res
= (lsym
->object()->pluginobj() != NULL
507 : LDPR_PREEMPTED_REG
);
509 isym
->resolution
= res
;
514 // Return TRUE if the comdat group with key COMDAT_KEY from this object
518 Pluginobj::include_comdat_group(std::string comdat_key
, Layout
* layout
)
520 std::pair
<Comdat_map::iterator
, bool> ins
=
521 this->comdat_map_
.insert(std::make_pair(comdat_key
, false));
523 // If this is the first time we've seen this comdat key, ask the
524 // layout object whether it should be included.
526 ins
.first
->second
= layout
->find_or_add_kept_section(comdat_key
,
530 return ins
.first
->second
;
533 // Class Sized_pluginobj.
535 template<int size
, bool big_endian
>
536 Sized_pluginobj
<size
, big_endian
>::Sized_pluginobj(
537 const std::string
& name
,
538 Input_file
* input_file
,
541 : Pluginobj(name
, input_file
, offset
, filesize
)
545 // Read the symbols. Not used for plugin objects.
547 template<int size
, bool big_endian
>
549 Sized_pluginobj
<size
, big_endian
>::do_read_symbols(Read_symbols_data
*)
554 // Lay out the input sections. Not used for plugin objects.
556 template<int size
, bool big_endian
>
558 Sized_pluginobj
<size
, big_endian
>::do_layout(Symbol_table
*, Layout
*,
564 // Add the symbols to the symbol table.
566 template<int size
, bool big_endian
>
568 Sized_pluginobj
<size
, big_endian
>::do_add_symbols(Symbol_table
* symtab
,
572 const int sym_size
= elfcpp::Elf_sizes
<size
>::sym_size
;
573 unsigned char symbuf
[sym_size
];
574 elfcpp::Sym
<size
, big_endian
> sym(symbuf
);
575 elfcpp::Sym_write
<size
, big_endian
> osym(symbuf
);
577 typedef typename
elfcpp::Elf_types
<size
>::Elf_WXword Elf_size_type
;
579 this->symbols_
.resize(this->nsyms_
);
581 for (int i
= 0; i
< this->nsyms_
; ++i
)
583 const struct ld_plugin_symbol
*isym
= &this->syms_
[i
];
584 const char* name
= isym
->name
;
585 const char* ver
= isym
->version
;
586 elfcpp::Elf_Half shndx
;
590 if (name
!= NULL
&& name
[0] == '\0')
592 if (ver
!= NULL
&& ver
[0] == '\0')
599 bind
= elfcpp::STB_WEAK
;
605 bind
= elfcpp::STB_GLOBAL
;
613 shndx
= elfcpp::SHN_ABS
;
616 shndx
= elfcpp::SHN_COMMON
;
621 shndx
= elfcpp::SHN_UNDEF
;
625 switch (isym
->visibility
)
628 vis
= elfcpp::STV_DEFAULT
;
631 vis
= elfcpp::STV_DEFAULT
;
634 vis
= elfcpp::STV_DEFAULT
;
638 vis
= elfcpp::STV_DEFAULT
;
642 if (isym
->comdat_key
!= NULL
643 && isym
->comdat_key
[0] != '\0'
644 && !this->include_comdat_group(isym
->comdat_key
, layout
))
645 shndx
= elfcpp::SHN_UNDEF
;
648 osym
.put_st_value(0);
649 osym
.put_st_size(static_cast<Elf_size_type
>(isym
->size
));
650 osym
.put_st_info(bind
, elfcpp::STT_NOTYPE
);
651 osym
.put_st_other(vis
, 0);
652 osym
.put_st_shndx(shndx
);
655 symtab
->add_from_pluginobj
<size
, big_endian
>(this, name
, ver
, &sym
);
659 // Get the size of a section. Not used for plugin objects.
661 template<int size
, bool big_endian
>
663 Sized_pluginobj
<size
, big_endian
>::do_section_size(unsigned int)
669 // Get the name of a section. Not used for plugin objects.
671 template<int size
, bool big_endian
>
673 Sized_pluginobj
<size
, big_endian
>::do_section_name(unsigned int)
676 return std::string();
679 // Return a view of the contents of a section. Not used for plugin objects.
681 template<int size
, bool big_endian
>
683 Sized_pluginobj
<size
, big_endian
>::do_section_contents(unsigned int)
691 // Return section flags. Not used for plugin objects.
693 template<int size
, bool big_endian
>
695 Sized_pluginobj
<size
, big_endian
>::do_section_flags(unsigned int)
701 // Return section entsize. Not used for plugin objects.
703 template<int size
, bool big_endian
>
705 Sized_pluginobj
<size
, big_endian
>::do_section_entsize(unsigned int)
711 // Return section address. Not used for plugin objects.
713 template<int size
, bool big_endian
>
715 Sized_pluginobj
<size
, big_endian
>::do_section_address(unsigned int)
721 // Return section type. Not used for plugin objects.
723 template<int size
, bool big_endian
>
725 Sized_pluginobj
<size
, big_endian
>::do_section_type(unsigned int)
731 // Return the section link field. Not used for plugin objects.
733 template<int size
, bool big_endian
>
735 Sized_pluginobj
<size
, big_endian
>::do_section_link(unsigned int)
741 // Return the section link field. Not used for plugin objects.
743 template<int size
, bool big_endian
>
745 Sized_pluginobj
<size
, big_endian
>::do_section_info(unsigned int)
751 // Return the section alignment. Not used for plugin objects.
753 template<int size
, bool big_endian
>
755 Sized_pluginobj
<size
, big_endian
>::do_section_addralign(unsigned int)
761 // Return the Xindex structure to use. Not used for plugin objects.
763 template<int size
, bool big_endian
>
765 Sized_pluginobj
<size
, big_endian
>::do_initialize_xindex()
771 // Get symbol counts. Not used for plugin objects.
773 template<int size
, bool big_endian
>
775 Sized_pluginobj
<size
, big_endian
>::do_get_global_symbol_counts(const Symbol_table
*,
776 size_t*, size_t*) const
781 // Class Plugin_finish. This task runs after all replacement files have
782 // been added. It calls each plugin's cleanup handler.
784 class Plugin_finish
: public Task
787 Plugin_finish(Task_token
* this_blocker
, Task_token
* next_blocker
)
788 : this_blocker_(this_blocker
), next_blocker_(next_blocker
)
793 if (this->this_blocker_
!= NULL
)
794 delete this->this_blocker_
;
800 if (this->this_blocker_
!= NULL
&& this->this_blocker_
->is_blocked())
801 return this->this_blocker_
;
806 locks(Task_locker
* tl
)
807 { tl
->add(this, this->next_blocker_
); }
812 Plugin_manager
* plugins
= parameters
->options().plugins();
813 gold_assert(plugins
!= NULL
);
819 { return "Plugin_finish"; }
822 Task_token
* this_blocker_
;
823 Task_token
* next_blocker_
;
826 // Class Plugin_hook.
828 Plugin_hook::~Plugin_hook()
832 // Return whether a Plugin_hook task is runnable.
835 Plugin_hook::is_runnable()
837 if (this->this_blocker_
!= NULL
&& this->this_blocker_
->is_blocked())
838 return this->this_blocker_
;
842 // Return a Task_locker for a Plugin_hook task. We don't need any
846 Plugin_hook::locks(Task_locker
*)
850 // Run the "all symbols read" plugin hook.
853 Plugin_hook::run(Workqueue
* workqueue
)
855 gold_assert(this->options_
.has_plugins());
856 this->options_
.plugins()->all_symbols_read(workqueue
,
858 this->input_objects_
,
863 &this->this_blocker_
);
864 workqueue
->queue_soon(new Plugin_finish(this->this_blocker_
,
865 this->next_blocker_
));
868 // The C interface routines called by the plugins.
870 #ifdef ENABLE_PLUGINS
872 // Register a claim-file handler.
874 static enum ld_plugin_status
875 register_claim_file(ld_plugin_claim_file_handler handler
)
877 gold_assert(parameters
->options().has_plugins());
878 parameters
->options().plugins()->set_claim_file_handler(handler
);
882 // Register an all-symbols-read handler.
884 static enum ld_plugin_status
885 register_all_symbols_read(ld_plugin_all_symbols_read_handler handler
)
887 gold_assert(parameters
->options().has_plugins());
888 parameters
->options().plugins()->set_all_symbols_read_handler(handler
);
892 // Register a cleanup handler.
894 static enum ld_plugin_status
895 register_cleanup(ld_plugin_cleanup_handler handler
)
897 gold_assert(parameters
->options().has_plugins());
898 parameters
->options().plugins()->set_cleanup_handler(handler
);
902 // Add symbols from a plugin-claimed input file.
904 static enum ld_plugin_status
905 add_symbols(void* handle
, int nsyms
, const ld_plugin_symbol
*syms
)
907 gold_assert(parameters
->options().has_plugins());
908 Pluginobj
* obj
= parameters
->options().plugins()->make_plugin_object(
909 static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle
)));
912 obj
->store_incoming_symbols(nsyms
, syms
);
916 // Get the input file information with an open (possibly re-opened)
919 static enum ld_plugin_status
920 get_input_file(const void *handle
, struct ld_plugin_input_file
*file
)
922 gold_assert(parameters
->options().has_plugins());
923 unsigned int obj_index
=
924 static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle
));
925 return parameters
->options().plugins()->get_input_file(obj_index
, file
);
928 // Release the input file.
930 static enum ld_plugin_status
931 release_input_file(const void *handle
)
933 gold_assert(parameters
->options().has_plugins());
934 unsigned int obj_index
=
935 static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle
));
936 return parameters
->options().plugins()->release_input_file(obj_index
);
939 // Get the symbol resolution info for a plugin-claimed input file.
941 static enum ld_plugin_status
942 get_symbols(const void * handle
, int nsyms
, ld_plugin_symbol
* syms
)
944 gold_assert(parameters
->options().has_plugins());
945 Pluginobj
* obj
= parameters
->options().plugins()->object(
946 static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle
)));
949 return obj
->get_symbol_resolution_info(nsyms
, syms
);
952 // Add a new (real) input file generated by a plugin.
954 static enum ld_plugin_status
955 add_input_file(char *pathname
)
957 gold_assert(parameters
->options().has_plugins());
958 return parameters
->options().plugins()->add_input_file(pathname
, false);
961 // Add a new (real) library required by a plugin.
963 static enum ld_plugin_status
964 add_input_library(char *pathname
)
966 gold_assert(parameters
->options().has_plugins());
967 return parameters
->options().plugins()->add_input_file(pathname
, true);
970 // Issue a diagnostic message from a plugin.
972 static enum ld_plugin_status
973 message(int level
, const char * format
, ...)
976 va_start(args
, format
);
981 parameters
->errors()->info(format
, args
);
984 parameters
->errors()->warning(format
, args
);
988 parameters
->errors()->error(format
, args
);
991 parameters
->errors()->fatal(format
, args
);
999 #endif // ENABLE_PLUGINS
1001 // Allocate a Pluginobj object of the appropriate size and endianness.
1004 make_sized_plugin_object(Input_file
* input_file
, off_t offset
, off_t filesize
)
1006 Pluginobj
* obj
= NULL
;
1008 parameters_force_valid_target();
1009 const Target
& target(parameters
->target());
1011 if (target
.get_size() == 32)
1013 if (target
.is_big_endian())
1014 #ifdef HAVE_TARGET_32_BIG
1015 obj
= new Sized_pluginobj
<32, true>(input_file
->filename(),
1016 input_file
, offset
, filesize
);
1018 gold_error(_("%s: not configured to support "
1019 "32-bit big-endian object"),
1020 input_file
->filename().c_str());
1023 #ifdef HAVE_TARGET_32_LITTLE
1024 obj
= new Sized_pluginobj
<32, false>(input_file
->filename(),
1025 input_file
, offset
, filesize
);
1027 gold_error(_("%s: not configured to support "
1028 "32-bit little-endian object"),
1029 input_file
->filename().c_str());
1032 else if (target
.get_size() == 64)
1034 if (target
.is_big_endian())
1035 #ifdef HAVE_TARGET_64_BIG
1036 obj
= new Sized_pluginobj
<64, true>(input_file
->filename(),
1037 input_file
, offset
, filesize
);
1039 gold_error(_("%s: not configured to support "
1040 "64-bit big-endian object"),
1041 input_file
->filename().c_str());
1044 #ifdef HAVE_TARGET_64_LITTLE
1045 obj
= new Sized_pluginobj
<64, false>(input_file
->filename(),
1046 input_file
, offset
, filesize
);
1048 gold_error(_("%s: not configured to support "
1049 "64-bit little-endian object"),
1050 input_file
->filename().c_str());
1054 gold_assert(obj
!= NULL
);
1058 } // End namespace gold.