AnsweredAssumed Answered

Relocating code and data - unsure about differences between example linker file and default linker file

Question asked by gorakk on Apr 22, 2015
Latest reply on Apr 22, 2015 by Carlos_Mendoza

I am working on placing some code into RAM.  Using: CodeWarrior 10.6, GCC C compiler, MQX 4.1.1, TWR-K60F120M

 

This document: Relocating Code and Data Using the CW GCC Linker File for Kinetis

 

shows the following .ld file example in section 4.3 Relocating Code in RAM - ‘.mydata’ has been added to the ‘.data’ section (line 8):

 

/* Initialized data sections goes into RAM, load LMA copy after code */ .data : AT(___ROM_AT) {      . = ALIGN(4);      _sdata = .; /* create a global symbol at data start */      *(.data) /* .data sections */      *(.data*) /* .data* sections */      *(.mydata) /* .mydata relocates a function on any RAM address */      . = ALIGN(4);      _edata = .; /* define a global symbol at data end */ } > m_data

 

But when I look at the .ld file for my project, the .data section is quite different:

 

    .data :     {         . = ALIGN(128);         /* create _sdata symbol which keep          relocation(execution) address of data start */         _sdata = .;         __VECTOR_TABLE_RAM_START = .;         KEEP(*(.vectors_ram))           . = ALIGN(512);         __BDT_BASE = .;         *(.usb_bdt)         __BDT_END = .;           . = ALIGN(0x4);         *(.exception)         . = ALIGN(0x4);         __exception_table_start__ = .;         __exception_table_end__ = .;           __START_DATA = .;         *(.data*)         *(.mydata)         __END_DATA = .;           . = ALIGN(0x4);         __START_SDATA = .;         *(.sdata*)         __END_SDATA = .;           . = ALIGN(0x4);         __SDA_BASE  = .;         __SDA_BASE_ = __SDA_BASE;           . = ALIGN(0x10);         /* create _edata symbol which keep          relocation(execution) address of data end */         _edata = .;     } > ram AT> rom

 

I added '*(.mydata)' on line 26 .  Is that the correct placement?  When I build the project and then look at the generated .map file it appears that the function is placed correctly in RAM but I would appreciate it if someone could verify the placement of '*(.mydata)' to the linker file.

Outcomes