연속 변수

기술노트 75313

아키텍처:

ARM

컴포넌트:

linker

업데이트:

2018-02-28 오전 2:53

Introduction

This technical note is focused on the need to force fixed order of placement in RAM, that is, for situations when making a 'struct' isn't feasible.

Example projects are found in the Example project (ContiguousVariables).zip .

Issue 1

Using pragma location you can place variables in a section, but the .map file shows that the variables are placed in arbitrary order.

Solution 1

To enforce order between variables, place variables in separate sections and then declare a "fixed order block" to define the order between the variables, i.e. the order of the sections.

Note that this "fixed order block" will also be placed at an arbitrary location, but with linker directives the placement of the block can be controlled.

Example of C source showing variables placed in separate sections named "1st", "2nd" and "3rd":

int ab[]   @ "1st" = {1, 2, 3, 4, 5, 6, 7, 8};
int a[] @ "2nd" = {1, 2, 3, 4, 5 };
int abc[] @ "3rd" = {1, 2, 3, 4, 5, 6, 7};

Example of linker configuration directives defining the order between the sections where the variables are located:

define block ARRAYS with fixed order
{
section 1st,
section 2nd,
section 3rd
};

place in RAM_region { first block ARRAYS, readwrite, ... };

// The directive "first block" will place the block first in the RAM_region.

Issue 2

Instead of section "2nd", in the above example, some reserved RAM space is needed between the variables in section "1st" and "3rd".

Solution 2

Define a block which is placed between the variables and then use the linker directive "keep" to force the block to be included.

Modify the .icf file in the above example and use the following linker directives:

define block RESERVED_SPACE with alignment = 8, size = 1024 { };

define block ARRAYS with fixed order
{
section 1st,
block RESERVED_SPACE,
section 3rd
};

keep { block RESERVED_SPACE };

 

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

죄송하지만, 당사 사이트에서는 Internet Explorer를 지원하지 않습니다.보다 편안한 사이트를 위해 Chrome, Edge, Firefox 등과 같은 최신 브라우저를 사용해 주시길 부탁드립니다.