0

Code Composer では、リンカー コマンド ファイルで新しいシンボルを簡単に定義できます。

_Addr_start = 0x5C00;
_AppLength  = 0x4C000;

メモリマップとセクションの割り当ての前。これは、TI のブートローダの例で行われます。

次に、Cコードでアドレスを(整数として)次のように参照できます

extern uint32_t _Addr_start; // note that uint32_t is fake. 
extern uint32_t _AppLength;  // there is no uint32_t object allocated

printf("start = %X len= %X\r\n", (uint32_t)&_Addr_start, (uint32_t)&_AppLength);

問題は、「小さい」メモリ モデルを使用すると、後者のシンボル (0x45C00) が 16 ビット ポインターにキャストしようとするため、リンカーに警告が表示されることです。

"C:/lakata/hardware-platform/CommonSW/otap.c", line 78: warning #17003-D: 
relocation from function "OtapGetExternal_CRC_Calc" to symbol "_AppLength"
overflowed; the 18-bit relocated address 0x3f7fc is too large to encode in
the 16-bit field (type = 'R_MSP_REL16' (161), file = "./otap.obj", offset =
0x00000002, section = ".text:OtapGetExternal_CRC_Calc")

明示的なfarポインターを使用してみましたが、コード コンポーザーはキーワードを理解していませんfar。ダミーシンボルを関数ポインターにして、コンパイラーをだまして逆参照すると....ポインターがコード空間を指し、コード空間モデルが「大」であるのに対し、データ空間モデルは「小」です。 .

4

1 に答える 1

0

質問を入力し終わる前に、私はそれを理解しました!

シンボルを次のように宣言する代わりに

extern uint32_t _AppLength; // pretend it is a dummy data

として宣言します

void _AppLength(void); // pretend it is a dummy function

&_AppLengthが想定されているため、ポインタ変換は適切に機能しますfar。(整数として宣言すると、&_AppLengthとみなされnear、リンカは失敗します。)

于 2013-11-07T00:55:47.940 に答える