ld: giving section a load address?
Posted: Fri Sep 25, 2015 4:22 pm
What's wrong with my loader script?
(there's more, but this should give the idea...)
The loader gives me:
The idea is to link stuff in .text to load and run in 0x8000 ... and .text2 and the rest to run in 0x1e000000... and to load right after the .text. (The code in .text copies the rest to 0x1e000000 on.)
If I direct everything to LOAD and and don't give a separate loading address, the code compiles and runs fine.
Only .init contains assembly code. The rest is C (except some inline asm without any absolute addresses).
(there's more, but this should give the idea...)
Code: Select all
ENTRY(_start)
MEMORY
{
LOAD (rwx) : ORIGIN = 0x00008000, LENGTH = 512k /* initial */
EXEC (rwx) : ORIGIN = 0x1e000000, 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 = .;
Code: Select all
/home/jaa/RasPi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: address 0xf8e8 of loader.elf section `.text2' is not within region `EXEC'
/home/jaa/RasPi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: loader.elf section `.rodata.str1.4' will not fit in region `EXEC'
/home/jaa/RasPi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: address 0x1d350 of loader.elf section `.bss' is not within region `EXEC'
/home/jaa/RasPi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: address 0xf8e8 of loader.elf section `.text2' is not within region `EXEC'
/home/jaa/RasPi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: address 0x1d350 of loader.elf section `.bss' is not within region `EXEC'
/home/jaa/RasPi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: address 0xf8e8 of loader.elf section `.text2' is not within region `EXEC'
/home/jaa/RasPi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: address 0x1d350 of loader.elf section `.bss' is not within region `EXEC'
/home/jaa/RasPi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: region `EXEC' overflowed by -503721136 bytes
collect2: error: ld returned 1 exit status
If I direct everything to LOAD and and don't give a separate loading address, the code compiles and runs fine.
Only .init contains assembly code. The rest is C (except some inline asm without any absolute addresses).