aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2011-09-20 04:58:56 +0000
committerAlan Modra <amodra@gmail.com>2011-09-20 04:58:56 +0000
commit15fc2e131d8effb40f28e922c2d402cccf8c8193 (patch)
treef6083ddf8d733d641263dcd5b02ee6d90c15d5c2
parent699d8ed24cdc9a265c9497edd3fcd300abce9424 (diff)
downloadgdb-15fc2e131d8effb40f28e922c2d402cccf8c8193.zip
gdb-15fc2e131d8effb40f28e922c2d402cccf8c8193.tar.gz
gdb-15fc2e131d8effb40f28e922c2d402cccf8c8193.tar.bz2
PR ld/12301
* ldlang.h (lang_input_statement_type): Add "reload" bitfield. Clarify comments. * ldlang.c (new_afile): Init new field. (load_symbols): Don't call ldlang_add_file when reloading. (open_input_bfds): Reload as-needed libs during plugin rescan.
-rw-r--r--ld/ChangeLog9
-rw-r--r--ld/ldlang.c18
-rw-r--r--ld/ldlang.h12
3 files changed, 34 insertions, 5 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index cafca0e..3e51f1c 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
+2011-09-20 Alan Modra <amodra@gmail.com>
+
+ PR ld/12301
+ * ldlang.h (lang_input_statement_type): Add "reload" bitfield.
+ Clarify comments.
+ * ldlang.c (new_afile): Init new field.
+ (load_symbols): Don't call ldlang_add_file when reloading.
+ (open_input_bfds): Reload as-needed libs during plugin rescan.
+
2011-09-15 H.J. Lu <hongjiu.lu@intel.com>
PR ld/12975
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 7251a86..ae54155 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -1133,6 +1133,7 @@ new_afile (const char *name,
#ifdef ENABLE_PLUGINS
p->claimed = FALSE;
p->claim_archive = FALSE;
+ p->reload = FALSE;
#endif /* ENABLE_PLUGINS */
lang_statement_append (&input_file_chain,
@@ -2780,7 +2781,10 @@ load_symbols (lang_input_statement_type *entry,
break;
case bfd_object:
- ldlang_add_file (entry);
+#ifdef ENABLE_PLUGINS
+ if (!entry->reload)
+#endif
+ ldlang_add_file (entry);
if (trace_files || trace_file_tries)
info_msg ("%I\n", entry);
break;
@@ -3272,6 +3276,18 @@ open_input_bfds (lang_statement_union_type *s, enum open_bfd_mode mode)
&& bfd_check_format (s->input_statement.the_bfd,
bfd_archive))
s->input_statement.loaded = FALSE;
+#ifdef ENABLE_PLUGINS
+ /* When rescanning, reload --as-needed shared libs. */
+ else if ((mode & OPEN_BFD_RESCAN) != 0
+ && 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.loaded = FALSE;
+ s->input_statement.reload = TRUE;
+ }
+#endif
os_tail = lang_output_section_statement.tail;
lang_list_init (&add);
diff --git a/ld/ldlang.h b/ld/ldlang.h
index 533fe74..95f9412 100644
--- a/ld/ldlang.h
+++ b/ld/ldlang.h
@@ -270,12 +270,13 @@ typedef struct lang_input_statement_struct
/* Whether to search for this entry as a dynamic archive. */
unsigned int dynamic : 1;
- /* Whether DT_NEEDED tags should be added for dynamic libraries in
- DT_NEEDED tags from this entry. */
+ /* Set if a DT_NEEDED tag should be added not just for the dynamic library
+ explicitly given by this entry but also for any dynamic libraries in
+ this entry's needed list. */
unsigned int add_DT_NEEDED_for_dynamic : 1;
- /* Whether this entry should cause a DT_NEEDED tag only when
- satisfying references from regular files, or always. */
+ /* Set if this entry should cause a DT_NEEDED tag only when some
+ regular file references its symbols (ie. --as-needed is in effect). */
unsigned int add_DT_NEEDED_for_regular : 1;
/* Whether to include the entire contents of an archive. */
@@ -295,6 +296,9 @@ typedef struct lang_input_statement_struct
/* Set if the file was claimed from an archive. */
unsigned int claim_archive : 1;
+
+ /* Set if reloading an --as-needed lib. */
+ unsigned int reload : 1;
#endif /* ENABLE_PLUGINS */
} lang_input_statement_type;