|
| 1 | +/* |
| 2 | + * Copyright (c) 2008-2018 Thomas Roell. All rights reserved. |
| 3 | + * |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 5 | + * of this software and associated documentation files (the "Software"), to |
| 6 | + * deal with the Software without restriction, including without limitation the |
| 7 | + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 8 | + * sell copies of the Software, and to permit persons to whom the Software is |
| 9 | + * furnished to do so, subject to the following conditions: |
| 10 | + * |
| 11 | + * 1. Redistributions of source code must retain the above copyright notice, |
| 12 | + * this list of conditions and the following disclaimers. |
| 13 | + * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | + * notice, this list of conditions and the following disclaimers in the |
| 15 | + * documentation and/or other materials provided with the distribution. |
| 16 | + * 3. Neither the name of Thomas Roell, nor the names of its contributors |
| 17 | + * may be used to endorse or promote products derived from this Software |
| 18 | + * without specific prior written permission. |
| 19 | + * |
| 20 | + * THE SOFTWARE IS PROVINCED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 21 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 22 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 23 | + * CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 24 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 25 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 26 | + * WITH THE SOFTWARE. |
| 27 | + */ |
| 28 | + |
| 29 | + |
| 30 | +/* Linker script to place sections and symbol values. Should be used together |
| 31 | + * with other linker script that defines memory regions FLASH and RAM. |
| 32 | + * It references following symbols, which must be defined in code: |
| 33 | + * Reset_Handler : Entry of reset handler |
| 34 | + * |
| 35 | + * It defines following symbols, which code can use without definition: |
| 36 | + * __exidx_start |
| 37 | + * __exidx_end |
| 38 | + * __copy_table_start__ |
| 39 | + * __copy_table_end__ |
| 40 | + * __zero_table_start__ |
| 41 | + * __zero_table_end__ |
| 42 | + * __etext |
| 43 | + * __data_start__ |
| 44 | + * __preinit_array_start |
| 45 | + * __preinit_array_end |
| 46 | + * __init_array_start |
| 47 | + * __init_array_end |
| 48 | + * __fini_array_start |
| 49 | + * __fini_array_end |
| 50 | + * __data_end__ |
| 51 | + * __bss_start__ |
| 52 | + * __bss_end__ |
| 53 | + * __end__ |
| 54 | + * end |
| 55 | + * __HeapLimit |
| 56 | + * __StackLimit |
| 57 | + * __StackTop |
| 58 | + * __stack |
| 59 | + * __FlashBase |
| 60 | + * __FlashLimit |
| 61 | + * |
| 62 | + * STM32L0 likes to see .text/.data to be 64 byte aligned. |
| 63 | + */ |
| 64 | + |
| 65 | +MEMORY |
| 66 | +{ |
| 67 | + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x00030000 |
| 68 | + SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00005000 |
| 69 | +} |
| 70 | + |
| 71 | +ENTRY(Reset_Handler) |
| 72 | + |
| 73 | +SECTIONS |
| 74 | +{ |
| 75 | + .text : ALIGN(64) |
| 76 | + { |
| 77 | + KEEP(*(.isr_vector)); |
| 78 | + |
| 79 | + *(.text .text.* .gnu.linkonce.t.*) |
| 80 | + |
| 81 | + KEEP(*(.init)) |
| 82 | + KEEP(*(.fini)) |
| 83 | + |
| 84 | + /* .ctors */ |
| 85 | + *crtbegin.o(.ctors) |
| 86 | + *crtbegin?.o(.ctors) |
| 87 | + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) |
| 88 | + *(SORT(.ctors.*)) |
| 89 | + *(.ctors) |
| 90 | + |
| 91 | + /* .dtors */ |
| 92 | + *crtbegin.o(.dtors) |
| 93 | + *crtbegin?.o(.dtors) |
| 94 | + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) |
| 95 | + *(SORT(.dtors.*)) |
| 96 | + *(.dtors) |
| 97 | + |
| 98 | + *(.rodata .rodata.* .gnu.linkonce.r.*) |
| 99 | + |
| 100 | + KEEP(*(.eh_frame*)) |
| 101 | + |
| 102 | + /* preinit data */ |
| 103 | + PROVIDE_HIDDEN (__preinit_array_start = .); |
| 104 | + KEEP(*(.preinit_array)) |
| 105 | + PROVIDE_HIDDEN (__preinit_array_end = .); |
| 106 | + |
| 107 | + /* init data */ |
| 108 | + PROVIDE_HIDDEN (__init_array_start = .); |
| 109 | + KEEP(*(SORT(.init_array.*))) |
| 110 | + KEEP(*(.init_array)) |
| 111 | + PROVIDE_HIDDEN (__init_array_end = .); |
| 112 | + |
| 113 | + /* finit data */ |
| 114 | + PROVIDE_HIDDEN (__fini_array_start = .); |
| 115 | + KEEP(*(SORT(.fini_array.*))) |
| 116 | + KEEP(*(.fini_array)) |
| 117 | + PROVIDE_HIDDEN (__fini_array_end = .); |
| 118 | + |
| 119 | + . = ALIGN(4); |
| 120 | + __copy_table_start__ = .; |
| 121 | + LONG (LOADADDR(.data)) |
| 122 | + LONG (__data_start__) |
| 123 | + LONG (__data_end__ - __data_start__) |
| 124 | + __copy_table_end__ = .; |
| 125 | + __zero_table_start__ = .; |
| 126 | + LONG (__bss_start__) |
| 127 | + LONG (__bss_end__ - __bss_start__) |
| 128 | + __zero_table_end__ = .; |
| 129 | + . = ALIGN(64); |
| 130 | + } > FLASH |
| 131 | + |
| 132 | + .ARM.extab : |
| 133 | + { |
| 134 | + *(.ARM.extab* .gnu.linkonce.armextab.*) |
| 135 | + } > FLASH |
| 136 | + |
| 137 | + .ARM.exidx : |
| 138 | + { |
| 139 | + PROVIDE_HIDDEN(__exidx_start = .); |
| 140 | + *(.ARM.exidx* .gnu.linkonce.armexidx.*) |
| 141 | + PROVIDE_HIDDEN(__exidx_end = .); |
| 142 | + } > FLASH |
| 143 | + |
| 144 | + __etext = . ; |
| 145 | + |
| 146 | + .stack (NOLOAD) : |
| 147 | + { |
| 148 | + __StackLimit = .; |
| 149 | + KEEP(*(.stack .stack.*)) |
| 150 | + . = ALIGN(1024); |
| 151 | + __StackTop = .; |
| 152 | + PROVIDE(__stack = __StackTop); |
| 153 | + } > SRAM |
| 154 | + |
| 155 | + .data : ALIGN(64) |
| 156 | + { |
| 157 | + __data_start__ = .; |
| 158 | + *(.ramfunc .ramfunc.*) |
| 159 | + . = ALIGN(8); |
| 160 | + *(vtable) |
| 161 | + . = ALIGN(8); |
| 162 | + *(.data .data.* .gnu.linkonce.d.*) |
| 163 | + . = ALIGN(8); |
| 164 | + __data_end__ = .; |
| 165 | + . = ALIGN(64); |
| 166 | + } > SRAM AT > FLASH |
| 167 | + |
| 168 | + .bss (NOLOAD) : |
| 169 | + { |
| 170 | + __bss_start__ = .; |
| 171 | + *(.bss .bss.* .gnu.linkonce.b.*) |
| 172 | + *(COMMON) |
| 173 | + . = ALIGN(8); |
| 174 | + __bss_end__ = .; |
| 175 | + } > SRAM |
| 176 | + |
| 177 | + .noinit (NOLOAD) : |
| 178 | + { |
| 179 | + *(.noinit .noinit.*) |
| 180 | + . = ALIGN(8); |
| 181 | + } > SRAM |
| 182 | + |
| 183 | + __end__ = . ; |
| 184 | + PROVIDE(end = .); |
| 185 | + |
| 186 | + __HeapLimit = ORIGIN(SRAM) + LENGTH(SRAM); |
| 187 | + __FlashBase = ALIGN(LOADADDR(.data) + SIZEOF(.data), 128); |
| 188 | + __FlashLimit = ORIGIN(FLASH) + LENGTH(FLASH); |
| 189 | + |
| 190 | + /* Stabs debugging sections. */ |
| 191 | + .stab 0 : { *(.stab) } |
| 192 | + .stabstr 0 : { *(.stabstr) } |
| 193 | + .stab.excl 0 : { *(.stab.excl) } |
| 194 | + .stab.exclstr 0 : { *(.stab.exclstr) } |
| 195 | + .stab.index 0 : { *(.stab.index) } |
| 196 | + .stab.indexstr 0 : { *(.stab.indexstr) } |
| 197 | + .comment 0 : { *(.comment) } |
| 198 | + /* DWARF debug sections. |
| 199 | + Symbols in the DWARF debugging sections are relative to the beginning |
| 200 | + of the section so we begin them at 0. */ |
| 201 | + /* DWARF 1 */ |
| 202 | + .debug 0 : { *(.debug) } |
| 203 | + .line 0 : { *(.line) } |
| 204 | + /* GNU DWARF 1 extensions */ |
| 205 | + .debug_srcinfo 0 : { *(.debug_srcinfo) } |
| 206 | + .debug_sfnames 0 : { *(.debug_sfnames) } |
| 207 | + /* DWARF 1.1 and DWARF 2 */ |
| 208 | + .debug_aranges 0 : { *(.debug_aranges) } |
| 209 | + .debug_pubnames 0 : { *(.debug_pubnames) } |
| 210 | + /* DWARF 2 */ |
| 211 | + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } |
| 212 | + .debug_abbrev 0 : { *(.debug_abbrev) } |
| 213 | + .debug_line 0 : { *(.debug_line) } |
| 214 | + .debug_frame 0 : { *(.debug_frame) } |
| 215 | + .debug_str 0 : { *(.debug_str) } |
| 216 | + .debug_loc 0 : { *(.debug_loc) } |
| 217 | + .debug_macinfo 0 : { *(.debug_macinfo) } |
| 218 | + /* SGI/MIPS DWARF 2 extensions */ |
| 219 | + .debug_weaknames 0 : { *(.debug_weaknames) } |
| 220 | + .debug_funcnames 0 : { *(.debug_funcnames) } |
| 221 | + .debug_typenames 0 : { *(.debug_typenames) } |
| 222 | + .debug_varnames 0 : { *(.debug_varnames) } |
| 223 | + /* DWARF 3 */ |
| 224 | + .debug_pubtypes 0 : { *(.debug_pubtypes) } |
| 225 | + .debug_ranges 0 : { *(.debug_ranges) } |
| 226 | + /* DWARF Extension. */ |
| 227 | + .debug_macro 0 : { *(.debug_macro) } |
| 228 | + .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) } |
| 229 | + .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) } |
| 230 | + /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } |
| 231 | +} |
0 commit comments