- IAR Embedded Workbench for Arm 9.70.x
- IAR C/C++ 開発
- リンカ設定ファイル
- セクションの取扱い
- use init tableディレクティブ
use init tableディレクティブ
構文
use init tablenamefor {section-selectors} [ except {section-selectors} ];
section-selectorsおよびexcept句については、セクションの選択を参照してください。
パラメータ
|
|
説明
すべての初期化エントリは通常、1つの初期化テーブル(Table)にまとめて生成されます。このディレクティブを使用して、一部のエントリが別のテーブルに配置されるようにします。この初期化テーブルは別のときに使用したり、通常の初期化テーブルではない異なる状況で使用することができます。
use init tableディレクティブで言及されていないすべての変数の初期化エントリは、通常の初期化テーブルに入れられます。複数のuse init tableディレクティブを使用すると、複数の初期化テーブルを持つことができます。
init テーブルの開始、終了、サイズは"Region$$name"の__section_begin、__section_end、__section_sizeをそれぞれ使用するか、シンボルRegion$$name$$Base、Region$$name$$Limit、Region$$name$$Lengthを使用して、アプリケーションプログラムでアクセスすることができます。
初期化関数 IAR_TABLE_INIT は、初期化テーブルの開始と終了アドレスで機能し、インクルードファイル stdlib.h で利用できます。use init tableを使用して作成した初期化テーブルの開始と終了アドレスで関数を呼び出すと、そのテーブルのすべての初期化エントリを初期化します。
注記
スタック使用量解析は、すべての初期化エントリを通常の初期化ルーチンで呼び出されたように扱います(IAR_DATA_INIT)。これにより、IAR_TABLE_INIT など、別の場所から呼び出される初期化エントリのスタック使用情報が正しくなくなります。ほとんどのスタックが使用されているときにそのような関数が呼び出されると、スタック使用量解析がこれを検出せずに、使用されるスタックが多すぎになる可能性があります。動的な初期化の初期化関数とルーチンは、通常小さいスタックスペースを使用するので、重大な問題になることはほとんどありません。
例
この例では、use init table ディレクティブはリンカ設定ファイルにあり、そのほかの例はCファイルにあります。
use init table Core2 for { section *.core2};
/* This code example needs IAR language extensions to handle
__section_begin. */
#include <stdlib.h>
/* This sets up the name of the table and ensures that pointers
to it have the correct attributes. */
#pragma section="Region$$Core2" const _DLIB_ELF_INIT_TABLE_MEMORY
/* Calling this function will result in all initialization
functions in the Core2 table being called. This must be called
before any of the data/objects are accessed. Nothing prevents
the data/objects from being accessed before they are
initialized and nothing prevents the data from being
initialized more than once (data is typically overwritten by
the initial values if it is initialized more than once). */
void HandleCore2Init()
{
IAR_TABLE_INIT(__section_begin("Region$$Core2"),
__section_end ("Region$$Core2"));
}