aboutsummaryrefslogtreecommitdiff
path: root/bfd/plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/plugin.c')
-rw-r--r--bfd/plugin.c64
1 files changed, 31 insertions, 33 deletions
diff --git a/bfd/plugin.c b/bfd/plugin.c
index d57ae59..5e5a0b7 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -73,8 +73,6 @@ dlerror (void)
#define bfd_plugin_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
#define bfd_plugin_new_section_hook _bfd_generic_new_section_hook
#define bfd_plugin_get_section_contents _bfd_generic_get_section_contents
-#define bfd_plugin_init_private_section_data _bfd_generic_init_private_section_data
-#define bfd_plugin_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
#define bfd_plugin_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
#define bfd_plugin_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
#define bfd_plugin_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
@@ -140,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
@@ -198,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)
@@ -241,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)
@@ -328,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;
@@ -600,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)
@@ -629,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
@@ -647,16 +658,6 @@ bfd_link_plugin_object_p (bfd *abfd)
return false;
}
-extern const bfd_target plugin_vec;
-
-/* Return TRUE if TARGET is a pointer to plugin_vec. */
-
-bool
-bfd_plugin_target_p (const bfd_target *target)
-{
- return target == &plugin_vec;
-}
-
/* Register OBJECT_P to be used by bfd_plugin_object_p. */
void
@@ -782,7 +783,8 @@ static bool
bfd_plugin_bfd_copy_private_section_data (bfd *ibfd ATTRIBUTE_UNUSED,
asection *isection ATTRIBUTE_UNUSED,
bfd *obfd ATTRIBUTE_UNUSED,
- asection *osection ATTRIBUTE_UNUSED)
+ asection *osection ATTRIBUTE_UNUSED,
+ struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
{
BFD_ASSERT (0);
return true;
@@ -990,30 +992,26 @@ const bfd_target plugin_vec =
{ /* bfd_check_format. */
_bfd_dummy_target,
bfd_plugin_object_p,
- bfd_generic_archive_p,
+ _bfd_dummy_target,
_bfd_dummy_target
},
{ /* bfd_set_format. */
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
- _bfd_generic_mkarchive,
+ _bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
{ /* bfd_write_contents. */
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
- _bfd_write_archive_contents,
+ _bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
BFD_JUMP_TABLE_GENERIC (bfd_plugin),
BFD_JUMP_TABLE_COPY (bfd_plugin),
BFD_JUMP_TABLE_CORE (bfd_plugin),
-#ifdef USE_64_BIT_ARCHIVE
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_64_bit),
-#else
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
-#endif
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
BFD_JUMP_TABLE_SYMBOLS (bfd_plugin),
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
BFD_JUMP_TABLE_WRITE (bfd_plugin),