aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-01-28 10:30:36 +1030
committerAlan Modra <amodra@gmail.com>2021-01-28 18:53:30 +1030
commitdef97fb945a98544938087eff3111e16ce58da6d (patch)
tree7efaf17089a481046698eabc075a1fb6cfe0b874 /ld
parent2f985dd1acf41d6b52ee2433f09a5fcc0244456a (diff)
downloadgdb-def97fb945a98544938087eff3111e16ce58da6d.zip
gdb-def97fb945a98544938087eff3111e16ce58da6d.tar.gz
gdb-def97fb945a98544938087eff3111e16ce58da6d.tar.bz2
PR27259, SHF_LINK_ORDER self-link
This stops ld from endless looping on SHF_LINK_ORDER sh_link loops. bfd/ PR 27259 * elflink.c (_bfd_elf_gc_mark_extra_sections): Use linker_mark to prevent endless looping of linked-to sections. ld/ PR 27259 * ldelf.c (ldelf_before_place_orphans): Use linker_mark to prevent endless looping of linked-to sections.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog6
-rw-r--r--ld/ldelf.c21
2 files changed, 20 insertions, 7 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index df20606..9dfff4a 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2021-01-28 Alan Modra <amodra@gmail.com>
+
+ PR 27259
+ * ldelf.c (ldelf_before_place_orphans): Use linker_mark to
+ prevent endless looping of linked-to sections.
+
2021-01-26 H.J. Lu <hongjiu.lu@intel.com>
* testsuite/ld-x86-64/bnd-plt-1.d: Fix a typo.
diff --git a/ld/ldelf.c b/ld/ldelf.c
index 9887e53..0499925 100644
--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -2188,14 +2188,21 @@ ldelf_before_place_orphans (void)
been discarded. */
asection *linked_to_sec;
for (linked_to_sec = elf_linked_to_section (isec);
- linked_to_sec != NULL;
+ linked_to_sec != NULL && !linked_to_sec->linker_mark;
linked_to_sec = elf_linked_to_section (linked_to_sec))
- if (discarded_section (linked_to_sec))
- {
- isec->output_section = bfd_abs_section_ptr;
- isec->flags |= SEC_EXCLUDE;
- break;
- }
+ {
+ if (discarded_section (linked_to_sec))
+ {
+ isec->output_section = bfd_abs_section_ptr;
+ isec->flags |= SEC_EXCLUDE;
+ break;
+ }
+ linked_to_sec->linker_mark = 1;
+ }
+ for (linked_to_sec = elf_linked_to_section (isec);
+ linked_to_sec != NULL && linked_to_sec->linker_mark;
+ linked_to_sec = elf_linked_to_section (linked_to_sec))
+ linked_to_sec->linker_mark = 0;
}
}
}