Linking blocks in a specified order

Technical Note 92924

Targets:
ARM, RL78, RX, SH, STM8

Component:
Linker

Updated:
5/13/2014 3:21 PM

Introduction

This tech note covers how to get IAR ILINK Linker to link the output in a specified order.

Background

When linking the linked sections and blocks are linked in an arbitrary order, (this is so by design).

Solution

The linker directive define block can be complemented with a fixed order parameter to get fixed order.

Example 1

Often (in the .icf files) the directive for placement in RAM looks like:

place in RAM_region { readwrite,
block CSTACK, block SVC_STACK, block IRQ_STACK, block FIQ_STACK,
block UND_STACK, block ABT_STACK, block HEAP };

To get fixed placement replace the above directive with these two directives:

define block FIXED_ORDER_RAM with fixed order { block CSTACK, 
block SVC_STACK, block IRQ_STACK, block FIQ_STACK,
block UND_STACK, block ABT_STACK, block HEAP};

place in RAM_region { readwrite, last block FIXED_ORDER_RAM };

Example 2

The example project ( Example 2 (ARM).zip , Example 2 (RX).zip , Example 2 (SH).zip) contains a buildable example placing blocks in a specified order in both the ROM and RAM regions.

Further reading

The Define Block directive is documented in the Section handling chapter in the Development Guide.

All product names are trademarks or registered trademarks of their respective owners.

Related Tech Notes

© IAR Systems 1995-2016 - All rights reserved.