[M16C-ELF] : Problem accessing "constant" data that is placed in ROM.

Prafulla Thakare PrafullaT@KPITCummins.com
Thu Dec 22 12:39:00 GMT 2005


Hi,

I have downloaded latest GCC and Binutils sources from FSF for M16C 
port. Using these sources, I could successfully build the cross 
toolchain i.e. m32c-elf-*.

However, I am facing a problem while accessing the "const" data and 
hard-coded strings which by default get placed in section ".rodata".

Note that, for the M16C-62P target which I am using, ROM memory region 
starts at memory location "0x000A0000" (i.e. 20 bit address). 
Therefore, as the pointer size for GCC M16C is two bytes, it fails to 
access this memory region.

I have further noticed that, ".plt" section is used for handling the  
"function pointers" and ".rodata" section (both are 20 bit addressable).

However, for this to work on actual hardware, I had to copy the ".plt" 
section from ROM (load address) to RAM at runtime. I am doing this in 
my own start-up code. After doing the above changes, I could get my 
function pointer working with actual hardware.

But, this does not solve my problem for accessing constant data and 
strings placed in ROM. 
As a workaround, I am currently copying the complete ".rodata" section 
from load address (ROM) to RAM, that is by treating it similar to
".data" 
section.

However, this is not the expected behavior, especially when using 
hardware. My ".rodata" should be in ROM all the time. 

I have noticed that, ".plt" stores a pointer to start of ".rodata" 
section. I would like to know, how it can be used without actually 
copying the ".rodata" section to RAM. 

Thanks in advance.

Regards,
Prafulla Thakare
KPIT Cummins InfoSystems Ltd.
Pune, India

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Free download of GNU based tool-chains for Renesas' SH and H8 Series.
The following site also offers free technical support to its users. 
Visit http://www.kpitgnutools.com for details. 
Latest versions of KPIT GNU tools were released on October 12, 2005.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



More information about the Gcc-help mailing list