user2807984
user2807984

Reputation: 23

ARM GNU GCC trying to zero out the .bss section

I am having a problem,

ARM GNU GCC is trying to 'zero' the .bss section , I dont want it to do it as my startup code is doing it already. Due to this the final image size is increased by the bss size filled with zero's .

I am already using NOLOAD in the linker script for bss section and -fno-zero-initialized-in-bss as part of CFLAGS for gcc.

How do I tell ARM GNU GCC not to zero out that section ?Am I missing something?

Upvotes: 0

Views: 1885

Answers (2)

Staszek
Staszek

Reputation: 951

For anyone that come here from Google 11 years later - make sure, that all your NOLOAD sections are at the end of the linker script. If you put .bss (NOLOAD) section, and then after that there is anything that needs to be loaded (eg. .ARM.exidx), then linker will generate binary with .bss section filled with zeros.

Upvotes: 1

fukanchik
fukanchik

Reputation: 2865

Here is the answer directly from ARM: How to prevent uninitialized data from being initialized to zero

You can prevent uninitialized data from being initialized to zero by placing that data in a different section. This can be achieved using #pragma arm section, or with the GNU compiler extension attribute((section("name"))).

#pragma arm section zidata = “non_initialized”
int i, j; // uninitialized data in non_initialized section (without the pragma, would be in .bss section by default)
#pragma arm section zidata // back to default (.bss section)
int k = 0, l = 0; // zero-initialized data in .bss section

Upvotes: 0

Related Questions