Austin Schuh | 41baf20 | 2022-01-01 14:33:40 -0800 | [diff] [blame^] | 1 | /** |
| 2 | * \file |
| 3 | * |
| 4 | * \brief Linker script for running in internal FLASH on the SAMD21G18A |
| 5 | * |
| 6 | * Copyright (c) 2017 Microchip Technology Inc. |
| 7 | * |
| 8 | * \asf_license_start |
| 9 | * |
| 10 | * \page License |
| 11 | * |
| 12 | * SPDX-License-Identifier: Apache-2.0 |
| 13 | * |
| 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 15 | * not use this file except in compliance with the License. |
| 16 | * You may obtain a copy of the Licence at |
| 17 | * |
| 18 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 19 | * |
| 20 | * Unless required by applicable law or agreed to in writing, software |
| 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
| 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 23 | * See the License for the specific language governing permissions and |
| 24 | * limitations under the License. |
| 25 | * |
| 26 | * \asf_license_stop |
| 27 | * |
| 28 | */ |
| 29 | |
| 30 | |
| 31 | OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") |
| 32 | OUTPUT_ARCH(arm) |
| 33 | SEARCH_DIR(.) |
| 34 | |
| 35 | /* Memory Spaces Definitions */ |
| 36 | MEMORY |
| 37 | { |
| 38 | rom (rx) : ORIGIN = 0x00000000 + 8K, LENGTH = 0x00040000 - 8K |
| 39 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 |
| 40 | } |
| 41 | |
| 42 | /* The stack size used by the application. NOTE: you need to adjust according to your application. */ |
| 43 | STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000; |
| 44 | |
| 45 | ENTRY(Reset_Handler) |
| 46 | |
| 47 | /* Section Definitions */ |
| 48 | SECTIONS |
| 49 | { |
| 50 | .text : |
| 51 | { |
| 52 | . = ALIGN(4); |
| 53 | _sfixed = .; |
| 54 | KEEP(*(.vectors .vectors.*)) |
| 55 | *(.text .text.* .gnu.linkonce.t.*) |
| 56 | *(.glue_7t) *(.glue_7) |
| 57 | *(.rodata .rodata* .gnu.linkonce.r.*) |
| 58 | *(.ARM.extab* .gnu.linkonce.armextab.*) |
| 59 | |
| 60 | /* Support C constructors, and C destructors in both user code |
| 61 | and the C library. This also provides support for C++ code. */ |
| 62 | . = ALIGN(4); |
| 63 | KEEP(*(.init)) |
| 64 | . = ALIGN(4); |
| 65 | __preinit_array_start = .; |
| 66 | KEEP (*(.preinit_array)) |
| 67 | __preinit_array_end = .; |
| 68 | |
| 69 | . = ALIGN(4); |
| 70 | __init_array_start = .; |
| 71 | KEEP (*(SORT(.init_array.*))) |
| 72 | KEEP (*(.init_array)) |
| 73 | __init_array_end = .; |
| 74 | |
| 75 | . = ALIGN(4); |
| 76 | KEEP (*crtbegin.o(.ctors)) |
| 77 | KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) |
| 78 | KEEP (*(SORT(.ctors.*))) |
| 79 | KEEP (*crtend.o(.ctors)) |
| 80 | |
| 81 | . = ALIGN(4); |
| 82 | KEEP(*(.fini)) |
| 83 | |
| 84 | . = ALIGN(4); |
| 85 | __fini_array_start = .; |
| 86 | KEEP (*(.fini_array)) |
| 87 | KEEP (*(SORT(.fini_array.*))) |
| 88 | __fini_array_end = .; |
| 89 | |
| 90 | KEEP (*crtbegin.o(.dtors)) |
| 91 | KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) |
| 92 | KEEP (*(SORT(.dtors.*))) |
| 93 | KEEP (*crtend.o(.dtors)) |
| 94 | |
| 95 | . = ALIGN(4); |
| 96 | _efixed = .; /* End of text section */ |
| 97 | } > rom |
| 98 | |
| 99 | /* .ARM.exidx is sorted, so has to go in its own output section. */ |
| 100 | PROVIDE_HIDDEN (__exidx_start = .); |
| 101 | .ARM.exidx : |
| 102 | { |
| 103 | *(.ARM.exidx* .gnu.linkonce.armexidx.*) |
| 104 | } > rom |
| 105 | PROVIDE_HIDDEN (__exidx_end = .); |
| 106 | |
| 107 | . = ALIGN(4); |
| 108 | _etext = .; |
| 109 | |
| 110 | .relocate : AT (_etext) |
| 111 | { |
| 112 | . = ALIGN(4); |
| 113 | _srelocate = .; |
| 114 | *(.ramfunc .ramfunc.*); |
| 115 | *(.data .data.*); |
| 116 | . = ALIGN(4); |
| 117 | _erelocate = .; |
| 118 | } > ram |
| 119 | |
| 120 | /* .bss section which is used for uninitialized data */ |
| 121 | .bss (NOLOAD) : |
| 122 | { |
| 123 | . = ALIGN(4); |
| 124 | _sbss = . ; |
| 125 | _szero = .; |
| 126 | *(.bss .bss.*) |
| 127 | *(COMMON) |
| 128 | . = ALIGN(4); |
| 129 | _ebss = . ; |
| 130 | _ezero = .; |
| 131 | end = .; |
| 132 | } > ram |
| 133 | |
| 134 | /* stack section */ |
| 135 | .stack (NOLOAD): |
| 136 | { |
| 137 | . = ALIGN(8); |
| 138 | _sstack = .; |
| 139 | . = . + STACK_SIZE; |
| 140 | . = ALIGN(8); |
| 141 | _estack = .; |
| 142 | } > ram |
| 143 | |
| 144 | . = ALIGN(4); |
| 145 | _end = . ; |
| 146 | } |