initiallizing global pointers with the address of a string literal, in PI code.

Hello all,

I am working on a position independent program whose startup procedure is handled manually.

when I declare an global pointer expression like

char *pTest = "TEST";

its strangely being located in bss and it is not possible to initialize pTest pointer with the address of constant string.


If I force it to locate in a particular section, like char *pTest __attribute((section(.data.pTest)))__ = "TEST"

lval is located in .data section and it has an execution adress, but address of rval is missing. I see 4 bytes of zero in the load address of execution region instead address of "TEST" string.

I can see "TEST" string in binary file but its address is not exist in LOAD$$"section"$$RW$$Base area, thus startup procedure initialize pTest pointer with zero and this couse wrong access in the runtime.


This problem exist only in position independed code, for global pointer initialization with string literals,

if I use initialized global arrays such as, char testarray[4] = {1, 2, 3, 4}

or global pointer initialized with numeric literal such as char *pTest __attribute((section(.data.pTest)))__ = (char *)0x11223344;

or in normal programs which has a main()

everything is located in correct places and startup procedure works correct.


so how can initialize global pointers with the address of a string literal in PI code.

thanks for any help