|
| 1 | +/* |
| 2 | + * This file is part of the libopencm3 project. |
| 3 | + * |
| 4 | + * Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de> |
| 5 | + * |
| 6 | + * This library is free software: you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU Lesser General Public License as published by |
| 8 | + * the Free Software Foundation, either version 3 of the License, or |
| 9 | + * (at your option) any later version. |
| 10 | + * |
| 11 | + * This library is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + * GNU Lesser General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU Lesser General Public License |
| 17 | + * along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + */ |
| 19 | + |
| 20 | +/* Generic linker script for STM32 targets using libopencm3. */ |
| 21 | + |
| 22 | +/* Memory regions must be defined in the ld script which includes this one. */ |
| 23 | + |
| 24 | +/* Enforce emmition of the vector table. */ |
| 25 | +EXTERN (vector_table) |
| 26 | + |
| 27 | +/* Define the entry point of the output file. */ |
| 28 | +ENTRY(reset_handler) |
| 29 | + |
| 30 | +/* Define sections. */ |
| 31 | +SECTIONS |
| 32 | +{ |
| 33 | + .vectors : { |
| 34 | + *(.vectors) /* Vector table */ |
| 35 | + } >vectors |
| 36 | + |
| 37 | + .text : { |
| 38 | + *(.text*) /* Program code */ |
| 39 | + . = ALIGN(4); |
| 40 | + *(.rodata*) /* Read-only data */ |
| 41 | + . = ALIGN(4); |
| 42 | + } >rom |
| 43 | + |
| 44 | + /* C++ Static constructors/destructors, also used for __attribute__ |
| 45 | + * ((constructor)) and the likes */ |
| 46 | + .preinit_array : { |
| 47 | + . = ALIGN(4); |
| 48 | + __preinit_array_start = .; |
| 49 | + KEEP (*(.preinit_array)) |
| 50 | + __preinit_array_end = .; |
| 51 | + } >rom |
| 52 | + .init_array : { |
| 53 | + . = ALIGN(4); |
| 54 | + __init_array_start = .; |
| 55 | + KEEP (*(SORT(.init_array.*))) |
| 56 | + KEEP (*(.init_array)) |
| 57 | + __init_array_end = .; |
| 58 | + } >rom |
| 59 | + .fini_array : { |
| 60 | + . = ALIGN(4); |
| 61 | + __fini_array_start = .; |
| 62 | + KEEP (*(.fini_array)) |
| 63 | + KEEP (*(SORT(.fini_array.*))) |
| 64 | + __fini_array_end = .; |
| 65 | + } >rom |
| 66 | + |
| 67 | + /* |
| 68 | + * Another section used by C++ stuff, appears when using newlib with |
| 69 | + * 64bit (long long) printf support |
| 70 | + */ |
| 71 | + .ARM.extab : { |
| 72 | + *(.ARM.extab*) |
| 73 | + } >rom |
| 74 | + .ARM.exidx : { |
| 75 | + __exidx_start = .; |
| 76 | + *(.ARM.exidx*) |
| 77 | + __exidx_end = .; |
| 78 | + } >rom |
| 79 | + |
| 80 | + . = ALIGN(4); |
| 81 | + _etext = .; |
| 82 | + |
| 83 | + .data : { |
| 84 | + _data = .; |
| 85 | + *(.data*) /* Read-write initialized data */ |
| 86 | + . = ALIGN(4); |
| 87 | + _edata = .; |
| 88 | + } >ram AT >rom |
| 89 | + _data_loadaddr = LOADADDR(.data); |
| 90 | + |
| 91 | + .bss : { |
| 92 | + *(.bss*) /* Read-write zero initialized data */ |
| 93 | + *(COMMON) |
| 94 | + . = ALIGN(4); |
| 95 | + _ebss = .; |
| 96 | + } >ram |
| 97 | + |
| 98 | + /* |
| 99 | + * The .eh_frame section appears to be used for C++ exception handling. |
| 100 | + * You may need to fix this if you're using C++. |
| 101 | + */ |
| 102 | + /DISCARD/ : { *(.eh_frame) } |
| 103 | + |
| 104 | + . = ALIGN(4); |
| 105 | + end = .; |
| 106 | +} |
| 107 | + |
| 108 | +PROVIDE(_stack = ORIGIN(ram) + LENGTH(ram)); |
| 109 | + |
0 commit comments