Skip to content

Migrating from LD to IAR ILINK

Felipe Torrezan edited this page Aug 28, 2023 · 1 revision

There is no international ISO standard for linker configuration files. This gives flexibility for each implementation to provide special-use options.

When you first select a target in IAR Embedded Workbench, you are selecting a default linker configuration for the selected device.

However, there are situations where a custom linker configuration might be required. The IAR ILINK Configuration syntax is simple and intuitive once you get acquainted to it.

Below you will find some examples showing fragments with the most important differences between linker configurations for the GNU Linker (ld) and for the IAR ILINK Linker.

Application entry point

GNU IAR
ENTRY(Reset_Handler)            
Automatically to points to __iar_program_start.
Can be overriden using the linker option --entry Reset_Handler or
via Project's Linker Options in the IDE.

Stack and Heap

GNU IAR
_estack = 0x20010000;
_Min_Heap_Size = 0x1000;
_Min_Stack_Size = 0x1000;       
/* Define STACK and HEAP blocks */
define block CSTACK with alignment = 8, size = 0x1000 { };    
define block HEAP   with alignment = 8, size = 0x1000 { };

Memory regions

GNU IAR
MEMORY
{
 FLASH (rx): ORIGIN = 0x08000000, LENGTH = 256K
 RAM  (xrw): ORIGIN = 0x20000000, LENGTH = 64K
 MEM1  (rx): ORIGIN = 0x60000000, LENGTH = 1M
}
define memory mem with size = 4G;
define region FLASH = mem:[from 0x08000000 size 256k];    
define region RAM   = mem:[from 0x20000000 size 64k];
define region MEM1  = mem:[from 0x60000000 size 1M];

Section allocation

GNU IAR
SECTIONS
{
 .isr_vector :
 {
  . = ALIGN(4);
  KEEP(*(.isr_vector))
  . = ALIGN(4);
 } >FLASH

 .sidata = .;

 .data : AT ( _sidata )
 {
  . = ALIGN(4);
  _sdata = .;
  *(.data)
  *(.data*)
  . = ALIGN(4);
  _edata = .;
 } >RAM

 ._user_heap_stack :
 {
  . = ALIGN(4);
  . = . + _Min_Heap_Size;
  . = . + _Min_Stack_Size;
  . = ALIGN(4);
 } >RAM
}
initialize by copy { rw };
do not initialize  { section .noinit };

place at address mem:0x08000000 { ro section .intvec };

place in FLASH { ro };
place in RAM   { rw,
                 block CSTACK,
                 block HEAP };