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.
工具/软件:Code Composer Studio
大家好,
我正在尝试找出在代码中引用链接器文件中定义的内存段的起始地址和长度的最佳方法。
我已经找到了一种方法来完成这项工作,但这似乎有点古怪,我想知道是否有一种更干净的方法来完成这项工作。
例如,我的链接程序文件中将包含以下内容:
#define test_address_LOC 0x1.5万 #define test_address_LEN 0x1000 test_address = test_address_LOC; 内存 { test_section: origin = test_address_LOC,length = test_address_LEN } sections { .testSection :{}> test_section type=NOINIT }
然后在代码中定义
extern volatile unsigned long test_address;
并使用test_address作为源站指针(与编译器映射注册地址的方式非常相似)。
虽然这项工作已经完成,但有没有一种更干净的方法可以在不需要使用变量的情况下执行此操作(在这种情况下,我只需访问节的起始地址和长度,而无需在链接程序文件的两个位置定义它), 或者,我是否可以将test_address的值分配给test_section的来源?
这怎么样? 请将这些行...
Christopher Carl 说:#define test_address_LOC 0x1.5万
#define test_address_LEN 0x1000
头文件中的...。 #在C代码和链接程序命令文件中都包含该标题。 然后更改...
extern volatile unsigned long test_address;
像这样的东西...
volatile unsigned long *特殊指针= test_address_loc;
那么您不需要变量test_address。
更改主题。 这是一件小事,但我想我要指出一下。 这...
Christopher Carl 说:测试部分:Origin = test_address_LOC,length = test_address_LEN
...不是一个部分,而是一个记忆范围。 因此,如果您使用名称test_memory_range而不是test_section.
谢谢,此致,
-George