1
我試圖生成一個映像,其中有一小部分代碼用於初始化電路板(樹莓派2B),將剩餘的內容複製到高端內存中並開始運行其餘代碼那裏。鏈接描述文件有什麼問題
這個想法是,首先將整個圖像加載到0x8000處,然後將「函數」複製到高端內存並啓動,然後放棄0x8000中的內容。
它不起作用。我得到的錯誤從LD:
...
/bin/ld: address 0x124ac of loader.elf section `.text2' is not within region `EXEC'
...
/bin/ld: address 0x1ff18 of loader.elf section `.bss' is not within region `EXEC'
...
/bin/ld: address 0x124ac of loader.elf section `.text2' is not within region `EXEC'
...
/bin/ld: address 0x1ff18 of loader.elf section `.bss' is not within region `EXEC'
...
/bin/ld: address 0x124ac of loader.elf section `.text2' is not within region `EXEC'
...
/bin/ld: address 0x1ff18 of loader.elf section `.bss' is not within region `EXEC'
...
/bin/ld: region `EXEC' overflowed by -520487144 bytes
collect2: error: ld returned 1 exit status
make: *** [loader.elf] Error 1
make: Target `all' not remade because of errors.
我的鏈接腳本:
ENTRY(_start)
MEMORY
{
LOAD (rwx) : ORIGIN = 0x00008000, LENGTH = 512k /* initial */
EXEC (rwx) : ORIGIN = 0x1f000000, LENGTH = 512k /* runtime */
}
SECTIONS
{
/* Starts at LOADER_ADDR. */
. = 0x8000;
__text_start = .;
.text :
{
*(.init)
*start1.o(.text)
*start1.o(.data)
*start1.o(.bss)
*(.text.startup)
} >LOAD
.text2 ALIGN(0x1000):
{
__code_begin = .;
*loader.o(.text)
*rpi2.o(.text)
*serial.o(.text)
*util.o(EXCLUDE_FILE(*instr_util.o).text)
*gdb.o(.text)
*(.text)
} >EXEC AT>LOAD
__text_end = .;
__data_start = .;
.data :
{
*(.data)
} >EXEC AT>LOAD
__data_end = .;
__bss_start = .;
.bss ALIGN(0x8):
{
bss = .;
*(.bss)
stacks = .;
. = . + 512; /* fiq stack size */
__fiq_stack = .;
. = . + 1024; /* usr & sys stack size (common) */
__usrsys_stack = .;
. = . + 16384; /* svc stack size (start-up) */
__svc_stack = .;
. = . + 4096; /* irq stack size (serial) */
__irq_stack = .;
. = . + 512; /* mon stack size */
__mon_stack = .;
. = . + 512; /* hyp stack size */
__hyp_stack = .;
. = . + 512; /* und stack size */
__und_stack = .;
. = . + 16384; /* abrt stack size (gdb-stub) */
__abrt_stack = .;
} >EXEC AT>LOAD
__bss_end = .;
__new_org = 0x1f000000;
/* gcc-generated crap */
.note :
{
*(.note.*)
} >LOAD
.debug :
{
*(.debug*)
} >LOAD
__end = .;
}
它正常工作,當我只用> LOAD無處不(都在較低的內存)。 程序並不大:
0x0001ff18 __bss_end = .
0x00032098 __end = .
忘了提:這是一個裸機程序。
[編輯] 滑稽,這個工作(但我寧願 '鏈狀' ...)
.text2 0x1e000000:
{
__code_begin = .;
*loader.o(.text)
*rpi2.o(.text)
*serial.o(.text)
*util.o(EXCLUDE_FILE(*instr_util.o).text)
*gdb.o(.text)
*(.text)
} AT>LOAD
[/編輯]