aboutsummaryrefslogtreecommitdiff
path: root/bfd/plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/plugin.c')
-rw-r--r--bfd/plugin.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/bfd/plugin.c b/bfd/plugin.c
index 1c72b74..733e7f0 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -138,6 +138,14 @@ struct plugin_list_entry
const char *plugin_name;
};
+struct plugin_data_struct
+{
+ int nsyms;
+ const struct ld_plugin_symbol *syms;
+ int object_only_nsyms;
+ asymbol **object_only_syms;
+};
+
static const char *plugin_program_name;
void
@@ -196,16 +204,23 @@ bfd_plugin_get_symbols_in_object_only (bfd *abfd)
abfd->filename, bfd_errmsg (bfd_get_error ()));
return;
}
- else if (!bfd_check_format (nbfd, bfd_object))
+ /* Prevent this recursive call into bfd_check_format from
+ attempting to load the plugin again while it is running. */
+ nbfd->plugin_format = bfd_plugin_no;
+ if (!bfd_check_format (nbfd, bfd_object))
{
/* There is no object only section if it isn't a bfd_object
file. */
bfd_close (nbfd);
return;
}
+
+ /* Copy LTO type derived from input sections. */
+ abfd->lto_type = nbfd->lto_type;
}
else
{
+ BFD_ASSERT (abfd->plugin_format == bfd_plugin_no);
if (!bfd_check_format (abfd, bfd_object))
{
(*_bfd_error_handler)
@@ -239,6 +254,9 @@ bfd_plugin_get_symbols_in_object_only (bfd *abfd)
/* Open the file containing object only section. */
nbfd = bfd_openr (object_only_file, NULL);
+ /* Prevent this recursive call into bfd_check_format from
+ attempting to load the plugin again while it is running. */
+ nbfd->plugin_format = bfd_plugin_no;
if (!bfd_check_format (nbfd, bfd_object))
{
(*_bfd_error_handler)
@@ -326,9 +344,8 @@ add_symbols (void * handle,
const struct ld_plugin_symbol * syms)
{
bfd *abfd = handle;
- struct plugin_data_struct *plugin_data =
- bfd_alloc (abfd, sizeof (plugin_data_struct));
-
+ struct plugin_data_struct *plugin_data = bfd_alloc (abfd,
+ sizeof (*plugin_data));
if (!plugin_data)
return LDPS_ERR;
@@ -598,6 +615,10 @@ try_load_plugin (const char *pname,
if (status != LDPS_OK)
goto short_circuit;
+ /* Setting bfd_plugin_no here prevents recursive calls into
+ bfd_check_format from within the plugin (unless the plugin opens
+ another bfd.) Attempting to load the plugin again while it is
+ running is *not* a good idea. */
abfd->plugin_format = bfd_plugin_no;
if (!current_plugin->claim_file)
@@ -627,14 +648,6 @@ bfd_plugin_set_plugin (const char *p)
plugin_name = p;
}
-/* Return TRUE if a plugin library is used. */
-
-bool
-bfd_plugin_specified_p (void)
-{
- return plugin_list != NULL;
-}
-
/* Return TRUE if ABFD can be claimed by linker LTO plugin. */
bool