TI工程师:
您好!我在调试时发现,我声明的volatile变量,volatile关键字无用,map文件中找不到相应的地址,请问这是为啥。
例如,static volatile uint32_t testVolatile; map文件中没有testVolatile。
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
我们建议您使用 Retain pragma。
您可以使用 TI v20.2.5 编译器尝试以下示例代码:
#include <stdint.h>
#pragma RETAIN (testVolatile)
static volatile uint32_t testVolatile;
int main(void)
{
return 0;
}
当使用 -mapfile_contents=sym_defs 链接器选项时,生成的map file报告了 testVolleile 变量:
main.obj
Run/Load
Value Binding Name (Section)
-------- -------- ---------------
00000134 local $a (.text)
00000140 local .bss:retain (.bss:retain)
00000134 local .text (.text)
00000134 global main (.text)
00000140 local testVolatile (.bss:retain)