我尝试找到答案很长时间。对不起,我真的找不到。
我使用 gcc、ld、gcc(用于汇编程序编译)。
我写了 ld 脚本:
SECTIONS
{
.text : *{.text}
}
LS_size = (SIZEOF(.text) + 2048 ) & ( 0xF800 ) >> 9 ;
我尝试使用汇编程序中的 LS_size:
_rom_size:
.byte LS_size
它工作正常,但在 C 代码上我无法将值设置为变量:
struct my_struct vari = {
.codesize = LS_size,
}
如果我 extern LS_size,我得到:
error: initializer element is not constant
如何从 ld 脚本中生成的变量中为我的常量 C 变量设置默认值?