リンカー スクリプトのロケーション カウンターに問題があります。これがバグなのか、間違った出力が予想されるのかはわかりません。
私はBSSセクションを持っています
/* Program bss, zeroed out during init. */
.bss :
{
. = ALIGN(4);
__bss_start = .;
*(.bss*)
*(.COMMON*)
. = ALIGN(4);
__bss_end = .;
__heap_start = .;
} >sram_u
__bss_size = SIZEOF(.bss);
私の問題は、(__bss_end - __bss_start)
と等しくないこと__bss_size
です。__bss_end
代わりにセクションの外に割り当てる.bss
と、期待値が得られます。elfread でセクション ヘッダーを確認すると、予想される.bss
サイズが得られます。
私が使用しているリンカーは次のとおりです。
GNU ld (GNU Tools for ARM Embedded Processors) 2.23.2.20131129
Copyright 2012 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
そしてGCC
arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.8.3 20131129 (release)
[ARM/embedded-4_8-branch revision 205641]
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
問題は、ロケーション カウンター ( .
) をセクション定義内で更新する必要があるのか、それとも使い方が間違っているのかということです。
PS: 正しい用語を使用していることを願っています...