Stored location of uninitialised varaibles

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

Stored location of uninitialised varaibles

763 Views
amit_dhand
Contributor III

Hello,

 

I am working on s12zvc demo board. I have few variables mentioned below :-

 

int b_main;

int c_main = 10;

static int d_main;

static int e_main = 23;

 

According to the definition of .bss and .data segment uninitialised varaibles should go into .bss segment and explicitly initialised variable to the .data segment.

But what I have observed is shown below :-

 

*********************************************************************************************

OBJECT-ALLOCATION SECTION

     Name               Module                 Addr   hSize   dSize     Ref    Section   RLIB

---------------------------------------------------------------------------------------------

 

- VARIABLES:

     c_main                                    1000       2       2       1   .data      

     e_main                                    1002       2       2       1   .data      

     d_main                                    1008       2       2       1   .common    

     b_main                                    100A       2       2       3   .common  

 

 

How could I change the segment from .common to .bss and I need only few variables to be there in the .bss segment.

 

Thank you.

Labels (1)
0 Kudos
3 Replies

525 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Amit ,

If you want put the variable to .bess segment, please try :

int b_main = 0;

If it still can not work , please tell me you use which CW ?

Hope it helps


Have a great day,
Alice

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

525 Views
amit_dhand
Contributor III

Hello Alice,

I am using Code-warrior for MCU s12zvc Version 10.6
I tried the initialisation of b_main with zero and checked the map file again, it shows that b_main is still in .common segment.

Is it possible to try to segment this area in LCF so that it will be directed to .bss (Block Started by Symbol) segment.

What is this .common segment => which variables comes into this segment.

Thank you

0 Kudos

525 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Amit,

(1) I also test it on the S12Z chip , yes , it still in the .common segment , no matter how i define the variable .

( before i test on  kinetis chips , when initialize it to 0 , it will place to .bss segment )

And i will continue to check ,then tell you !

(2) About the .common segment,  it also place the uninitialized variable , and you can search the .common on the web .

For example : c - .bss vs COMMON: what goes where? - Stack Overflow

BR

Alice

0 Kudos