123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- PROVIDE(_stext = ORIGIN(REGION_TEXT));
- PROVIDE(_stack_start = ORIGIN(REGION_STACK) + LENGTH(REGION_STACK));
- PROVIDE(_max_hart_id = 0);
- PROVIDE(_hart_stack_size = 2K);
- PROVIDE(_heap_size = 0);
- EXTERN(ExceptionHandler);
- PROVIDE(InstructionMisaligned = ExceptionHandler);
- PROVIDE(InstructionFault = ExceptionHandler);
- PROVIDE(IllegalInstruction = ExceptionHandler);
- PROVIDE(Breakpoint = ExceptionHandler);
- PROVIDE(LoadMisaligned = ExceptionHandler);
- PROVIDE(LoadFault = ExceptionHandler);
- PROVIDE(StoreMisaligned = ExceptionHandler);
- PROVIDE(StoreFault = ExceptionHandler);;
- PROVIDE(UserEnvCall = ExceptionHandler);
- PROVIDE(SupervisorEnvCall = ExceptionHandler);
- PROVIDE(MachineEnvCall = ExceptionHandler);
- PROVIDE(InstructionPageFault = ExceptionHandler);
- PROVIDE(LoadPageFault = ExceptionHandler);
- PROVIDE(StorePageFault = ExceptionHandler);
- EXTERN(DefaultHandler);
- PROVIDE(SupervisorSoft = DefaultHandler);
- PROVIDE(MachineSoft = DefaultHandler);
- PROVIDE(SupervisorTimer = DefaultHandler);
- PROVIDE(MachineTimer = DefaultHandler);
- PROVIDE(SupervisorExternal = DefaultHandler);
- PROVIDE(MachineExternal = DefaultHandler);
- SECTIONS
- {
- .text.dummy (NOLOAD) :
- {
-
- . = ABSOLUTE(_stext);
- } > REGION_TEXT
- .text _stext :
- {
-
-
- KEEP(*(.init));
- KEEP(*(.init.rust));
- . = ALIGN(4);
- KEEP(*(.init.trap));
- . = ALIGN(4);
- *(.trap);
- *(.trap.rust);
- *(.text.abort);
- *(.text .text.*);
- } > REGION_TEXT
- .rodata : ALIGN(4)
- {
- *(.srodata .srodata.*);
- *(.rodata .rodata.*);
-
- . = ALIGN(4);
- } > REGION_RODATA
- .data : ALIGN(${ARCH_WIDTH})
- {
- _sidata = LOADADDR(.data);
- _sdata = .;
-
- PROVIDE(__global_pointer$ = . + 0x800);
- *(.sdata .sdata.* .sdata2 .sdata2.*);
- *(.data .data.*);
- . = ALIGN(${ARCH_WIDTH});
- _edata = .;
- } > REGION_DATA AT > REGION_RODATA
- .bss (NOLOAD) : ALIGN(${ARCH_WIDTH})
- {
- _sbss = .;
- *(.sbss .sbss.* .bss .bss.*);
- . = ALIGN(${ARCH_WIDTH});
- _ebss = .;
- } > REGION_BSS
-
- .heap (NOLOAD) :
- {
- _sheap = .;
- . += _heap_size;
- . = ALIGN(4);
- _eheap = .;
- } > REGION_HEAP
-
- .stack (NOLOAD) :
- {
- _estack = .;
- . = ABSOLUTE(_stack_start);
- _sstack = .;
- } > REGION_STACK
-
-
- .got (INFO) :
- {
- KEEP(*(.got .got.*));
- }
- .eh_frame (INFO) : { KEEP(*(.eh_frame)) }
- .eh_frame_hdr (INFO) : { *(.eh_frame_hdr) }
- }
- ASSERT(ORIGIN(REGION_TEXT) % 4 == 0, "
- ERROR(riscv-rt): the start of the REGION_TEXT must be 4-byte aligned");
- ASSERT(ORIGIN(REGION_RODATA) % 4 == 0, "
- ERROR(riscv-rt): the start of the REGION_RODATA must be 4-byte aligned");
- ASSERT(ORIGIN(REGION_DATA) % ${ARCH_WIDTH} == 0, "
- ERROR(riscv-rt): the start of the REGION_DATA must be ${ARCH_WIDTH}-byte aligned");
- ASSERT(ORIGIN(REGION_HEAP) % 4 == 0, "
- ERROR(riscv-rt): the start of the REGION_HEAP must be 4-byte aligned");
- ASSERT(ORIGIN(REGION_TEXT) % 4 == 0, "
- ERROR(riscv-rt): the start of the REGION_TEXT must be 4-byte aligned");
- ASSERT(ORIGIN(REGION_STACK) % 4 == 0, "
- ERROR(riscv-rt): the start of the REGION_STACK must be 4-byte aligned");
- ASSERT(_stext % 4 == 0, "
- ERROR(riscv-rt): `_stext` must be 4-byte aligned");
- ASSERT(_sdata % ${ARCH_WIDTH} == 0 && _edata % ${ARCH_WIDTH} == 0, "
- BUG(riscv-rt): .data is not ${ARCH_WIDTH}-byte aligned");
- ASSERT(_sidata % ${ARCH_WIDTH} == 0, "
- BUG(riscv-rt): the LMA of .data is not ${ARCH_WIDTH}-byte aligned");
- ASSERT(_sbss % ${ARCH_WIDTH} == 0 && _ebss % ${ARCH_WIDTH} == 0, "
- BUG(riscv-rt): .bss is not ${ARCH_WIDTH}-byte aligned");
- ASSERT(_sheap % 4 == 0, "
- BUG(riscv-rt): start of .heap is not 4-byte aligned");
- ASSERT(_stext + SIZEOF(.text) < ORIGIN(REGION_TEXT) + LENGTH(REGION_TEXT), "
- ERROR(riscv-rt): The .text section must be placed inside the REGION_TEXT region.
- Set _stext to an address smaller than 'ORIGIN(REGION_TEXT) + LENGTH(REGION_TEXT)'");
- ASSERT(SIZEOF(.stack) > (_max_hart_id + 1) * _hart_stack_size, "
- ERROR(riscv-rt): .stack section is too small for allocating stacks for all the harts.
- Consider changing `_max_hart_id` or `_hart_stack_size`.");
- ASSERT(SIZEOF(.got) == 0, "
- .got section detected in the input files. Dynamic relocations are not
- supported. If you are linking to C code compiled using the `gcc` crate
- then modify your build script to compile the C code _without_ the
- -fPIC flag. See the documentation of the `gcc::Config.fpic` method for
- details.");
|