static initialization does not work with arm-none-eabi

Guest #2278074
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.
#2278077
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.
Guest #2278193
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 ?
Moderator #2278326
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).

Reply

A question of your own? This thread is over 15 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.