Initialized variables are put in sbss2 section

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Initialized variables are put in sbss2 section

889 Views
pierreschmidt
Contributor III

Hello, why are variables declared as:

 

CONST(uint8, SOAD_CONST) SoAd_VSockMultPdus[] =

{

  0x00u,

  0x00u,

  0x00u

};

 

put in sbss2 section?

 

As soon as other values than 0 are used, it is OK: SoAd_VSockMultPdus goes into sdata2.

 

sbss2 is for uninitialized data so there is no reason for CodeWarrior to use this sections, because 00 must be initialized.

 

This causes a bug during execution because SoAd_VSockMultPdus is not 00 (no initialization has been done).

 

So what should be done to have SoAd_VSockMultPdus in sdata2??

 

Thanks.

 

Labels (1)
Tags (2)
0 Kudos
Reply
1 Reply

501 Views
stanish
NXP Employee
NXP Employee

Hello Pierre,

I assume you are targeting PowerPC.

The default build tools settings place the zero constant data into uninitialized const section. In fact it in case sbss2 section is located in RAM it should work fine (all bss sections are zeroed by the startup copydown routine) but if it's in Flash the problem you describe may occur.

I'd recommend you to add the pragma below into your project (e.g. add into prefix file) as a workaround:


#pragma explicit_zero_data on

by default this pragma is off.

Regards

Stan

0 Kudos
Reply