PR ld/13287
authorAlan Modra <amodra@gmail.com>
Thu, 20 Oct 2011 09:50:59 +0000 (09:50 +0000)
committerAlan Modra <amodra@gmail.com>
Thu, 20 Oct 2011 09:50:59 +0000 (09:50 +0000)
* plugin.c (plugin_should_reload): New function.
* plugin.h (plugin_should_reload): Declare.
* ldlang.c (open_input_bfds): Use above function.

ld/ChangeLog
ld/ldlang.c
ld/plugin.c
ld/plugin.h

index 04b8cf6e60d8a95fb9ff4e9573ea728579aeb18d..568ccc2c8cdae30323b8857d45914443c5d5fd1b 100644 (file)
@@ -1,3 +1,10 @@
+2011-10-20  Alan Modra  <amodra@gmail.com>
+
+       PR ld/13287
+       * plugin.c (plugin_should_reload): New function.
+       * plugin.h (plugin_should_reload): Declare.
+       * ldlang.c (open_input_bfds): Use above function.
+
 2011-10-19  Alan Modra  <amodra@gmail.com>
 
        PR ld/13254
index ae541558ec5eda12c48290002090b47b08e7f4be..2c56b564559e3a30683d5168854856c569112299 100644 (file)
@@ -3282,7 +3282,8 @@ open_input_bfds (lang_statement_union_type *s, enum open_bfd_mode mode)
                       && plugin_insert == NULL
                       && s->input_statement.loaded
                       && s->input_statement.add_DT_NEEDED_for_regular
-                      && ((s->input_statement.the_bfd->flags) & DYNAMIC) != 0)
+                      && ((s->input_statement.the_bfd->flags) & DYNAMIC) != 0
+                      && plugin_should_reload (s->input_statement.the_bfd))
                {
                  s->input_statement.loaded = FALSE;
                  s->input_statement.reload = TRUE;
index 5f4aa8faa6ab59d565111ed3633e2539b74dee67..91fe48b9f27135a219598343d562b39c78e60d0d 100644 (file)
@@ -1014,3 +1014,14 @@ plugin_notice (struct bfd_link_info *info,
                                      abfd, section, value, flags, string);
   return TRUE;
 }
+
+/* Return true if bfd is a dynamic library that should be reloaded.  */
+
+bfd_boolean
+plugin_should_reload (bfd *abfd)
+{
+  return ((abfd->flags & DYNAMIC) != 0
+         && bfd_get_flavour (abfd) == bfd_target_elf_flavour
+         && bfd_get_format (abfd) == bfd_object
+         && (elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0);
+}
index ee29b7ce1c9908c840b6c975d1868f1cd71c30d0..dc32295b0d8e59b1104d59a4e150f89f19037d18 100644 (file)
@@ -66,4 +66,7 @@ extern void plugin_call_cleanup (void);
    add_symbols hook has been called so that it can be read when linking.  */
 extern bfd *plugin_get_ir_dummy_bfd (const char *name, bfd *template);
 
+/* Return true if bfd is a dynamic library that should be reloaded.  */
+extern bfd_boolean plugin_should_reload (bfd *);
+
 #endif /* !def GLD_PLUGIN_H */