1OUTPUT_ARCH( "riscv" ) 2 3ENTRY( _start ) 4 5MEMORY 6{ 7 /* Run in FLASH */ 8 flash (rxai!w) : ORIGIN = 0x08000000, LENGTH = 64k 9 ram (wxa!ri) : ORIGIN = 0x20000000, LENGTH = 20k 10 11 /* Run in RAM */ 12/* flash (rxai!w) : ORIGIN = 0x20000000, LENGTH = 15k 13 ram (wxa!ri) : ORIGIN = 0x20003C00, LENGTH = 5K 14*/ 15} 16 17 18SECTIONS 19{ 20 __stack_size = DEFINED(__stack_size) ? __stack_size : 2K; 21 22 23 .init : 24 { 25 KEEP (*(SORT_NONE(.init))) 26 } >flash AT>flash 27 28 .ilalign : 29 { 30 . = ALIGN(4); 31 PROVIDE( _ilm_lma = . ); 32 } >flash AT>flash 33 34 .ialign : 35 { 36 PROVIDE( _ilm = . ); 37 } >flash AT>flash 38 39 .text : 40 { 41 *(.rodata .rodata.*) 42 *(.text.unlikely .text.unlikely.*) 43 *(.text.startup .text.startup.*) 44 *(.text .text.*) 45 *(.gnu.linkonce.t.*) 46 } >flash AT>flash 47 48 .fini : 49 { 50 KEEP (*(SORT_NONE(.fini))) 51 } >flash AT>flash 52 53 . = ALIGN(4); 54 55 PROVIDE (__etext = .); 56 PROVIDE (_etext = .);/*0x80022c8*/ 57 PROVIDE (etext = .);/*0x80022c8*/ 58 PROVIDE( _eilm = . ); 59 60 .preinit_array : 61 { 62 PROVIDE_HIDDEN (__preinit_array_start = .); 63 KEEP (*(.preinit_array)) 64 PROVIDE_HIDDEN (__preinit_array_end = .); 65 } >flash AT>flash 66 67 .init_array : 68 { 69 PROVIDE_HIDDEN (__init_array_start = .); 70 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) 71 KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)) 72 PROVIDE_HIDDEN (__init_array_end = .); 73 } >flash AT>flash 74 75 .fini_array : 76 { 77 PROVIDE_HIDDEN (__fini_array_start = .); 78 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) 79 KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors)) 80 PROVIDE_HIDDEN (__fini_array_end = .); 81 } >flash AT>flash 82 83 .ctors : 84 { 85 /* gcc uses crtbegin.o to find the start of 86 the constructors, so we make sure it is 87 first. Because this is a wildcard, it 88 doesn't matter if the user does not 89 actually link against crtbegin.o; the 90 linker won't look for a file to match a 91 wildcard. The wildcard also means that it 92 doesn't matter which directory crtbegin.o 93 is in. */ 94 KEEP (*crtbegin.o(.ctors)) 95 KEEP (*crtbegin?.o(.ctors)) 96 /* We don't want to include the .ctor section from 97 the crtend.o file until after the sorted ctors. 98 The .ctor section from the crtend file contains the 99 end of ctors marker and it must be last */ 100 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) 101 KEEP (*(SORT(.ctors.*))) 102 KEEP (*(.ctors)) 103 } >flash AT>flash 104 105 .dtors : 106 { 107 KEEP (*crtbegin.o(.dtors)) 108 KEEP (*crtbegin?.o(.dtors)) 109 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) 110 KEEP (*(SORT(.dtors.*))) 111 KEEP (*(.dtors)) 112 } >flash AT>flash 113 114 . = ALIGN(4); 115 PROVIDE( _eilm = . ); 116 117 .lalign : 118 { 119 . = ALIGN(4); 120 PROVIDE( _data_lma = . ); 121 } >flash AT>flash 122 123 .dalign : 124 { 125 . = ALIGN(4); 126 PROVIDE( _data = . ); 127 } >ram AT>flash 128 129 130 .data : 131 { 132 *(.rdata) 133 134 *(.gnu.linkonce.r.*) 135 *(.data .data.*) 136 *(.gnu.linkonce.d.*) 137 . = ALIGN(8); 138 PROVIDE( __global_pointer$ = . + 0x800); 139 *(.sdata .sdata.*) 140 *(.gnu.linkonce.s.*) 141 . = ALIGN(8); 142 *(.srodata.cst16) 143 *(.srodata.cst8) 144 *(.srodata.cst4) 145 *(.srodata.cst2) 146 *(.srodata .srodata.*) 147 } >ram AT>flash 148 149 . = ALIGN(4); 150 PROVIDE( _edata = . ); 151 PROVIDE( edata = . ); 152 153 PROVIDE( _fbss = . ); /*0X200052A0 0X200002A0*/ 154 PROVIDE( __bss_start = . ); 155 .bss : 156 { 157 *(.sbss*) 158 *(.gnu.linkonce.sb.*) 159 *(.bss .bss.*) 160 *(.gnu.linkonce.b.*) 161 *(COMMON) 162 . = ALIGN(4); 163 } >ram AT>ram 164 165 . = ALIGN(8); 166 PROVIDE( _end = . ); /*0X2000,0340*/ 167 PROVIDE( end = . ); 168 169 .stack ORIGIN(ram) + LENGTH(ram) - __stack_size : 170 { 171 PROVIDE( _heap_end = . ); 172 . = __stack_size; 173 PROVIDE( _sp = . ); 174 } >ram AT>ram 175} 176