可是g_root_inode明明在申明时已经初始化过了啊,不是该分配到.data段吗?网上查询资料并查阅gcc手册才发现一个天大的公开秘密:gcc默认将出初始化为0的全局变量分配至.bss段以减小flash占用空间!GCC有一个[url=]special option[/url]控制这样的行为:
-fno-zero-initialized-in-bss
If the target supports a BSS section, GCC by default puts variables that are initialized to zero into BSS. This
can save space in the resulting code. This option turns off this
behavior because some programs explicitly rely on variables going to
the data section. E.g., so that the resulting executable can find the
beginning of that section and/or make assumptions based on that.
The default is:-fzero-initialized-in-bss.
于是乎通过sparc-gaisler-elf-gcc -v --help命令查询我所使用的sparc-gaisler-elf-gcc是否支持该命令:
sparc-gaisler-elf-gcc的bss段分配选项