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