diff options
author | Alan Modra <amodra@gmail.com> | 2021-01-28 10:30:36 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-01-28 18:53:30 +1030 |
commit | def97fb945a98544938087eff3111e16ce58da6d (patch) | |
tree | 7efaf17089a481046698eabc075a1fb6cfe0b874 /bfd | |
parent | 2f985dd1acf41d6b52ee2433f09a5fcc0244456a (diff) | |
download | gdb-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 'bfd')
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/elflink.c | 24 |
2 files changed, 22 insertions, 8 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index c8fcb3a..0fdc1fa 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2021-01-28 Alan Modra <amodra@gmail.com> + + PR 27259 + * elflink.c (_bfd_elf_gc_mark_extra_sections): Use linker_mark to + prevent endless looping of linked-to sections. + 2020-12-17 Mihails Strasuns <mihails.strasuns@intel.com> * bfd-elf.h (elfcore_write_file_note): New function. diff --git a/bfd/elflink.c b/bfd/elflink.c index 59a6080..47c3fb4 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -13631,15 +13631,23 @@ _bfd_elf_gc_mark_extra_sections (struct bfd_link_info *info, /* Since all sections, except for backend specific ones, have been garbage collected, call mark_hook on this section if any of its linked-to sections is marked. */ - asection *linked_to_sec = elf_linked_to_section (isec); - for (; linked_to_sec != NULL; + asection *linked_to_sec; + 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)) - if (linked_to_sec->gc_mark) - { - if (!_bfd_elf_gc_mark (info, isec, mark_hook)) - return FALSE; - break; - } + { + if (linked_to_sec->gc_mark) + { + if (!_bfd_elf_gc_mark (info, isec, mark_hook)) + return FALSE; + 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; } if (!debug_frag_seen |