Still need (desperately!!!) help with initializing code
gregory.menke at gsfc.nasa.gov
gregory.menke at gsfc.nasa.gov
Wed Nov 26 14:54:09 UTC 2003
Leon Pollak writes:
> Hello.
> I am really stuck with this.
> My study of gcc stuff shows that there were significant changes in version 3
> and I am lost in them.
> I understand that static variables values are stored in some section, which
> must be later copied into another section. Also the _bss section must be
> zeroed.
> I have passed through the start.S files in many BSPs and it seems to me that
> all BSPs do BSS zeroing, but only few do copying of ROM to RAM.
> Why is this? What do I miss?
Some bsp's do rom to ram copying, others don't. There is no
fundamental requirement that a bsp do it, the choice is mostly a
pragmatic one.
The section copying you allude to is related to the rom-ram copying,
in that case, the various .data sections are copied so initialized
data occupies ram. If a bsp does not copy, the .data sections are
already in place, so nothing more needs to be done with them.
.bss always needs to be zero'ed because .bss sections are not suposed
to be included in the ROM image- they contain no initialized data.
>From the standpoint of copying from rom to ram, the init,fini code is
usually copied right along with .text.
These issues are the same in most any C runtime, gcc2 vs gcc3 doesn't
affect them.
The global constructor init code is supplied by gcc in several parts.
There are a couple "crt" related .o files that must be included at
linktime which fill out the beginning and end of the _init, _fini
code. If they aren't linked properly, global
constructors/desctructors will not function- the init & fini sections
will be empty in the executable. To link them properly, they must be
positioned in the right order around the RTEMS & application .o and .a
files. The link script must arrange for the right sections as well.
GCC does change how it arranges this kind of thing, I think a number
of architectures changed how the ctors/dtors were called from gcc2.x
to gcc3.x- both PPC and MIPS changed, IIRC.
If you're working on a PPC, GCC does handle the ctors/dtors via
init,fini. If its not working for you, then the problem is very
likely your link script and/or bspspecs. If you've got those files
all set up, resort to objdump to examine the _init,_fini sections.
You might also want to doublecheck your link step itself- make sure
its actually using your bspspecs & linkcmds, that sort of thing is
easy to mess up.
Gregm
More information about the users
mailing list