我正在使用gcc創建一個pic32微控制器的十六進制文件,我需要將配置文件放在程序flash中的特殊內存地址中。鏈接描述文件部分沒有出現在ELF上
我使用這個簡單的鏈接腳本:
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
部分。
我在做什麼錯?
使用你的解決方案,編譯器生成訪問變量的代碼,但沒有定義ELF部分:'dummy = config0;'在'.text'節生成以下MIPS代碼:'lui v0, 0xbfc0; lw v012284(v0); sw v0,28(gp)': - /謝謝。 – avelinoherrera