attributes - [IAR]如何打印一段结束地址的开头?
问题描述
1.我在 .icf 中为 myTest 创建了一个自定义部分
define symbol __ICFEDIT_region_TEST_start__ = (0x10080000);
define symbol __ICFEDIT_region_TEST_end__ = (0x100DFFFF);
define region TEST_region = mem:[from __ICFEDIT_region_TEST_start__ to __ICFEDIT_region_TEST_end__];
place at start of TEST_region {section .test_cases_entries};
2.我在test.c中编写了一些测试代码
#pragma section = ".test_cases_entries"
void pfm_test_cases_init(void)
{
struct pwb_altest_desc *start,*stop;
start = __section_begin(".test_cases_entries");
stop = __section_end(".test_cases_entries");
printf("test section start = %x \n\r",start);
printf("test section end = %x \n\r",stop);
}
- 结果响应
test section start = 0
test section end = 0
- 预期结果:0x10080000 部分的开始?0x100DFFFF 部分结束?
解决方案
__section_begin(".section")
__section_end(".section")
如果该部分的任何部分.section
都不包含在最终二进制文件中,则为0 。在您的情况下,您首先必须确保该部分.test_case_entries
不为空,即项目中的某些模块将数据放在该部分中。然后你需要让链接器在最终的二进制文件中包含这些数据。这可以通过引用某个模块中的数据(__section_begin
并且__section_end
不计算在内)、将数据声明为__root
或--keep
在链接器命令行上使用来完成。
下面包括一个适用于我的机器的测试程序。请注意,.icf 文件并不完整,因为其中大部分取决于您的目标系统。
测试.c:
#include <stdio.h>
// Make the compiler recognize .section as a section for __section_begin and
// __section_end.
#pragma section = ".section"
void main(void)
{
// Find the start and end address of .section
int *start = __section_begin(".section");
int *stop = __section_end(".section");
printf("section start = %x \n", start);
printf("section end = %x \n", stop);
}
// Put data in .section and make the data root to ensure is is included.
// This can be in a different file.
#pragma location=".section"
__root int data[100];
test.icf 的一部分
define symbol TEST_start = (0x10080000);
define symbol TEST_end = (0x100DFFFF);
define region TEST_region = mem:[from TEST_start to TEST_end];
place at start of TEST_region {section .section};
推荐阅读
- php - PHP 警告:PHP 启动:无法加载动态库 'php_v8js.dll'
- c# - 在视图模型之间使用时,MessagingCenter Unsubscribe 在 xamarin 表单中不起作用
- javascript - 如何在反应式中获取底层复选框值?
- javascript - Java AES/ECB/PKCS5Padding加密到crypto-js解密
- r - 识别矩阵中的重复岛并更改它们的值
- python - 如何在另一个脚本中运行 Python 脚本并立即关闭自身
- javascript - 如何在多选2中更改顺序
- angular - Angular:检测拦截器内的重定向
- gitlab - 在 GitLab CI 脚本中克隆另一个 GitLab 存储库
- swift - 扩展键字典:字符串值:swift中的数组