|
| 1 | +/* Linker script for Nordic Semiconductor nRF5 devices |
| 2 | + * |
| 3 | + * Version: Sourcery G++ 4.5-1 |
| 4 | + * Support: https://support.codesourcery.com/GNUToolchain/ |
| 5 | + * |
| 6 | + * Copyright (c) 2007, 2008, 2009, 2010 CodeSourcery, Inc. |
| 7 | + * |
| 8 | + * The authors hereby grant permission to use, copy, modify, distribute, |
| 9 | + * and license this software and its documentation for any purpose, provided |
| 10 | + * that existing copyright notices are retained in all copies and that this |
| 11 | + * notice is included verbatim in any distributions. No written agreement, |
| 12 | + * license, or royalty fee is required for any of the authorized uses. |
| 13 | + * Modifications to this software may be copyrighted by their authors |
| 14 | + * and need not follow the licensing terms described here, provided that |
| 15 | + * the new terms are clearly indicated on the first page of each file where |
| 16 | + * they apply. |
| 17 | + */ |
| 18 | +OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") |
| 19 | + |
| 20 | +/* Linker script to place sections and symbol values. Should be used together |
| 21 | + * with other linker script that defines memory regions FLASH and RAM. |
| 22 | + * It references following symbols, which must be defined in code: |
| 23 | + * Reset_Handler : Entry of reset handler |
| 24 | + * |
| 25 | + * It defines following symbols, which code can use without definition: |
| 26 | + * __exidx_start |
| 27 | + * __exidx_end |
| 28 | + * __etext |
| 29 | + * __data_start__ |
| 30 | + * __preinit_array_start |
| 31 | + * __preinit_array_end |
| 32 | + * __init_array_start |
| 33 | + * __init_array_end |
| 34 | + * __fini_array_start |
| 35 | + * __fini_array_end |
| 36 | + * __data_end__ |
| 37 | + * __bss_start__ |
| 38 | + * __bss_end__ |
| 39 | + * __HeapBase |
| 40 | + * __HeapLimit |
| 41 | + * __StackLimit |
| 42 | + * __StackTop |
| 43 | + * __stack |
| 44 | + * __bssnz_start__ |
| 45 | + * __bssnz_end__ |
| 46 | + */ |
| 47 | +ENTRY(Reset_Handler) |
| 48 | + |
| 49 | +SECTIONS |
| 50 | +{ |
| 51 | + .imghdr (NOLOAD): |
| 52 | + { |
| 53 | + . = . + _imghdr_size; |
| 54 | + } > FLASH |
| 55 | + |
| 56 | + __text = .; |
| 57 | + |
| 58 | + .text : |
| 59 | + { |
| 60 | + __isr_vector_start = .; |
| 61 | + KEEP(*(.isr_vector)) |
| 62 | + __isr_vector_end = .; |
| 63 | + EXCLUDE_FILE(*liblc3.a: *libm.a: *libsamplerate.a: *audio_usb.o) *(.text*) |
| 64 | + |
| 65 | + KEEP(*(.init)) |
| 66 | + KEEP(*(.fini)) |
| 67 | + |
| 68 | + . = ALIGN(4); |
| 69 | + /* preinit data */ |
| 70 | + PROVIDE_HIDDEN (__preinit_array_start = .); |
| 71 | + KEEP(*(.preinit_array)) |
| 72 | + PROVIDE_HIDDEN (__preinit_array_end = .); |
| 73 | + |
| 74 | + . = ALIGN(4); |
| 75 | + /* init data */ |
| 76 | + PROVIDE_HIDDEN (__init_array_start = .); |
| 77 | + KEEP(*(SORT(.init_array.*))) |
| 78 | + KEEP(*(.init_array)) |
| 79 | + PROVIDE_HIDDEN (__init_array_end = .); |
| 80 | + |
| 81 | + . = ALIGN(4); |
| 82 | + /* finit data */ |
| 83 | + PROVIDE_HIDDEN (__fini_array_start = .); |
| 84 | + KEEP(*(SORT(.fini_array.*))) |
| 85 | + KEEP(*(.fini_array)) |
| 86 | + PROVIDE_HIDDEN (__fini_array_end = .); |
| 87 | + |
| 88 | + /* .ctors */ |
| 89 | + *crtbegin.o(.ctors) |
| 90 | + *crtbegin?.o(.ctors) |
| 91 | + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) |
| 92 | + *(SORT(.ctors.*)) |
| 93 | + *(.ctors) |
| 94 | + |
| 95 | + /* .dtors */ |
| 96 | + *crtbegin.o(.dtors) |
| 97 | + *crtbegin?.o(.dtors) |
| 98 | + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) |
| 99 | + *(SORT(.dtors.*)) |
| 100 | + *(.dtors) |
| 101 | + |
| 102 | + EXCLUDE_FILE(*liblc3.a: *libsamplerate.a:) *(.rodata*) |
| 103 | + |
| 104 | + *(.eh_frame*) |
| 105 | + PROVIDE(mynewt_main = main); |
| 106 | + . = ALIGN(4); |
| 107 | + } > FLASH |
| 108 | + |
| 109 | + |
| 110 | + .net_core_img : |
| 111 | + { |
| 112 | + PROVIDE(net_core_img_start = .); |
| 113 | + KEEP(*(.net_core_img)); |
| 114 | + PROVIDE(net_core_img_end = .); |
| 115 | + } > FLASH |
| 116 | + |
| 117 | + .ARM.extab : |
| 118 | + { |
| 119 | + *(.ARM.extab* .gnu.linkonce.armextab.*) |
| 120 | + . = ALIGN(4); |
| 121 | + } > FLASH |
| 122 | + |
| 123 | + __exidx_start = .; |
| 124 | + .ARM.exidx : |
| 125 | + { |
| 126 | + *(.ARM.exidx* .gnu.linkonce.armexidx.*) |
| 127 | + . = ALIGN(4); |
| 128 | + } > FLASH |
| 129 | + __exidx_end = .; |
| 130 | + |
| 131 | + __etext = .; |
| 132 | + |
| 133 | + .vector_relocation : |
| 134 | + { |
| 135 | + . = ALIGN(4); |
| 136 | + __vector_tbl_reloc__ = .; |
| 137 | + . = . + (__isr_vector_end - __isr_vector_start); |
| 138 | + . = ALIGN(4); |
| 139 | + } > RAM |
| 140 | + |
| 141 | + /* Section for app-net cores IPC */ |
| 142 | + .ipc 0x20000400 (NOLOAD): |
| 143 | + { |
| 144 | + . = ALIGN(4); |
| 145 | + *(.ipc) |
| 146 | + . = ALIGN(4); |
| 147 | + } > RAM |
| 148 | + |
| 149 | + /* This section will be zeroed by RTT package init */ |
| 150 | + .rtt (NOLOAD): |
| 151 | + { |
| 152 | + . = ALIGN(4); |
| 153 | + *(.rtt) |
| 154 | + . = ALIGN(4); |
| 155 | + } > RAM |
| 156 | + |
| 157 | + .data : |
| 158 | + { |
| 159 | + __data_start__ = .; |
| 160 | + *(vtable) |
| 161 | + *(.data*) |
| 162 | + |
| 163 | + *(.jcr) |
| 164 | + *liblc3.a:(.text* .rodata*) |
| 165 | + *libsamplerate.a:(.text* .rodata*) |
| 166 | + *audio_usb.o(.text*) |
| 167 | + *libm.a:(.text*) |
| 168 | + . = ALIGN(4); |
| 169 | + /* All data end */ |
| 170 | + __data_end__ = .; |
| 171 | + } > RAM AT > FLASH |
| 172 | + |
| 173 | + /* Non-zeroed BSS. This section is similar to BSS, but does not get zeroed at init-time. |
| 174 | + */ |
| 175 | + .bssnz : |
| 176 | + { |
| 177 | + . = ALIGN(4); |
| 178 | + __bssnz_start__ = .; |
| 179 | + *(.bss.core.nz*) |
| 180 | + . = ALIGN(4); |
| 181 | + __bssnz_end__ = .; |
| 182 | + } > RAM |
| 183 | + |
| 184 | + .bss : |
| 185 | + { |
| 186 | + . = ALIGN(4); |
| 187 | + __bss_start__ = .; |
| 188 | + *(.bss*) |
| 189 | + *(COMMON) |
| 190 | + . = ALIGN(4); |
| 191 | + __bss_end__ = .; |
| 192 | + } > RAM |
| 193 | + |
| 194 | + /* Heap starts after BSS */ |
| 195 | + . = ALIGN(8); |
| 196 | + __HeapBase = .; |
| 197 | + |
| 198 | + /* .stack_dummy section doesn't contains any symbols. It is only |
| 199 | + * used for linker to calculate size of stack sections, and assign |
| 200 | + * values to stack symbols later */ |
| 201 | + .stack_dummy (COPY): |
| 202 | + { |
| 203 | + *(.stack*) |
| 204 | + } > RAM |
| 205 | + |
| 206 | + _ram_start = ORIGIN(RAM); |
| 207 | + |
| 208 | + /* Set stack top to end of RAM, and stack limit move down by |
| 209 | + * size of stack_dummy section */ |
| 210 | + __StackTop = ORIGIN(RAM) + LENGTH(RAM); |
| 211 | + __StackLimit = __StackTop - SIZEOF(.stack_dummy); |
| 212 | + PROVIDE(__stack = __StackTop); |
| 213 | + |
| 214 | + /* Top of head is the bottom of the stack */ |
| 215 | + __HeapLimit = __StackLimit; |
| 216 | + |
| 217 | + /* Check if data + heap + stack exceeds RAM limit */ |
| 218 | + ASSERT(__HeapBase <= __HeapLimit, "region RAM overflowed with stack") |
| 219 | +} |
| 220 | + |
0 commit comments