Linking blocks in a specified order

Technical Note 92924

Architectures:

ARM, RL78, RX, SH, STM8

Component:

linker

Updated:

2018/5/31 9:14

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.

很抱歉,该页面尚未翻译成中文。

如果您有任何问题,请联系我们的中国团队

We do no longer support Internet Explorer. To get the best experience of iar.com, we recommend upgrading to a modern browser such as Chrome or Edge.