1*6b8177c5SMatthias Ringwald/* 2*6b8177c5SMatthias Ringwald****************************************************************************** 3*6b8177c5SMatthias Ringwald** 4*6b8177c5SMatthias Ringwald 5*6b8177c5SMatthias Ringwald** File : LinkerScript.ld 6*6b8177c5SMatthias Ringwald** 7*6b8177c5SMatthias Ringwald** Author : Auto-generated by System Workbench for STM32 8*6b8177c5SMatthias Ringwald** 9*6b8177c5SMatthias Ringwald** Abstract : Linker script for STM32L476RGTx series 10*6b8177c5SMatthias Ringwald** 1024Kbytes FLASH and 128Kbytes RAM 11*6b8177c5SMatthias Ringwald** 12*6b8177c5SMatthias Ringwald** Set heap size, stack size and stack location according 13*6b8177c5SMatthias Ringwald** to application requirements. 14*6b8177c5SMatthias Ringwald** 15*6b8177c5SMatthias Ringwald** Set memory bank area and size if external memory is used. 16*6b8177c5SMatthias Ringwald** 17*6b8177c5SMatthias Ringwald** Target : STMicroelectronics STM32 18*6b8177c5SMatthias Ringwald** 19*6b8177c5SMatthias Ringwald** Distribution: The file is distributed “as is,” without any warranty 20*6b8177c5SMatthias Ringwald** of any kind. 21*6b8177c5SMatthias Ringwald** 22*6b8177c5SMatthias Ringwald***************************************************************************** 23*6b8177c5SMatthias Ringwald** @attention 24*6b8177c5SMatthias Ringwald** 25*6b8177c5SMatthias Ringwald** <h2><center>© COPYRIGHT(c) 2019 STMicroelectronics</center></h2> 26*6b8177c5SMatthias Ringwald** 27*6b8177c5SMatthias Ringwald** Redistribution and use in source and binary forms, with or without modification, 28*6b8177c5SMatthias Ringwald** are permitted provided that the following conditions are met: 29*6b8177c5SMatthias Ringwald** 1. Redistributions of source code must retain the above copyright notice, 30*6b8177c5SMatthias Ringwald** this list of conditions and the following disclaimer. 31*6b8177c5SMatthias Ringwald** 2. Redistributions in binary form must reproduce the above copyright notice, 32*6b8177c5SMatthias Ringwald** this list of conditions and the following disclaimer in the documentation 33*6b8177c5SMatthias Ringwald** and/or other materials provided with the distribution. 34*6b8177c5SMatthias Ringwald** 3. Neither the name of STMicroelectronics nor the names of its contributors 35*6b8177c5SMatthias Ringwald** may be used to endorse or promote products derived from this software 36*6b8177c5SMatthias Ringwald** without specific prior written permission. 37*6b8177c5SMatthias Ringwald** 38*6b8177c5SMatthias Ringwald** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39*6b8177c5SMatthias Ringwald** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40*6b8177c5SMatthias Ringwald** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 41*6b8177c5SMatthias Ringwald** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 42*6b8177c5SMatthias Ringwald** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 43*6b8177c5SMatthias Ringwald** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 44*6b8177c5SMatthias Ringwald** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 45*6b8177c5SMatthias Ringwald** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46*6b8177c5SMatthias Ringwald** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 47*6b8177c5SMatthias Ringwald** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48*6b8177c5SMatthias Ringwald** 49*6b8177c5SMatthias Ringwald***************************************************************************** 50*6b8177c5SMatthias Ringwald*/ 51*6b8177c5SMatthias Ringwald 52*6b8177c5SMatthias Ringwald/* Entry Point */ 53*6b8177c5SMatthias RingwaldENTRY(Reset_Handler) 54*6b8177c5SMatthias Ringwald 55*6b8177c5SMatthias Ringwald/* Highest address of the user mode stack */ 56*6b8177c5SMatthias Ringwald_estack = 0x20018000; /* end of RAM */ 57*6b8177c5SMatthias Ringwald/* Generate a link error if heap and stack don't fit into RAM */ 58*6b8177c5SMatthias Ringwald_Min_Heap_Size = 0x200; /* required amount of heap */ 59*6b8177c5SMatthias Ringwald_Min_Stack_Size = 0x400; /* required amount of stack */ 60*6b8177c5SMatthias Ringwald 61*6b8177c5SMatthias Ringwald/* Specify the memory areas */ 62*6b8177c5SMatthias RingwaldMEMORY 63*6b8177c5SMatthias Ringwald{ 64*6b8177c5SMatthias RingwaldRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K 65*6b8177c5SMatthias RingwaldRAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 32K 66*6b8177c5SMatthias RingwaldFLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K 67*6b8177c5SMatthias Ringwald} 68*6b8177c5SMatthias Ringwald 69*6b8177c5SMatthias Ringwald/* Define output sections */ 70*6b8177c5SMatthias RingwaldSECTIONS 71*6b8177c5SMatthias Ringwald{ 72*6b8177c5SMatthias Ringwald /* The startup code goes first into FLASH */ 73*6b8177c5SMatthias Ringwald .isr_vector : 74*6b8177c5SMatthias Ringwald { 75*6b8177c5SMatthias Ringwald . = ALIGN(8); 76*6b8177c5SMatthias Ringwald KEEP(*(.isr_vector)) /* Startup code */ 77*6b8177c5SMatthias Ringwald . = ALIGN(8); 78*6b8177c5SMatthias Ringwald } >FLASH 79*6b8177c5SMatthias Ringwald 80*6b8177c5SMatthias Ringwald /* The program code and other data goes into FLASH */ 81*6b8177c5SMatthias Ringwald .text : 82*6b8177c5SMatthias Ringwald { 83*6b8177c5SMatthias Ringwald . = ALIGN(8); 84*6b8177c5SMatthias Ringwald *(.text) /* .text sections (code) */ 85*6b8177c5SMatthias Ringwald *(.text*) /* .text* sections (code) */ 86*6b8177c5SMatthias Ringwald *(.glue_7) /* glue arm to thumb code */ 87*6b8177c5SMatthias Ringwald *(.glue_7t) /* glue thumb to arm code */ 88*6b8177c5SMatthias Ringwald *(.eh_frame) 89*6b8177c5SMatthias Ringwald 90*6b8177c5SMatthias Ringwald KEEP (*(.init)) 91*6b8177c5SMatthias Ringwald KEEP (*(.fini)) 92*6b8177c5SMatthias Ringwald 93*6b8177c5SMatthias Ringwald . = ALIGN(8); 94*6b8177c5SMatthias Ringwald _etext = .; /* define a global symbols at end of code */ 95*6b8177c5SMatthias Ringwald } >FLASH 96*6b8177c5SMatthias Ringwald 97*6b8177c5SMatthias Ringwald /* Constant data goes into FLASH */ 98*6b8177c5SMatthias Ringwald .rodata : 99*6b8177c5SMatthias Ringwald { 100*6b8177c5SMatthias Ringwald . = ALIGN(8); 101*6b8177c5SMatthias Ringwald *(.rodata) /* .rodata sections (constants, strings, etc.) */ 102*6b8177c5SMatthias Ringwald *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 103*6b8177c5SMatthias Ringwald . = ALIGN(8); 104*6b8177c5SMatthias Ringwald } >FLASH 105*6b8177c5SMatthias Ringwald 106*6b8177c5SMatthias Ringwald .ARM.extab : 107*6b8177c5SMatthias Ringwald { 108*6b8177c5SMatthias Ringwald . = ALIGN(8); 109*6b8177c5SMatthias Ringwald *(.ARM.extab* .gnu.linkonce.armextab.*) 110*6b8177c5SMatthias Ringwald . = ALIGN(8); 111*6b8177c5SMatthias Ringwald } >FLASH 112*6b8177c5SMatthias Ringwald .ARM : { 113*6b8177c5SMatthias Ringwald . = ALIGN(8); 114*6b8177c5SMatthias Ringwald __exidx_start = .; 115*6b8177c5SMatthias Ringwald *(.ARM.exidx*) 116*6b8177c5SMatthias Ringwald __exidx_end = .; 117*6b8177c5SMatthias Ringwald . = ALIGN(8); 118*6b8177c5SMatthias Ringwald } >FLASH 119*6b8177c5SMatthias Ringwald 120*6b8177c5SMatthias Ringwald .preinit_array : 121*6b8177c5SMatthias Ringwald { 122*6b8177c5SMatthias Ringwald . = ALIGN(8); 123*6b8177c5SMatthias Ringwald PROVIDE_HIDDEN (__preinit_array_start = .); 124*6b8177c5SMatthias Ringwald KEEP (*(.preinit_array*)) 125*6b8177c5SMatthias Ringwald PROVIDE_HIDDEN (__preinit_array_end = .); 126*6b8177c5SMatthias Ringwald . = ALIGN(8); 127*6b8177c5SMatthias Ringwald } >FLASH 128*6b8177c5SMatthias Ringwald 129*6b8177c5SMatthias Ringwald .init_array : 130*6b8177c5SMatthias Ringwald { 131*6b8177c5SMatthias Ringwald . = ALIGN(8); 132*6b8177c5SMatthias Ringwald PROVIDE_HIDDEN (__init_array_start = .); 133*6b8177c5SMatthias Ringwald KEEP (*(SORT(.init_array.*))) 134*6b8177c5SMatthias Ringwald KEEP (*(.init_array*)) 135*6b8177c5SMatthias Ringwald PROVIDE_HIDDEN (__init_array_end = .); 136*6b8177c5SMatthias Ringwald . = ALIGN(8); 137*6b8177c5SMatthias Ringwald } >FLASH 138*6b8177c5SMatthias Ringwald .fini_array : 139*6b8177c5SMatthias Ringwald { 140*6b8177c5SMatthias Ringwald . = ALIGN(8); 141*6b8177c5SMatthias Ringwald PROVIDE_HIDDEN (__fini_array_start = .); 142*6b8177c5SMatthias Ringwald KEEP (*(SORT(.fini_array.*))) 143*6b8177c5SMatthias Ringwald KEEP (*(.fini_array*)) 144*6b8177c5SMatthias Ringwald PROVIDE_HIDDEN (__fini_array_end = .); 145*6b8177c5SMatthias Ringwald . = ALIGN(8); 146*6b8177c5SMatthias Ringwald } >FLASH 147*6b8177c5SMatthias Ringwald 148*6b8177c5SMatthias Ringwald /* used by the startup to initialize data */ 149*6b8177c5SMatthias Ringwald _sidata = LOADADDR(.data); 150*6b8177c5SMatthias Ringwald 151*6b8177c5SMatthias Ringwald /* Initialized data sections goes into RAM, load LMA copy after code */ 152*6b8177c5SMatthias Ringwald .data : 153*6b8177c5SMatthias Ringwald { 154*6b8177c5SMatthias Ringwald . = ALIGN(8); 155*6b8177c5SMatthias Ringwald _sdata = .; /* create a global symbol at data start */ 156*6b8177c5SMatthias Ringwald *(.data) /* .data sections */ 157*6b8177c5SMatthias Ringwald *(.data*) /* .data* sections */ 158*6b8177c5SMatthias Ringwald 159*6b8177c5SMatthias Ringwald . = ALIGN(8); 160*6b8177c5SMatthias Ringwald _edata = .; /* define a global symbol at data end */ 161*6b8177c5SMatthias Ringwald } >RAM AT> FLASH 162*6b8177c5SMatthias Ringwald 163*6b8177c5SMatthias Ringwald 164*6b8177c5SMatthias Ringwald /* Uninitialized data section */ 165*6b8177c5SMatthias Ringwald . = ALIGN(4); 166*6b8177c5SMatthias Ringwald .bss : 167*6b8177c5SMatthias Ringwald { 168*6b8177c5SMatthias Ringwald /* This is used by the startup in order to initialize the .bss secion */ 169*6b8177c5SMatthias Ringwald _sbss = .; /* define a global symbol at bss start */ 170*6b8177c5SMatthias Ringwald __bss_start__ = _sbss; 171*6b8177c5SMatthias Ringwald *(.bss) 172*6b8177c5SMatthias Ringwald *(.bss*) 173*6b8177c5SMatthias Ringwald *(COMMON) 174*6b8177c5SMatthias Ringwald 175*6b8177c5SMatthias Ringwald . = ALIGN(4); 176*6b8177c5SMatthias Ringwald _ebss = .; /* define a global symbol at bss end */ 177*6b8177c5SMatthias Ringwald __bss_end__ = _ebss; 178*6b8177c5SMatthias Ringwald } >RAM 179*6b8177c5SMatthias Ringwald 180*6b8177c5SMatthias Ringwald /* User_heap_stack section, used to check that there is enough RAM left */ 181*6b8177c5SMatthias Ringwald ._user_heap_stack : 182*6b8177c5SMatthias Ringwald { 183*6b8177c5SMatthias Ringwald . = ALIGN(8); 184*6b8177c5SMatthias Ringwald PROVIDE ( end = . ); 185*6b8177c5SMatthias Ringwald PROVIDE ( _end = . ); 186*6b8177c5SMatthias Ringwald . = . + _Min_Heap_Size; 187*6b8177c5SMatthias Ringwald . = . + _Min_Stack_Size; 188*6b8177c5SMatthias Ringwald . = ALIGN(8); 189*6b8177c5SMatthias Ringwald } >RAM 190*6b8177c5SMatthias Ringwald 191*6b8177c5SMatthias Ringwald 192*6b8177c5SMatthias Ringwald 193*6b8177c5SMatthias Ringwald /* Remove information from the standard libraries */ 194*6b8177c5SMatthias Ringwald /DISCARD/ : 195*6b8177c5SMatthias Ringwald { 196*6b8177c5SMatthias Ringwald libc.a ( * ) 197*6b8177c5SMatthias Ringwald libm.a ( * ) 198*6b8177c5SMatthias Ringwald libgcc.a ( * ) 199*6b8177c5SMatthias Ringwald } 200*6b8177c5SMatthias Ringwald 201*6b8177c5SMatthias Ringwald .ARM.attributes 0 : { *(.ARM.attributes) } 202*6b8177c5SMatthias Ringwald} 203*6b8177c5SMatthias Ringwald 204*6b8177c5SMatthias Ringwald 205