Linker section .data from *.elf file is not loaded

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Linker section .data from *.elf file is not loaded

684 Views
m_botthof
Contributor I

I try to load a *.elf file into my target device (evaluation board "T42D4RDB" for QorIQ T1042). After the elf file is loaded, I find that the .data section has not been loaded into the RAM. The .text section has been loaded correctly.

My CRT0 function works so that it copies the .data section from behind the .text section to its correct position. Therefore, the .data section must be loaded from codewarrior when loading the elf file. Do you have a hint how to load the .data section by codewarrior?

Labels (1)
0 Kudos
2 Replies

527 Views
yipingwang
NXP TechSupport
NXP TechSupport

Hello M. Botthof,

You could refer to the example in the file <project>_gcc-aeabi_ROM.lcf in CodeWarrior default project.

PROVIDE (__etext = .);

 .sdata          :
    AT (_etext)
  {
    __SDATA_START__ = .;
    _sdata = . ;
    _SDA_BASE_ = . + 32768 ; *(.sdata .sdata.* .gnu.linkonce.s.*)
    _fsdata = .;
    __SDATA_END__ = .;
  } > ram
 
  _esdata = _etext + SIZEOF (.sdata);
 
  .data           :
   AT ((_etext)+SIZEOF(.sdata))
  {
     _data = . ;
    *(.data .data.* .gnu.linkonce.d.*)
     SORT(CONSTRUCTORS)
  } > ram
 


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

527 Views
m_botthof
Contributor I

Hi,

thanks for your reply. My linker file includes a .data section like yours. My problem is, that CodeWarrior loads this .data section to the linked address ("ram" address) and not to the address directly behind the .text section (from which my ctr0 will copy the .data section to the linked address).

This means, after CodeWarrior loaded the elf file, the data in RAM is correct, but when my crt0 code is executed (like it will be, when starting out of flash), it will overwrite the data in RAM.

Is there a possibility to get CodeWarrior to load the .data section right behind the .text section (the AT(...) address of .data section)?

0 Kudos