pic32 8字节上的静态变量
由于某种原因,当我将这两个变量提供“使用”属性时,编译器使它们长8个字节。没有它,编译器将它们优化,因为我不使用它们(尚未使用)。有人知道为什么这是吗?并且有任何已知的解决方法吗?
__attribute__ ((used,section(".booter_version"))) static uint32_t BooterVersion = 2;
__attribute__ ((used,section(".hardware_version"))) static uint32_t HardwareVersion = 3;
包含这些部分的LinkerScript部分:
/* booter version number is placed at the second last 4 bytes of program mem for the booter*/
.BooterVersion _BOOTER_VERSION_ADDRESS :
{
KEEP (*(.booter_version))
} >kseg0_program_mem
/* hardware version number is placed at the end of program mem for the booter */
.HardwareVersion _HARDWARE_VERSION_ADDRESS :
{
KEEP (*(.hardware_version))
} >kseg0_program_mem
编译后的内存图中的图像(在程序MEM中,您会看到最后两行):
For some reason, when I give these two variables the "used" attribute, the compiler makes them 8 bytes long. Without it, the compiler optimizes them away as I don't use them (yet). Anyone knows why this is? And are any workarounds for this known?
__attribute__ ((used,section(".booter_version"))) static uint32_t BooterVersion = 2;
__attribute__ ((used,section(".hardware_version"))) static uint32_t HardwareVersion = 3;
Linkerscript part with these sections:
/* booter version number is placed at the second last 4 bytes of program mem for the booter*/
.BooterVersion _BOOTER_VERSION_ADDRESS :
{
KEEP (*(.booter_version))
} >kseg0_program_mem
/* hardware version number is placed at the end of program mem for the booter */
.HardwareVersion _HARDWARE_VERSION_ADDRESS :
{
KEEP (*(.hardware_version))
} >kseg0_program_mem
Image from the memory map after compiling (in program mem, you see the last two lines for these):
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论