binutils/binutils-2.25.1-plugin-format-checking.patch
2016-01-25 11:31:53 +00:00

61 lines
1.9 KiB
Diff

diff -rup binutils-2.25.1.orig/bfd/plugin.c binutils-2.25.1/bfd/plugin.c
--- binutils-2.25.1.orig/bfd/plugin.c 2015-11-05 11:40:58.400941923 +0000
+++ binutils-2.25.1/bfd/plugin.c 2015-11-05 15:50:37.046908541 +0000
@@ -135,8 +135,9 @@ static asection bfd_plugin_fake_common_s
= BFD_FAKE_SECTION (bfd_plugin_fake_common_section, SEC_IS_COMMON, 0,
NULL, 0);
-/* Get symbols from object only section. */
+static bfd_boolean in_get_symbols = FALSE;
+/* Get symbols from object only section. */
static void
bfd_plugin_get_symbols_in_object_only (bfd *abfd)
{
@@ -153,7 +154,8 @@ bfd_plugin_get_symbols_in_object_only (b
if (abfd->sections == NULL && abfd->my_archive == NULL)
{
nbfd = bfd_openr (abfd->filename, NULL);
- if (nbfd == NULL || !bfd_check_format (nbfd, bfd_object))
+
+ if (nbfd == NULL)
{
(*_bfd_error_handler)
(_("%s: failed to open to extract object only section: %s"),
@@ -161,6 +163,22 @@ bfd_plugin_get_symbols_in_object_only (b
bfd_close (nbfd);
return;
}
+ else
+ {
+ /* Note that we are calling bfd_check_format from inside
+ bfd_plugin_get_symbols_in_object_only. bfd_check_format
+ will iterate through the known list of formats, including
+ the "plugin" format, and we do not want to end up in a
+ recursive loop. */
+ in_get_symbols = TRUE;
+ if (!bfd_check_format (nbfd, bfd_object))
+ {
+ in_get_symbols = FALSE;
+ bfd_close (nbfd);
+ return;
+ }
+ in_get_symbols = FALSE;
+ }
}
else
{
@@ -515,6 +515,12 @@ load_plugin (bfd *abfd)
static const bfd_target *
bfd_plugin_object_p (bfd *abfd)
{
+ /* If in_get_symbols is TRUE then this function is being called from
+ bfd_check_format. We do not want to iterate again - we will just
+ end up in an infinite loop. So return NULL here. */
+ if (in_get_symbols)
+ return NULL;
+
if (ld_plugin_object_p)
return ld_plugin_object_p (abfd);