1OUTPUT_ARCH( "riscv" ) 2ENTRY(_start) 3 4MEMORY 5{ 6 /* FlashBoot location on Flash */ 7 FLASH (rwx) : ORIGIN = 0x400000+0x40, LENGTH = 32K-0x040-0x3C0 8 /* ram for stack */ 9 STACK(xrw) : ORIGIN = 0x100000,LENGTH = 8K 10 /* ram for common bss and data */ 11 SRAM(xrw) : ORIGIN = 0x100000+8K,LENGTH = 8K 12 /* ram for fix rom bss and data */ 13 ROM_BSS_DATA(rx): ORIGIN = 0x100000+16K,LENGTH = 2K 14 /* ram for code rom bss and data */ 15 CODE_ROM_BSS_DATA(rx): ORIGIN = 0x100000+18K,LENGTH = 2K 16 /* signature */ 17 SIGN(rx): ORIGIN = 0x100000+40K,LENGTH = 0x040 18 /* ram for flashboot */ 19 FLASH_BOOT(rx): ORIGIN = 0x100000+40K+0x040,LENGTH = 80K-0x040 20 /* ram for heap */ 21 HEAP(xrw): ORIGIN = 0xdc000,LENGTH = 144K 22 /* rom for fixed rom */ 23 FIXED_ROM(rx): ORIGIN = 0x00000000+11K,LENGTH = 21K 24 /* rom for code rom */ 25 CODE_ROM(rx): ORIGIN = 0x003b8000+278K,LENGTH = 10K 26} 27 28SECTIONS 29{ 30 /* The startup code goes first into FLASH */ 31 .text.entry : ALIGN(4) 32 { 33 KEEP(*(.text.entry)) 34 } > FLASH_BOOT AT>FLASH 35 36 .rom.text : 37 { 38 . = ALIGN(4); 39 KEEP(SORT(libbase.o)(.text*)) 40 KEEP(SORT(libbase.o)(.rodata*)) 41 . = ALIGN(4); 42 } > FIXED_ROM 43 44 .rom.code.text : 45 { 46 . = ALIGN(4); 47 KEEP(SORT(libcodebase.o)(.text*)) 48 KEEP(SORT(libcodebase.o)(.rodata*)) 49 . = ALIGN(4); 50 } > CODE_ROM 51 52 /* Stack in SRAM at Highest addresses */ 53 .stacks (NOLOAD) : 54 { 55 . = ALIGN(4); 56 __SYSTEM_STACK_BEGIN__ = ORIGIN(STACK); 57 KEEP(*(.stacks)) 58 __SYSTEM_STACK_END__ = ORIGIN(STACK) + LENGTH(STACK); 59 } > STACK 60 __SYSTEM_STACK_SIZE__ = __SYSTEM_STACK_END__ - __SYSTEM_STACK_BEGIN__; 61 __stack_top = __SYSTEM_STACK_END__; 62 63 .rom.data : 64 { 65 . = ALIGN(4); 66 __rom_copy_start = LOADADDR(.rom.data); 67 . = ALIGN(4); 68 __rom_copy_ram_start = .; 69 __global_pointer$ = .; 70 KEEP(SORT(libbase.o) (.data*)) 71 . = ALIGN(4); 72 __rom_copy_ram_end = .; 73 } > ROM_BSS_DATA AT>FIXED_ROM 74 __rom_copy_size = __rom_copy_ram_end - __rom_copy_ram_start; 75 76 .rom.code.data : 77 { 78 . = ALIGN(4); 79 __code_rom_copy_start = LOADADDR(.rom.code.data); 80 . = ALIGN(4); 81 __code_rom_copy_ram_start = .; 82 KEEP(SORT(libcodebase.o) (.data*)) 83 . = ALIGN(4); 84 __code_rom_copy_ram_end = .; 85 }>CODE_ROM_BSS_DATA AT>CODE_ROM 86 __code_rom_copy_size = __code_rom_copy_ram_end - __code_rom_copy_ram_start; 87 88 .rom.bss : 89 { 90 . = ALIGN(4); 91 __rom_bss_start = .; 92 KEEP(libbase.o (.bss)) 93 KEEP(libbase.o (.bss*)) 94 KEEP(libbase.o (COMMON)) 95 . = ALIGN(4); 96 __rom_bss_end = .; 97 } > ROM_BSS_DATA AT>FIXED_ROM 98 99 .rom.code.bss : 100 { 101 . = ALIGN(4); 102 __code_rom_bss_start = .; 103 KEEP(libcodebase.o (.bss)) 104 KEEP(libcodebase.o (.bss*)) 105 KEEP(libcodebase.o (COMMON)) 106 . = ALIGN(4); 107 __code_rom_bss_end = .; 108 }>CODE_ROM_BSS_DATA AT>CODE_ROM 109 110 .text : ALIGN(4) 111 { 112 __start_addr = .; 113 *(.text*) 114 . = ALIGN(4); 115 __rodata_start = .; 116 *(.rodata*) 117 . = ALIGN(4); 118 __rodata_end = .; 119 __text_end = .; 120 } > FLASH_BOOT AT>FLASH 121 122 /* data section */ 123 .data : ALIGN(4) 124 { 125 __data_load = LOADADDR(.data); 126 __data_start = .; 127 *(.data*) 128 . = ALIGN(4); 129 __data_end = .; 130 } > FLASH_BOOT AT>FLASH 131 132 /* bss section */ 133 .bss (NOLOAD) : ALIGN(4) 134 { 135 __bss_begin__ = .; 136 *(.bss*) 137 *(COMMON) 138 . = ALIGN(4); 139 __bss_end__ = .; 140 } > FLASH_BOOT 141 __bss_size__ = __bss_end__ - __bss_begin__; 142 143 .heap (NOLOAD) : 144 { 145 . = ALIGN(4); 146 __heap_begin__ = ORIGIN(HEAP); 147 KEEP(*(.heap)) 148 __heap_end__ = __heap_begin__ + LENGTH(HEAP); 149 } > HEAP 150} 151