5
我創建了一個內存鏈接腳本並將其保存爲memory.ld在Eclipse IDE:項目:屬性:GCC鏈接:雜項:我添加-M -T memory.ld如何解決鏈接器腳本中的錯誤?
memory.ld:
MEMORY
{
ram (rw) : ORIGIN = 0x4000000 , LENGTH = 2M
}
SECTIONS
{
RAM : { *(.myvarloc)
} > ram }
在我的C程序:我做了一個全球性的聲明爲:
__attribute__ ((section(".myvarloc")))
uint8 measurements [30];
錯誤:
/usr/bin/ld: FEBRUARY section `.text' will not fit in region `ram'
/usr/bin/ld: region `ram' overflowed by 20018 bytes
/usr/lib/i386-linux-gnu/libc_nonshared.a(elf-init.oS): In function `__libc_csu_init':
(.text+0x2b): undefined reference to `__init_array_end'
/usr/lib/i386-linux-gnu/libc_nonshared.a(elf-init.oS): In function `__libc_csu_init':
(.text+0x31): undefined reference to `__init_array_start'
/usr/lib/i386-linux-gnu/libc_nonshared.a(elf-init.oS): In function `__libc_csu_init':
(.text+0x57): undefined reference to `__init_array_start'
/usr/bin/ld: FEBRUARY: hidden symbol `__init_array_end' isn't defined
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
錯誤與'.text' /'ram'不是'.myvarloc'溢出有關。 – anishsane
您的鏈接器腳本可能需要告訴鏈接器如何處理其他代碼/數據等,而不僅僅是如何處理.myvarloc部分 – nos
非常感謝您的答覆。你能給我舉個例子嗎? – user3252048