Subject: Re: removing init/fini_fallthru
To: Valeriy E. Ushakov <uwe@ptc.spbu.ru>
From: Nick Hudson <skrll@netbsd.org>
List: tech-toolchain
Date: 06/21/2006 08:13:52
On Wednesday 21 June 2006 01:36, Valeriy E. Ushakov wrote:
> On Tue, Jun 20, 2006 at 00:38:30 +1000, Simon Burge wrote:
> > MIPS with gcc4 is having some problems generating bad code which we sort
> > of worked around but breaking gcc3 in the process. Nick Hudson and I
> > have come up with the following which does away with the init_fallthru
> > and fini_fallthru functions and just puts _init and _fini directly in
> > the .init and .fini sections.
>
> I'm confused. crti.c says:
>
> void _init(void) __attribute__((section(".init")));
> void _fini(void) __attribute__((section(".fini")));
>
> so these functions are already in .init and .fini respectively.
They are and they are used correctly as the .init/.fini section entry points.
What is required is a way to generate a function prologue at the start
of .init/.fini sections and a function epilogue at the end of the .init/.fini
section. Any other .init/.fini code is run by being in the middle of these.
The function pro/epilogue are put there by careful placing of objects at link
time. Any additional .init/.fini section code should in objects passed to the
linker between start and end objects.
The way the code works now is _init/_fini calls init/fini_fallthru where
init/fini_fallthru provide the funciton prologue. The function call from
_init was confusing gcc4 on mips because gcc thinks _init_fallthru is a
global, but the assembler declares it as a local. Changing _init_fallthru to
a global in the assembler confuses gcc3.
The diff Simon posted does away with the _init/_fini call to
init/fall_fallthru and generates a _init/_fini that only have the function
prologue.
Clear as mud?
> SY, Uwe
Nick