diff options
author | Alan Modra <amodra@gmail.com> | 2015-10-28 17:18:13 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2015-10-28 17:51:10 +1030 |
commit | 199af1503922ce2134d774a78be0d9e2ae055ab1 (patch) | |
tree | dd1fcec6689ca3acbd5ef488fc0f5db79581fb1e /bfd/section.c | |
parent | 26656b1dc6c00f2eea0d329cc2637aebf3da1458 (diff) | |
download | gdb-199af1503922ce2134d774a78be0d9e2ae055ab1.zip gdb-199af1503922ce2134d774a78be0d9e2ae055ab1.tar.gz gdb-199af1503922ce2134d774a78be0d9e2ae055ab1.tar.bz2 |
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.
Diffstat (limited to 'bfd/section.c')
-rw-r--r-- | bfd/section.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/bfd/section.c b/bfd/section.c index 834a9ab..247d98a 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -903,16 +903,18 @@ FUNCTION bfd_get_next_section_by_name SYNOPSIS - asection *bfd_get_next_section_by_name (asection *sec); + asection *bfd_get_next_section_by_name (bfd *ibfd, asection *sec); DESCRIPTION Given @var{sec} is a section returned by @code{bfd_get_section_by_name}, return the next most recently created section attached to the same - BFD with the same name. Return NULL if no such section exists. + BFD with the same name, or if no such section exists in the same BFD and + IBFD is non-NULL, the next section with the same name in any input + BFD following IBFD. Return NULL on finding no section. */ asection * -bfd_get_next_section_by_name (asection *sec) +bfd_get_next_section_by_name (bfd *ibfd, asection *sec) { struct section_hash_entry *sh; const char *name; @@ -930,6 +932,16 @@ bfd_get_next_section_by_name (asection *sec) && strcmp (sh->root.string, name) == 0) return &sh->section; + if (ibfd != NULL) + { + while ((ibfd = ibfd->link.next) != NULL) + { + asection *s = bfd_get_section_by_name (ibfd, name); + if (s != NULL) + return s; + } + } + return NULL; } @@ -951,7 +963,7 @@ bfd_get_linker_section (bfd *abfd, const char *name) asection *sec = bfd_get_section_by_name (abfd, name); while (sec != NULL && (sec->flags & SEC_LINKER_CREATED) == 0) - sec = bfd_get_next_section_by_name (sec); + sec = bfd_get_next_section_by_name (NULL, sec); return sec; } |