1/****************************************************************************** 2 * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") 3 * All rights reserved. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 *****************************************************************************/ 18 19MEMORY 20{ 21 FLASH (rxai!w) : ORIGIN = 0x20000000, LENGTH = 1M 22 RAM_ILM (wxa) : ORIGIN = 0x00000000, LENGTH = 128K 23 RAM_DLM (wxa) : ORIGIN = 0x00080000, LENGTH = 128K 24} 25 26ENTRY(reset_vector) 27EXTERN(_b91_inject_start) 28 29SECTIONS 30{ 31 PROVIDE (BIN_BEGIN = ORIGIN(FLASH)); 32 33 PROVIDE(__text_start = .); 34 .entry.text : ALIGN(8) 35 { 36 KEEP(*(.entry.text)) 37 } > FLASH 38 39 ._b91_inject_start ORIGIN(FLASH) + 0x18 : 40 { 41 KEEP(*(._b91_inject_start)) 42 } > FLASH 43 44 .retention_data : ALIGN(8) 45 { 46 KEEP(*(.retention_data )) 47 . = .; 48 } > RAM_ILM AT > FLASH 49 50 PROVIDE (SEG_RETENTION_DATA_VMA_START = ADDR(.retention_data)); 51 PROVIDE (SEG_RETENTION_DATA_LMA_START = LOADADDR(.retention_data)); 52 PROVIDE (SEG_RETENTION_DATA_VMA_END = .); 53 54 .ram_code : ALIGN(8) 55 { 56 KEEP(*(.ram_code )) 57 . = .; 58 } > RAM_ILM AT > FLASH 59 60 PROVIDE (SEG_RAMCODE_VMA_START = ADDR(.ram_code)); 61 PROVIDE (SEG_RAMCODE_LMA_START = LOADADDR(.ram_code)); 62 PROVIDE (SEG_RAMCODE_VMA_END = .); 63 64 .text : ALIGN(8) 65 { 66 *(.text .stub .text.* .gnu.linkonce.t.* ) 67 *(.interrupt.text ) 68 *(.interrupt.text.* ) 69 *(.interrupt.HalTrapVector.text ) 70 KEEP(*(.text.*personality* )) 71 *(.text.unlikely .text.unlikely.*) 72 KEEP(*(.itcm.text)) 73 PROVIDE(__rodata_start = .); 74 *(.gnu.warning ) 75 *(.rodata .rodata.* .gnu.linkonce.r.* ) 76 PROVIDE(__rodata_end = .); 77 *(.gcc_except_table .gcc_except_table.*) 78 *(.eh_frame_hdr ) 79 . = ALIGN(0x20); 80 KEEP(*(.eh_frame )) 81 KEEP(*(.exec.itable)) 82 83 KEEP(*(.got*)) 84 KEEP(*(.plt*)) 85 86 KEEP (*(.init)) 87 KEEP (*(.fini)) 88 89 PROVIDE_HIDDEN (__preinit_array_start = .); 90 KEEP (*(.preinit_array)) 91 PROVIDE_HIDDEN (__preinit_array_end = .); 92 93 PROVIDE_HIDDEN (__init_array_start = .); 94 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) 95 KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)) 96 KEEP (*crtbegin.o(.ctors)) 97 KEEP (*crtbegin?.o(.ctors)) 98 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) 99 KEEP (*(SORT(.ctors.*))) 100 KEEP (*(.ctors)) 101 PROVIDE_HIDDEN (__init_array_end = .); 102 103 PROVIDE_HIDDEN (__fini_array_start = .); 104 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) 105 KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors)) 106 PROVIDE_HIDDEN (__fini_array_end = .); 107 108 PROVIDE(_hdf_drivers_start = .); 109 KEEP(*(.hdf.driver)) 110 PROVIDE(_hdf_drivers_end = .); 111 112 KEEP (*crtbegin.o(.dtors)) 113 KEEP (*crtbegin?.o(.dtors)) 114 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) 115 KEEP (*(SORT(.dtors.*))) 116 KEEP (*(.dtors)) 117 118 } > FLASH AT > FLASH 119 120 /* zInit code and data - will be freed after init */ 121 .zInit : ALIGN(8) 122 { 123 __zinitcall_bsp_start = .; 124 KEEP (*(.zinitcall.bsp0.init)) 125 KEEP (*(.zinitcall.bsp1.init)) 126 KEEP (*(.zinitcall.bsp2.init)) 127 KEEP (*(.zinitcall.bsp3.init)) 128 KEEP (*(.zinitcall.bsp4.init)) 129 __zinitcall_bsp_end = .; 130 __zinitcall_device_start = .; 131 KEEP (*(.zinitcall.device0.init)) 132 KEEP (*(.zinitcall.device1.init)) 133 KEEP (*(.zinitcall.device2.init)) 134 KEEP (*(.zinitcall.device3.init)) 135 KEEP (*(.zinitcall.device4.init)) 136 __zinitcall_device_end = .; 137 __zinitcall_core_start = .; 138 KEEP (*(.zinitcall.core0.init)) 139 KEEP (*(.zinitcall.core1.init)) 140 KEEP (*(.zinitcall.core2.init)) 141 KEEP (*(.zinitcall.core3.init)) 142 KEEP (*(.zinitcall.core4.init)) 143 __zinitcall_core_end = .; 144 __zinitcall_sys_service_start = .; 145 KEEP (*(.zinitcall.sys.service0.init)) 146 KEEP (*(.zinitcall.sys.service1.init)) 147 KEEP (*(.zinitcall.sys.service2.init)) 148 KEEP (*(.zinitcall.sys.service3.init)) 149 KEEP (*(.zinitcall.sys.service4.init)) 150 __zinitcall_sys_service_end = .; 151 __zinitcall_sys_feature_start = .; 152 KEEP (*(.zinitcall.sys.feature0.init)) 153 KEEP (*(.zinitcall.sys.feature1.init)) 154 KEEP (*(.zinitcall.sys.feature2.init)) 155 KEEP (*(.zinitcall.sys.feature3.init)) 156 KEEP (*(.zinitcall.sys.feature4.init)) 157 __zinitcall_sys_feature_end = .; 158 __zinitcall_run_start = .; 159 KEEP (*(.zinitcall.run0.init)) 160 KEEP (*(.zinitcall.run1.init)) 161 KEEP (*(.zinitcall.run2.init)) 162 KEEP (*(.zinitcall.run3.init)) 163 KEEP (*(.zinitcall.run4.init)) 164 __zinitcall_run_end = .; 165 __zinitcall_app_service_start = .; 166 KEEP (*(.zinitcall.app.service0.init)) 167 KEEP (*(.zinitcall.app.service1.init)) 168 KEEP (*(.zinitcall.app.service2.init)) 169 KEEP (*(.zinitcall.app.service3.init)) 170 KEEP (*(.zinitcall.app.service4.init)) 171 __zinitcall_app_service_end = .; 172 __zinitcall_app_feature_start = .; 173 KEEP (*(.zinitcall.app.feature0.init)) 174 KEEP (*(.zinitcall.app.feature1.init)) 175 KEEP (*(.zinitcall.app.feature2.init)) 176 KEEP (*(.zinitcall.app.feature3.init)) 177 KEEP (*(.zinitcall.app.feature4.init)) 178 __zinitcall_app_feature_end = .; 179 __zinitcall_test_start = .; 180 KEEP (*(.zinitcall.test0.init)) 181 KEEP (*(.zinitcall.test1.init)) 182 KEEP (*(.zinitcall.test2.init)) 183 KEEP (*(.zinitcall.test3.init)) 184 KEEP (*(.zinitcall.test4.init)) 185 __zinitcall_test_end = .; 186 __zinitcall_exit_start = .; 187 KEEP (*(.zinitcall.exit0.init)) 188 KEEP (*(.zinitcall.exit1.init)) 189 KEEP (*(.zinitcall.exit2.init)) 190 KEEP (*(.zinitcall.exit3.init)) 191 KEEP (*(.zinitcall.exit4.init)) 192 __zinitcall_exit_end = .; 193 } > FLASH AT > FLASH 194 195 PROVIDE(__text_end = .); 196 197 .data : ALIGN(8) 198 { 199 PROVIDE (__global_pointer$ = . + (4K / 2)); 200 . += 8; /* Workaround because linker don't use global pointer (GP) on extreme edge */ 201 *(.data .data.* .gnu.linkonce.d.* ) 202 KEEP(*( SORT (.liteos.table.*))); 203 KEEP(*(.gnu.linkonce.d.*personality* )) 204 SORT(CONSTRUCTORS) 205 *(.srodata.cst16 ) 206 *(.srodata.cst8 ) 207 *(.srodata.cst4 ) 208 *(.srodata.cst2 ) 209 *(.srodata .srodata.* ) 210 *(.sdata .sdata.* .gnu.linkonce.s.* ) 211 *(.sdata2 .sdata2.* .gnu.linkonce.s.* ) 212 } > RAM_DLM AT > FLASH 213 214 PROVIDE(SEG_DATA_VMA_START = ADDR(.data)); 215 PROVIDE(SEG_DATA_LMA_START = LOADADDR(.data)); 216 PROVIDE(SEG_DATA_VMA_END = .); 217 PROVIDE(__ram_data_start = SEG_DATA_VMA_START); 218 PROVIDE(__ram_data_end = SEG_DATA_VMA_END); 219 220 .bss (NOLOAD) : ALIGN(8) 221 { 222 *(.dynsbss ) 223 *(.sbss .sbss.* .gnu.linkonce.sb.* ) 224 *(.scommon .scommon.* ) 225 *(.dynbss ) 226 *(.bss .bss.* .gnu.linkonce.b.* ) 227 *(COMMON ) 228 } > RAM_DLM 229 230 PROVIDE(SEG_BSS_VMA_START = ADDR(.bss)); 231 PROVIDE(SEG_BSS_VMA_END = .); 232 PROVIDE(__bss_start = SEG_BSS_VMA_START); 233 PROVIDE(__bss_end = SEG_BSS_VMA_END); 234 235 .noinit (NOLOAD) : ALIGN(16) 236 { 237 *(.noinit) 238 } > RAM_DLM 239 240 .int_stack (NOLOAD) : ALIGN(0x1000) 241 { 242 __int_stack_start = .; 243 *(.int_stack); 244 __int_stack_end = .; 245 } > RAM_DLM 246 247 . = ALIGN(8); 248 /* end is the starting address of the heap, the heap grows upward */ 249 _end = .; 250 _heap_end = ORIGIN(RAM_DLM) + LENGTH(RAM_DLM) - 1; 251 252 .heap : ALIGN(1024) 253 { 254 PROVIDE (__los_heap_addr_start__ = .); 255 . = ORIGIN(RAM_ILM) + LENGTH(RAM_ILM); 256 PROVIDE (__los_heap_addr_end__ = . - 1); 257 } > RAM_ILM 258 PROVIDE (__los_heap_size__ = __los_heap_addr_end__ - __los_heap_addr_start__ + 1); 259 260/* PROVIDE (__los_heap_addr_start__ = .); 261 . = ORIGIN(RAM_DLM) + LENGTH(RAM_DLM); 262 PROVIDE (__los_heap_addr_end__ = . - 1); 263 PROVIDE (__los_heap_size__ = __los_heap_addr_end__ - __los_heap_addr_start__ + 1);*/ 264 265 .BIN_END : 266 { 267 BIN_END = .; 268 } > FLASH 269 PROVIDE (BIN_SIZE = BIN_END - BIN_BEGIN); 270 271 /* Remove information from the standard libraries 0x400 */ 272 /DISCARD/ : 273 { 274 libc.a ( * ) 275 libm.a ( * ) 276 libgcc.a ( * ) 277 *(.dummy) 278 } 279} 280