EmbDev.net

Forum: ARM programming with GCC/GNU tools static initialization does not work with arm-none-eabi


von Pawel (Guest)


Rate this post
useful
not useful
Hello, I moved from arm-elf- to arm-none-eabi- and noticed that a static 
variable inside a function would not initialize. A piece of code like:

static uint8_t Config[3] = { 0x87, 0x44, 0x00 } ;

would yield Config[] being { 0x00, 0x00, 0x00 }

That worked with arm-elf ... am I doing something wrong ?

Thank you for help or hints.

Pawel.

von (prx) A. K. (prx)


Rate this post
useful
not useful
And data not explicitly initialized is not set to 0, I assume.

Those initializations are part of the startup code linked into the 
executable. arm-none-eabi usually implies that there is no operating 
system provided program loader (which normally does this job) and that 
initialized static data is part of the program data segment, to be 
copied from ROM to RAM by some startup code which is provided either by 
the development environment or has to be provided by you.

The initialization code depends on definitions within the linker script, 
so replacing only of them usually fails.

von Pawel (Guest)


Rate this post
useful
not useful
The data appears to be initialized with zeros.

Do you mean the arm-none-eabi- compiler does not generate such startup 
code while the arm-elf compiler would generate it ?
Shall I write such code myself ?

von Martin T. (mthomas) (Moderator)


Rate this post
useful
not useful
I don't think the problem is related to EABI or "old ABI". Are both 
toolchains based on the same version of the gcc sources? Let the linker 
create a map-file and checked the assigend addresses for the array and 
the start and end of the .data output-section? If there are still 
problems please create a minimal but full example with source-code incl. 
startup-code, linker-script, compiler- & linker-options (pref. in a 
makefile).

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.