Strip down linker script

This commit is contained in:
R
2024-04-12 18:16:22 +01:00
parent 7e0ba7151b
commit 388fbaec91
2 changed files with 11 additions and 77 deletions
+10 -37
View File
@@ -5,10 +5,14 @@ PROVIDE( _stack_size = __stack_size );
MEMORY MEMORY
{ {
/* CH32V20x_D6 -> 10 KB SRAM */ /* Try to squeeze down to this target size */
/* allow full flash (incl. non-zero-wait) */ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 2K
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 224K /* We have a total of 512 bytes here.
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 10K - Need 256 bytes to buffer a flash page across USB packets
- Need space for USB buffers
- Tiny tiny amount of free space
*/
USBRAM (rw) : ORIGIN = 0x400060c0, LENGTH = 64
} }
SECTIONS SECTIONS
@@ -29,29 +33,6 @@ SECTIONS
. = ALIGN(4); . = ALIGN(4);
} >FLASH } >FLASH
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH
PROVIDE(_data_lma = .); PROVIDE(_data_lma = .);
.data : .data :
@@ -73,7 +54,7 @@ SECTIONS
*(.srodata .srodata.*) *(.srodata .srodata.*)
. = ALIGN(4); . = ALIGN(4);
PROVIDE( _edata = .); PROVIDE( _edata = .);
} >RAM AT>FLASH } >USBRAM AT>FLASH
.bss : .bss :
{ {
@@ -85,15 +66,7 @@ SECTIONS
*(COMMON*) *(COMMON*)
. = ALIGN(4); . = ALIGN(4);
PROVIDE( _ebss = .); PROVIDE( _ebss = .);
} >RAM } >USBRAM
PROVIDE( _end = _ebss); PROVIDE( _end = _ebss);
.stack ORIGIN(RAM) + LENGTH(RAM) - __stack_size :
{
PROVIDE( _heap_end = . );
PROVIDE( _susrstack = . );
. = . + __stack_size;
PROVIDE( _eusrstack = .);
} >RAM
} }
+1 -40
View File
@@ -32,46 +32,7 @@ _start:
bltu a0, a1, 1b bltu a0, a1, 1b
2: 2:
// Call preinit array functions // Invoke main
la s0, __preinit_array_start
la s1, __preinit_array_end
bgeu s0, s1, 2f
1:
lw t0, (s0)
jalr t0
addi s0, s0, 4
bltu s0, s1, 1b
2:
// Call init array functions
la s0, __init_array_start
la s1, __init_array_end
bgeu s0, s1, 2f
1:
lw t0, (s0)
jalr t0
addi s0, s0, 4
bltu s0, s1, 1b
2:
// Invoke main with a possible mode switch
la ra, 1f
la t0, main la t0, main
csrw mepc, t0 csrw mepc, t0
mret mret
1:
// Return from main, call fini array functions
la s0, __fini_array_start
la s1, __fini_array_end
bgeu s0, s1, 2f
1:
lw t0, (s0)
jalr t0
addi s0, s0, 4
bltu s0, s1, 1b
2:
// Finally, loop infinitely
wfi
j 2b