This patch adds elf2flt support for prioritised constructors and destructors,
but only when --enable-emit-relocs is in effect.
GCC puts prioritised constructors and destructors in special .ctor.N
and .dtor.N sections (where N encodes the priority). The constructors
and destructors in these sections have a lower priority than those
in the default .ctor and .dtor sections. However, we need to treat
the crtbegin.o's and crtend.o's sections specially; crtbegin.o's .[cd]tor
sections must come before all the other .[cd]tor* contents and crtend.o's
.[cd]tor sections must come after all other contents.
In --disable-emit-relocs links, it wasn't possible to treat crtbegin.o
and crtend.o specially. ld-elf2flt would do:
so all the input .[cd]tor sections would already be lumped together by the
time the script was used. This isn't a problem for --enable-emit-relocs as
it only links once.
The patch copies the [cd]tor support from the standard binutils linker
script. The question is: should the new lines be used unconditionally,
or only when --enable-emit-relocs is in effect?
We could use the new lines for --disable-emit-relocs without breaking
programs that don't use prioritised [cd]tors. However, it would be a user
interface regression for programs that _do_ use them. At the moment,
if you try to use prioritised [cd]tors with --disable-emit-relocs,
you get a linker error like this:
error: no memory region specified for loadable section `.ctors.60535'
With the new lines, the link would silently succeed, and you'd get a
runtime failure instead. I've therefore guarded the lines with
"SINGLE_LINK:", a bit like the "W_RODAT" stuff that's already there.
Tested on Coldfire, with both --enable-emit-relocs and
--disable-emit-relocs. It fixes the GCC ecos.exp tests.
Please install if OK.
Richard
Signed-off-by: Richard Sandiford <richard@codesourcery.com>