String literals allocation.

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

String literals allocation.

362件の閲覧回数
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 返答(返信)