Question about _init, _fini

Bill Gatliff bgat at billgatliff.com
Thu Aug 21 21:49:44 UTC 2003


Mike:


They're part of gcc's startup and shutdown processes, defined in 
crtbegin.o and crtend.o.

They're functions; declare a do-nothing version by the same name, i.e.:

void _init(void)
{
}

... and you should be good to go.  You could also wander around in gcc's 
source code and see what they do, but if I recall correctly, they aren't 
needed in bare-bones setups.  :^)


b.g.


mikeci at acm.org wrote:

>>Quite likely yes.  Look for the .init and .fini sections of a linker
>>script for another bsp using a processor similar to yours- if you're
>>using a MIPS, have a look at the MongooseV's link script, you'll find it
>>down in the bsp directory.  WHile you're at it, you might want to check
>>the other sections too, linker scripts evolve and sometimes
>>leave bsp's behind.
>>
>>Gregm
>>    
>>
>
>Hi!
>
>Here is what I tried:
>
>1. Add a new section:
>
>
>.init :
>{
>     KEEP (*(.init))
>}
>
>and similar for .fini
>
>This gives me a linker error stating that _init and _fini are undefined.
>If I add
>.init :
>{
>     PROVIDE (_init = .);
>     KEEP(*(.init))
>}
>
>linker doesn't complain, but program generates an exception. My question
>is where are those two symbols defined, and how to link the code which
>goes with it?
>
>If I check the memory map, it seams that no code is linked neither for
>_init nor for _fini.
>
>
>Regards
>
>Ivica
>
>
>
>
>
>
>  
>

-- 
Bill Gatliff
Professional embedded GNU training.
bgat at billgatliff.com





More information about the users mailing list