From 199af1503922ce2134d774a78be0d9e2ae055ab1 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 28 Oct 2015 17:18:13 +1030 Subject: Orphan output section with multiple input sections If given input sections with differing flags, we'd like to place the section according to the final output section flags. bfd/ PR ld/19162 * elflink.c (_bfd_elf_gc_mark_reloc): Move code iterating over linker input bfds.. * section.c (bfd_get_next_section_by_name): ..to here. Add ibfd param. (bfd_get_linker_section): Adjust bfd_get_next_section_by_name call. * tekhex.c (first_phase): Likewise. * elflink.c (bfd_elf_gc_sections): Likewise. * bfd-in2.h: Regenerate. ld/ PR ld/19162 * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Check flags before calling _bfd_elf_match_sections_by_type. Merge flags for any other input sections that might match a new output section to decide placement. --- bfd/elflink.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'bfd/elflink.c') diff --git a/bfd/elflink.c b/bfd/elflink.c index 1cfdd31..1b41c79 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -12179,8 +12179,6 @@ _bfd_elf_gc_mark_reloc (struct bfd_link_info *info, rsec = _bfd_elf_gc_mark_rsec (info, sec, gc_mark_hook, cookie, &start_stop); while (rsec != NULL) { - asection *s; - if (!rsec->gc_mark) { if (bfd_get_flavour (rsec->owner) != bfd_target_elf_flavour @@ -12191,22 +12189,7 @@ _bfd_elf_gc_mark_reloc (struct bfd_link_info *info, } if (!start_stop) break; - s = bfd_get_next_section_by_name (rsec); - if (s == NULL) - { - bfd *i = rsec->owner; - - if (i != NULL) - { - while ((i = i->link.next) != NULL) - { - s = bfd_get_section_by_name (i, rsec->name); - if (s != NULL) - break; - } - } - } - rsec = s; + rsec = bfd_get_next_section_by_name (rsec->owner, rsec); } return TRUE; } @@ -12757,7 +12740,7 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info) && (sec->flags & SEC_LINKER_CREATED) == 0) elf_eh_frame_section (sub) = sec; fini_reloc_cookie_for_section (&cookie, sec); - sec = bfd_get_next_section_by_name (sec); + sec = bfd_get_next_section_by_name (NULL, sec); } } -- cgit v1.1