linkerscript.ld (3317B)
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 bl_rom (rx) : ORIGIN = 0x08000000, LENGTH = 16K 25 prm_rom (rx) : ORIGIN = 0x08004000, LENGTH = 16K 26 rom (rx) : ORIGIN = 0x08008000, LENGTH = 480K 27 ccm (xrw) : ORIGIN = 0x10000000, LENGTH = 64K 28 ram (rwx) : ORIGIN = 0x20000000, LENGTH = 128K 29 } 30 31 /* Enforce emmition of the vector table. */ 32 EXTERN (vector_table) 33 34 /* Define the entry point of the output file. */ 35 ENTRY(reset_handler) 36 37 /* Define sections. */ 38 SECTIONS 39 { 40 .bootloader : { 41 KEEP(*(.bootloader_section)) /* 16 KB */ 42 . = ALIGN(4); 43 } >bl_rom 44 45 .parameters : { 46 KEEP(*(.parameters_section)) /* 16 KB */ 47 . = ALIGN(4); 48 } >prm_rom 49 50 .text : { 51 *(.vectors) /* Vector table */ 52 KEEP(*(.firmware_info)) 53 *(.text*) /* Program code */ 54 . = ALIGN(4); 55 *(.rodata*) /* Read-only data */ 56 . = ALIGN(4); 57 } >rom 58 59 /* C++ Static constructors/destructors, also used for __attribute__ 60 * ((constructor)) and the likes */ 61 .preinit_array : { 62 . = ALIGN(4); 63 __preinit_array_start = .; 64 KEEP (*(.preinit_array)) 65 __preinit_array_end = .; 66 } >rom 67 .init_array : { 68 . = ALIGN(4); 69 __init_array_start = .; 70 KEEP (*(SORT(.init_array.*))) 71 KEEP (*(.init_array)) 72 __init_array_end = .; 73 } >rom 74 .fini_array : { 75 . = ALIGN(4); 76 __fini_array_start = .; 77 KEEP (*(.fini_array)) 78 KEEP (*(SORT(.fini_array.*))) 79 __fini_array_end = .; 80 } >rom 81 82 /* 83 * Another section used by C++ stuff, appears when using newlib with 84 * 64bit (long long) printf support 85 */ 86 .ARM.extab : { 87 *(.ARM.extab*) 88 } >rom 89 .ARM.exidx : { 90 __exidx_start = .; 91 *(.ARM.exidx*) 92 __exidx_end = .; 93 } >rom 94 95 . = ALIGN(4); 96 _etext = .; 97 98 /* ram, but not cleared on reset, eg boot/app comms */ 99 .noinit (NOLOAD) : { 100 *(.noinit*) 101 } >ram 102 . = ALIGN(4); 103 104 .data : { 105 _data = .; 106 *(.data*) /* Read-write initialized data */ 107 *(.ramtext*) /* "text" functions to run in ram */ 108 . = ALIGN(4); 109 _edata = .; 110 } >ram AT >rom 111 _data_loadaddr = LOADADDR(.data); 112 113 .ccmram : { 114 _sccmram = .; 115 *(.ccmram) 116 *(.ccmram*) 117 . = ALIGN(4); 118 _eccmram = .; 119 } >ccm AT >rom 120 _ccm_loadaddr = LOADADDR(.ccmram); 121 122 .bss : { 123 *(.bss*) /* Read-write zero initialized data */ 124 *(COMMON) 125 . = ALIGN(4); 126 _ebss = .; 127 } >ram 128 129 /* 130 * The .eh_frame section appears to be used for C++ exception handling. 131 * You may need to fix this if you're using C++. 132 */ 133 /* /DISCARD/ : { *(.eh_frame) } */ 134 135 . = ALIGN(4); 136 end = .; 137 } 138 139 PROVIDE(_stack = ORIGIN(ram) + LENGTH(ram));