PATCH: Add SORT_NONE to .init and .fini sections in linker sripts
H.J. Lu
hjl.tools@gmail.com
Wed Aug 1 01:09:00 GMT 2012
On Tue, Jul 31, 2012 at 3:56 PM, Alan Modra <amodra@gmail.com> wrote:
> On Tue, Jul 31, 2012 at 02:00:30PM -0700, H.J. Lu wrote:
>> Some linker sripts put .init and .fini sections in .text section. Those
>> targets fail PR ld/14156 tests. This set of patches adds SORT_NONE to
>> .init and .fini sections in linker sripts. Tested for xtensa-elf, d30v-elf,
>> d10v-elf and msp430-elf. OK to install?
>
> OK, but please add SORT_NONE to elf.sc too.
>
Here is the additional patch I checked in. I'd like to backport
it to 2.23 since SORT_NONE isn't handled properly.
--
H.J.
---
PR ld/14156
* ldlang.c (wild_sort): Properly handle by_none.
* scripttempl/elf.sc: Add SORT_NONE to .init and .fini sections.
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 5a4eef7..5327e12 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -2462,7 +246@@ -3512,8 +3512,6 @@ update_wild_statements (lang_statement_u
if (sort_section == by_name)
sec->spec.sorted = by_alignment_name;
break;
- case by_none:
- sec->spec.sorted = none;
default:
break;
}
2,9 @@ wild_sort (lang_wild_statement_type *wild,
/* Here either the files are not sorted by name, or we are
looking at the sections for this file. */
- if (sec != NULL && sec->spec.sorted != none)
+ if (sec != NULL
+ && sec->spec.sorted != none
+ && sec->spec.sorted != by_none)
if (compare_section (sec->spec.sorted, section, ls->section) < 0)
break;
}
diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
index 17c2cf1..51a655e 100644
--- a/ld/scripttempl/elf.sc
+++ b/ld/scripttempl/elf.sc
@@ -462,7 +462,7 @@ cat <<EOF
.init ${RELOCATING-0} :
{
${RELOCATING+${INIT_START}}
- KEEP (*(.init))
+ KEEP (*(SORT_NONE(.init)))
${RELOCATING+${INIT_END}}
} ${FILL}
@@ -483,7 +483,7 @@ cat <<EOF
.fini ${RELOCATING-0} :
{
${RELOCATING+${FINI_START}}
- KEEP (*(.fini))
+ KEEP (*(SORT_NONE(.fini)))
${RELOCATING+${FINI_END}}
} ${FILL}
${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);}
More information about the Binutils
mailing list