global variables in C++ in .data

Russ.Shaw russell@webaxs.net
Wed Aug 9 02:27:00 GMT 2000


.data section should go into ram, which you should force with your
linker script. Also, use the AT(<rom-addr>) option to say the .data
section is loaded from rom on start-up. That way, your crt0.o
can copy the initial values of .data variables into ram.


> Michel van Elk wrote:
> 
> Hi,
> 
> When I put global variables in a C++ file and compile em with gcc they
> are put in the .data section. In my case this means ROM so not a place
> where you want your variables to be. Does anyone know how to get these
> globals in the .bss section ? If I rename the file to .C the variable is put
> in the .bss section, just as I would expect.
> 
> Thanks !!
> 
> Michel van Elk
> 

-- 
*******************************************
*   Russell Shaw, B.Eng, M.Eng(Research)  *
*      email: russell@webaxs.net          *
*      Australia                          *
*******************************************



More information about the Gcc-help mailing list