String literals allocation.

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

String literals allocation.

367 Views
daniel_aciubota
Contributor I

Hello,

I have the following global variable definition in a fresh bareboard project for MC9S12ZVML128 created with CW 10.6.4 (S12Z compiler 1.0.5).

char const *pcc = "abcdefghijklmnopq";

After a build, the map file shows the following:

- pcc is allocated to section .data (expected)

- pcc points to an address from section .data (unexpected )

It seems that the string literal is stored in section .copy and used to initialize a variable from .data to which pcc points to in the end.

Based on the linker documentation and the content of the .prm file I was expecting the string literal to end up in the ROM segment (.rodata1 section) and pcc to point to the ROM address of the literal.

Here is the link of the documentation that I used:

https://www.nxp.com/docs/en/reference-manual/Build_Tools_Utilities.pdf

Is this behavior correct and if so what's the explanation ? 

Thank you.

0 Kudos
0 Replies