diff options
author | Alan Modra <amodra@gmail.com> | 2015-10-29 16:16:22 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2015-10-29 19:42:50 +1030 |
commit | 936384714fa8b0f7ca8cc3b5637394461bc998c8 (patch) | |
tree | 2dbee0b6a2d5c5b00506e43e5e24c7090f284345 /ld/emultempl/mmo.em | |
parent | fix typo in ld's texinfo (diff) | |
download | binutils-gdb-936384714fa8b0f7ca8cc3b5637394461bc998c8.tar.gz binutils-gdb-936384714fa8b0f7ca8cc3b5637394461bc998c8.tar.bz2 binutils-gdb-936384714fa8b0f7ca8cc3b5637394461bc998c8.zip |
Re: Orphan output section with multiple input sections
The last patch missed handling the case where the ideal place to put
an orphan was after a non-existent output section statement, as can
happen when not using the builtin linker scripts. This patch uses the
updated flags for that case too, and extends the support to mmo and pe.
PR ld/19162
* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Pass
updated flags to lang_output_section_find_by_flags.
* emultempl/mmo.em (mmo_place_orphan): Merge flags for any
other input sections that might match a new output section to
decide placement.
* emultempl/pe.em (gld_${EMULATION_NAME}_place_orphan): Likewise.
* emultempl/pep.em (gld_${EMULATION_NAME}_place_orphan): Likewise.
* ldlang.c (lang_output_section_find_by_flags): Add sec_flags param.
* ldlang.h (lang_output_section_find_by_flags): Update prototype.
Diffstat (limited to 'ld/emultempl/mmo.em')
-rw-r--r-- | ld/emultempl/mmo.em | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/ld/emultempl/mmo.em b/ld/emultempl/mmo.em index 47f77d850da..8949aed13fa 100644 --- a/ld/emultempl/mmo.em +++ b/ld/emultempl/mmo.em @@ -88,6 +88,8 @@ mmo_place_orphan (asection *s, lang_output_section_statement_type *after; lang_output_section_statement_type *os; size_t i; + flagword flags; + asection *nexts; /* We have nothing to say for anything other than a final link or for sections that are excluded. */ @@ -109,9 +111,21 @@ mmo_place_orphan (asection *s, A section without contents can have SEC_LOAD == 0, but we still want it attached to a sane section so the symbols appear as expected. */ - if ((s->flags & (SEC_ALLOC | SEC_READONLY)) != SEC_READONLY) + flags = s->flags; + nexts = s; + while ((nexts = bfd_get_next_section_by_name (nexts->owner, nexts)) != NULL) + if (nexts->output_section == NULL + && (nexts->flags & SEC_EXCLUDE) == 0 + && ((nexts->flags ^ flags) & (SEC_LOAD | SEC_ALLOC)) == 0 + && (nexts->owner->flags & DYNAMIC) == 0 + && nexts->owner->usrdata != NULL + && !(((lang_input_statement_type *) nexts->owner->usrdata) + ->flags.just_syms)) + flags = (((flags ^ SEC_READONLY) | (nexts->flags ^ SEC_READONLY)) + ^ SEC_READONLY); + if ((flags & (SEC_ALLOC | SEC_READONLY)) != SEC_READONLY) for (i = 0; i < sizeof (holds) / sizeof (holds[0]); i++) - if ((s->flags & holds[i].nonzero_flags) != 0) + if ((flags & holds[i].nonzero_flags) != 0) { place = &holds[i].orphansave; if (place->os == NULL) |