String literals allocation.

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

String literals allocation.

534 次查看
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 项奖励
回复
0 回复数