【发布时间】:2013-12-11 15:42:09
【问题描述】:
我正在使用 gcc 为 pic32 微控制器创建一个 hex 文件,我需要将配置字放在程序闪存中的特殊内存地址。
我正在使用这个简单的链接器脚本:
MEMORY {
boot_flash : ORIGIN = 0x1FC00000, LENGTH = 0xBF0
sfr : ORIGIN = 0x1F800000, LENGTH = 0x100000
program_flash : ORIGIN = 0x1D000000, LENGTH = 0x20000
ram : ORIGIN = 0x00000000, LENGTH = 0x8000
config0 : ORIGIN = 0xBFC02FFC, LENGTH = 0x4
config1 : ORIGIN = 0xBFC02FF8, LENGTH = 0x4
config2 : ORIGIN = 0xBFC02FF4, LENGTH = 0x4
config3 : ORIGIN = 0xBFC02FF0, LENGTH = 0x4
}
SECTIONS {
.text : {
*( .text )
} >boot_flash
.text : {
*(.text)
} >program_flash
.bss : {
*( .bss )
} >ram
.data : {
*( .data )
} >ram
.config0 : {
*( .config0 )
} >config0
.config1 : {
*( .config1 )
} >config1
.config2 : {
*( .config2 )
} >config2
.config3 : {
*( .config3 )
} >config3
}
然后,我编译这个简单的代码:
...
uint32_t config0 __attribute__ ((section(".config0"))) = 0xFFFFFFFF;
uint32_t config1 __attribute__ ((section(".config1"))) = 0xFFFFAF0F;
uint32_t config2 __attribute__ ((section(".config2"))) = 0xFFFFFDFF;
uint32_t config3 __attribute__ ((section(".config3"))) = 0xFFFFFDFF;
...
最后,我检查了mips-elf-objdump 生成的 ELF 文件。代码和数据都可以,但输出 ELF 中没有 .config 部分。
我做错了什么?
【问题讨论】: