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.
This commit is contained in:
Alan Modra
2015-10-29 16:16:22 +10:30
parent d85063237a
commit 936384714f
7 changed files with 76 additions and 18 deletions

View File

@@ -1499,11 +1499,12 @@ next_matching_output_section_statement (lang_output_section_statement_type *os,
lang_output_section_statement_type *
lang_output_section_find_by_flags (const asection *sec,
flagword sec_flags,
lang_output_section_statement_type **exact,
lang_match_sec_type_func match_type)
{
lang_output_section_statement_type *first, *look, *found;
flagword look_flags, sec_flags, differ;
flagword look_flags, differ;
/* We know the first statement on this list is *ABS*. May as well
skip it. */
@@ -1511,7 +1512,6 @@ lang_output_section_find_by_flags (const asection *sec,
first = first->next;
/* First try for an exact match. */
sec_flags = sec->flags;
found = NULL;
for (look = first; look; look = look->next)
{
@@ -1695,7 +1695,7 @@ lang_output_section_find_by_flags (const asection *sec,
if (found || !match_type)
return found;
return lang_output_section_find_by_flags (sec, NULL, NULL);
return lang_output_section_find_by_flags (sec, sec_flags, NULL, NULL);
}
/* Find the last output section before given output statement.