沁恒微RISC-V MCU CH32V103 的gcc链接脚本
1 ENTRY( _start ) 2 3 __stack_size = 2048; 4 5 PROVIDE( _stack_size = __stack_size ); 6 7 8 MEMORY 9 { 10 FLASH (rx) : ORIGIN = 0x00000000 , LENGTH = 0x10000 11 RAM (xrw) : ORIGIN = 0x20000000 , LENGTH = 0x5000 12 } 13 14 15 SECTIONS 16 { 17 18 .init : 19 { 20 _sinit = .; 21 . = ALIGN(4); 22 KEEP(*(SORT_NONE(.init))) 23 . = ALIGN(4); 24 _einit = .; 25 } >FLASH AT>FLASH 26 27 .vector : 28 { 29 *(.vector); 30 . = ALIGN(64); 31 } >FLASH AT>FLASH 32 33 .flag : 34 { 35 . = ORIGIN(FLASH)+0x8000; 36 KEEP(*(SORT_NONE(.myBufSection))) 37 }>FLASH AT>FLASH 38 39 .text : 40 { 41 . = ALIGN(4); 42 *(.text) 43 *(.text.*) 44 *(.rodata) 45 *(.rodata*) 46 *(.glue_7) 47 *(.glue_7t) 48 *(.gnu.linkonce.t.*) 49 . = ALIGN(4); 50 } >FLASH AT>FLASH 51 52 .fini : 53 { 54 KEEP(*(SORT_NONE(.fini))) 55 . = ALIGN(4); 56 } >FLASH AT>FLASH 57 58 PROVIDE( _etext = . ); 59 PROVIDE( _eitcm = . ); 60 61 .preinit_array : 62 { 63 PROVIDE_HIDDEN (__preinit_array_start = .); 64 KEEP (*(.preinit_array)) 65 PROVIDE_HIDDEN (__preinit_array_end = .); 66 } >FLASH AT>FLASH 67 68 .init_array : 69 { 70 PROVIDE_HIDDEN (__init_array_start = .); 71 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) 72 KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)) 73 PROVIDE_HIDDEN (__init_array_end = .); 74 } >FLASH AT>FLASH 75 76 .fini_array : 77 { 78 PROVIDE_HIDDEN (__fini_array_start = .); 79 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) 80 KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors)) 81 PROVIDE_HIDDEN (__fini_array_end = .); 82 } >FLASH AT>FLASH 83 84 .ctors : 85 { 86 /* gcc uses crtbegin.o to find the start of 87 the constructors, so we make sure it is 88 first. Because this is a wildcard, it 89 doesn't matter if the user does not 90 actually link against crtbegin.o; the 91 linker won't look for a file to match a 92 wildcard. The wildcard also means that it 93 doesn't matter which directory crtbegin.o 94 is in. */ 95 KEEP (*crtbegin.o(.ctors)) 96 KEEP (*crtbegin?.o(.ctors)) 97 /* We don't want to include the .ctor section from 98 the crtend.o file until after the sorted ctors. 99 The .ctor section from the crtend file contains the 100 end of ctors marker and it must be last */ 101 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) 102 KEEP (*(SORT(.ctors.*))) 103 KEEP (*(.ctors)) 104 } >FLASH AT>FLASH 105 106 .dtors : 107 { 108 KEEP (*crtbegin.o(.dtors)) 109 KEEP (*crtbegin?.o(.dtors)) 110 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) 111 KEEP (*(SORT(.dtors.*))) 112 KEEP (*(.dtors)) 113 } >FLASH AT>FLASH 114 115 .dalign : 116 { 117 . = ALIGN(4); 118 PROVIDE(_data_vma = .); 119 } >RAM AT>FLASH 120 121 .dlalign : 122 { 123 . = ALIGN(4); 124 PROVIDE(_data_lma = .); 125 } >FLASH AT>FLASH 126 127 .data : 128 { 129 *(.gnu.linkonce.r.*) 130 *(.data .data.*) 131 *(.gnu.linkonce.d.*) 132 . = ALIGN(8); 133 PROVIDE( __global_pointer$ = . + 0x800 ); 134 *(.sdata .sdata.*) 135 *(.sdata2.*) 136 *(.gnu.linkonce.s.*) 137 . = ALIGN(8); 138 *(.srodata.cst16) 139 *(.srodata.cst8) 140 *(.srodata.cst4) 141 *(.srodata.cst2) 142 *(.srodata .srodata.*) 143 . = ALIGN(4); 144 PROVIDE( _edata = .); 145 } >RAM AT>FLASH 146 147 .bss : 148 { 149 . = ALIGN(4); 150 PROVIDE( _sbss = .); 151 *(.sbss*) 152 *(.gnu.linkonce.sb.*) 153 *(.bss*) 154 *(.gnu.linkonce.b.*) 155 *(COMMON*) 156 . = ALIGN(4); 157 PROVIDE( _ebss = .); 158 } >RAM AT>FLASH 159 160 PROVIDE( _end = _ebss); 161 PROVIDE( end = . ); 162 163 .stack ORIGIN(RAM) + LENGTH(RAM) - __stack_size : 164 { 165 . = ALIGN(4); 166 PROVIDE(_susrstack = . ); 167 . = . + __stack_size; 168 PROVIDE( _eusrstack = .); 169 } >RAM 170 171 }