aboutsummaryrefslogtreecommitdiff
path: root/ld/ldlang.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2014-07-03 16:32:45 +0930
committerAlan Modra <amodra@gmail.com>2014-07-03 17:05:42 +0930
commitd215621ebe5a6b60dff2e60c788a0f761e3cb5bd (patch)
treeeb5c641bf87b201f435e3cc6d0d753a7410ceab0 /ld/ldlang.c
parentfd48cee0093fef69608959d0f577c0c81fe24eec (diff)
downloadgdb-d215621ebe5a6b60dff2e60c788a0f761e3cb5bd.zip
gdb-d215621ebe5a6b60dff2e60c788a0f761e3cb5bd.tar.gz
gdb-d215621ebe5a6b60dff2e60c788a0f761e3cb5bd.tar.bz2
Reload --as-needed libraries inside groups
When a shared library appears within --start-group/--end-group ld may only discover a need for loading the library on the second or subsequent pass over archive libraries, as more objects are extracted. ld/ PR 17068 * ldlang.c (load_symbols): Always check flags.reload. (open_input_bfds): Always reload --as-needed shared libraries, not just when rescanning. * ldlang.h (struct lang_input_statement_flags): Update reload comment. * plugin.c (plugin_should_reload): Assume shared library arg. * plugin.h (plugin_should_reload): Update comment. ld/testsuite * ld-elf/pr17068.s: New. * ld-elf/pr17068a.s: New. * ld-elf/pr17068b.s: New. * ld-elf/pr17068c.s: New. * ld-elf/pr17068d.s: New. * ld-elf/pr17068e.s: New. * ld-elf/pr17068ez.s: New. * ld-elf/elf.exp: Run new test.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r--ld/ldlang.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 60877b8..5e10c4a 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -2790,9 +2790,7 @@ load_symbols (lang_input_statement_type *entry,
break;
case bfd_object:
-#ifdef ENABLE_PLUGINS
if (!entry->flags.reload)
-#endif
ldlang_add_file (entry);
if (trace_files || verbose)
info_msg ("%I\n", entry);
@@ -3268,38 +3266,32 @@ open_input_bfds (lang_statement_union_type *s, enum open_bfd_mode mode)
{
lang_statement_union_type **os_tail;
lang_statement_list_type add;
+ bfd *abfd;
s->input_statement.target = current_target;
/* If we are being called from within a group, and this
is an archive which has already been searched, then
force it to be researched unless the whole archive
- has been loaded already. Do the same for a rescan. */
+ has been loaded already. Do the same for a rescan.
+ Likewise reload --as-needed shared libs. */
if (mode != OPEN_BFD_NORMAL
#ifdef ENABLE_PLUGINS
&& ((mode & OPEN_BFD_RESCAN) == 0
|| plugin_insert == NULL)
#endif
- && !s->input_statement.flags.whole_archive
&& s->input_statement.flags.loaded
- && s->input_statement.the_bfd != NULL
- && bfd_check_format (s->input_statement.the_bfd,
- bfd_archive))
- s->input_statement.flags.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.flags.loaded
- && s->input_statement.flags.add_DT_NEEDED_for_regular
- && s->input_statement.the_bfd != NULL
- && ((s->input_statement.the_bfd->flags) & DYNAMIC) != 0
- && plugin_should_reload (s->input_statement.the_bfd))
+ && (abfd = s->input_statement.the_bfd) != NULL
+ && ((bfd_get_format (abfd) == bfd_archive
+ && !s->input_statement.flags.whole_archive)
+ || (bfd_get_format (abfd) == bfd_object
+ && ((abfd->flags) & DYNAMIC) != 0
+ && s->input_statement.flags.add_DT_NEEDED_for_regular
+ && plugin_should_reload (abfd))))
{
s->input_statement.flags.loaded = FALSE;
s->input_statement.flags.reload = TRUE;
}
-#endif
os_tail = lang_output_section_statement.tail;
lang_list_init (&add);