|
| 1 | +ENTRY( _start ) |
| 2 | + |
| 3 | +__stack_size = 2048; |
| 4 | + |
| 5 | +PROVIDE( _stack_size = __stack_size ); |
| 6 | + |
| 7 | + |
| 8 | +MEMORY |
| 9 | +{ |
| 10 | + /*FLASH, RAM, and RAM-CODE can be freely configured according to project |
| 11 | + requirements;Please refer to the datasheet manual for specific allocation*/ |
| 12 | + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 128K /* zero_wait flah ,and loaded into RAM_CODE for running */ |
| 13 | + RAM_CODE (xrw) : ORIGIN = 0x20100000, LENGTH = 128K /* RAM for running code*/ |
| 14 | + RAM (xrw) : ORIGIN = (0x20120000+256), LENGTH = (448K-256-64k) /* RAM for .data .bss section and other*/ |
| 15 | + RAM_LOAD (xrw) : ORIGIN = 0x20120000, LENGTH = 256 /* RAM for .load section*/ |
| 16 | +} |
| 17 | + |
| 18 | +SECTIONS |
| 19 | +{ |
| 20 | + .init : |
| 21 | + { |
| 22 | + _sinit = .; |
| 23 | + . = ALIGN(4); |
| 24 | + KEEP(*(SORT_NONE(.init))) |
| 25 | + . = ALIGN(4); |
| 26 | + _einit = .; |
| 27 | + } >FLASH AT>FLASH |
| 28 | + |
| 29 | + .loadcodelalign : |
| 30 | + { |
| 31 | + . = ALIGN(4); |
| 32 | + PROVIDE(_loadcode_lma = .); |
| 33 | + } >FLASH AT>FLASH |
| 34 | + |
| 35 | + .loadcode : |
| 36 | + { |
| 37 | + . = ALIGN(4); |
| 38 | + PROVIDE(_loadcode_vma_start = .); |
| 39 | + *(.load); |
| 40 | + . = ALIGN(4); |
| 41 | + PROVIDE(_loadcode_vma_end = .); |
| 42 | + }>RAM_LOAD AT>FLASH |
| 43 | + |
| 44 | + .highcodelalign : |
| 45 | + { |
| 46 | + . = ALIGN(4); |
| 47 | + PROVIDE(_highcode_lma = .); |
| 48 | + } >FLASH AT>FLASH |
| 49 | + |
| 50 | + .highcode : |
| 51 | + { |
| 52 | + . = ALIGN(4); |
| 53 | + PROVIDE(_highcode_vma_start = .); |
| 54 | + *(.vector); |
| 55 | + KEEP(*(SORT_NONE(.vector_handler))) |
| 56 | + *(.text) |
| 57 | + *(.text.*) |
| 58 | + *(.rodata) |
| 59 | + *(.rodata*) |
| 60 | + *(.sdata2.*) |
| 61 | + *(.glue_7) |
| 62 | + *(.glue_7t) |
| 63 | + *(.gnu.linkonce.t.*) |
| 64 | + . = ALIGN(4); |
| 65 | + PROVIDE(_highcode_vma_end = .); |
| 66 | + } >RAM_CODE AT>FLASH |
| 67 | + |
| 68 | + .text : |
| 69 | + { |
| 70 | + . = ALIGN(4); |
| 71 | + KEEP(*(SORT_NONE(.handle_reset))) |
| 72 | + . = ALIGN(4); |
| 73 | + } >FLASH AT>FLASH |
| 74 | + |
| 75 | + .highcodelalign1 : |
| 76 | + { |
| 77 | + . = ALIGN(4); |
| 78 | + PROVIDE(_highcode_lma1 = .); |
| 79 | + } >FLASH AT>FLASH |
| 80 | + |
| 81 | + .fini : |
| 82 | + { |
| 83 | + . = ALIGN(4); |
| 84 | + PROVIDE(_highcode_vma_start1 = .); |
| 85 | + KEEP(*(SORT_NONE(.fini))) |
| 86 | + . = ALIGN(4); |
| 87 | + } >RAM_CODE AT>FLASH |
| 88 | + |
| 89 | + PROVIDE( _etext = . ); |
| 90 | + PROVIDE( _eitcm = . ); |
| 91 | + |
| 92 | + .preinit_array : |
| 93 | + { |
| 94 | + PROVIDE_HIDDEN (__preinit_array_start = .); |
| 95 | + KEEP (*(.preinit_array)) |
| 96 | + PROVIDE_HIDDEN (__preinit_array_end = .); |
| 97 | + } >RAM_CODE AT>FLASH |
| 98 | + |
| 99 | + .init_array : |
| 100 | + { |
| 101 | + PROVIDE_HIDDEN (__init_array_start = .); |
| 102 | + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) |
| 103 | + KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)) |
| 104 | + PROVIDE_HIDDEN (__init_array_end = .); |
| 105 | + } >RAM_CODE AT>FLASH |
| 106 | + |
| 107 | + .fini_array : |
| 108 | + { |
| 109 | + PROVIDE_HIDDEN (__fini_array_start = .); |
| 110 | + KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) |
| 111 | + KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors)) |
| 112 | + PROVIDE_HIDDEN (__fini_array_end = .); |
| 113 | + } >RAM_CODE AT>FLASH |
| 114 | + |
| 115 | + .ctors : |
| 116 | + { |
| 117 | + /* gcc uses crtbegin.o to find the start of |
| 118 | + the constructors, so we make sure it is |
| 119 | + first. Because this is a wildcard, it |
| 120 | + doesn't matter if the user does not |
| 121 | + actually link against crtbegin.o; the |
| 122 | + linker won't look for a file to match a |
| 123 | + wildcard. The wildcard also means that it |
| 124 | + doesn't matter which directory crtbegin.o |
| 125 | + is in. */ |
| 126 | + KEEP (*crtbegin.o(.ctors)) |
| 127 | + KEEP (*crtbegin?.o(.ctors)) |
| 128 | + /* We don't want to include the .ctor section from |
| 129 | + the crtend.o file until after the sorted ctors. |
| 130 | + The .ctor section from the crtend file contains the |
| 131 | + end of ctors marker and it must be last */ |
| 132 | + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) |
| 133 | + KEEP (*(SORT(.ctors.*))) |
| 134 | + KEEP (*(.ctors)) |
| 135 | + } >RAM_CODE AT>FLASH |
| 136 | + |
| 137 | + .dtors : |
| 138 | + { |
| 139 | + KEEP (*crtbegin.o(.dtors)) |
| 140 | + KEEP (*crtbegin?.o(.dtors)) |
| 141 | + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) |
| 142 | + KEEP (*(SORT(.dtors.*))) |
| 143 | + KEEP (*(.dtors)) |
| 144 | + . = ALIGN(4); |
| 145 | + PROVIDE(_highcode_vma_end1 = .); |
| 146 | + } >RAM_CODE AT>FLASH |
| 147 | + |
| 148 | + .dalign : |
| 149 | + { |
| 150 | + . = ALIGN(4); |
| 151 | + PROVIDE(_data_vma = .); |
| 152 | + } >RAM AT>FLASH |
| 153 | + |
| 154 | + .dlalign : |
| 155 | + { |
| 156 | + . = ALIGN(4); |
| 157 | + PROVIDE(_data_lma = .); |
| 158 | + } >FLASH AT>FLASH |
| 159 | + |
| 160 | + .data : |
| 161 | + { |
| 162 | + . = ALIGN(4); |
| 163 | + *(.gnu.linkonce.r.*) |
| 164 | + *(.data .data.*) |
| 165 | + *(.gnu.linkonce.d.*) |
| 166 | + . = ALIGN(8); |
| 167 | + PROVIDE( __global_pointer$ = . + 0x800 ); |
| 168 | + *(.sdata .sdata.*) |
| 169 | + *(.sdata2.*) |
| 170 | + *(.gnu.linkonce.s.*) |
| 171 | + . = ALIGN(8); |
| 172 | + *(.srodata.cst16) |
| 173 | + *(.srodata.cst8) |
| 174 | + *(.srodata.cst4) |
| 175 | + *(.srodata.cst2) |
| 176 | + *(.srodata .srodata.*) |
| 177 | + . = ALIGN(4); |
| 178 | + PROVIDE( _edata = .); |
| 179 | + } >RAM AT>FLASH |
| 180 | + |
| 181 | + .bss : |
| 182 | + { |
| 183 | + . = ALIGN(4); |
| 184 | + PROVIDE( _sbss = .); |
| 185 | + *(.sbss*) |
| 186 | + *(.gnu.linkonce.sb.*) |
| 187 | + *(.bss*) |
| 188 | + *(.gnu.linkonce.b.*) |
| 189 | + *(COMMON*) |
| 190 | + . = ALIGN(4); |
| 191 | + PROVIDE( _ebss = .); |
| 192 | + } >RAM AT>FLASH |
| 193 | + |
| 194 | + PROVIDE( _end = _ebss); |
| 195 | + PROVIDE( end = . ); |
| 196 | + |
| 197 | + .stack ORIGIN(RAM) + LENGTH(RAM) - __stack_size : |
| 198 | + { |
| 199 | + PROVIDE( _heap_end = . ); |
| 200 | + . = ALIGN(4); |
| 201 | + PROVIDE(_susrstack = . ); |
| 202 | + . = . + __stack_size; |
| 203 | + PROVIDE( _eusrstack = .); |
| 204 | + } >RAM |
| 205 | + |
| 206 | +} |
| 207 | + |
| 208 | + |
| 209 | + |
0 commit comments