xref: /nrf52832-nimble/nordic/nrfx/mdk/nrf91_common.ld (revision 150812a83cab50279bd772ef6db1bfaf255f2c5b)
1/* Linker script for Nordic Semiconductor nRF91 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 */
18OUTPUT_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 *   __end__
40 *   end
41 *   __HeapLimit
42 *   __StackLimit
43 *   __StackTop
44 *   __stack
45 */
46ENTRY(Reset_Handler)
47
48SECTIONS
49{
50    .text :
51    {
52        KEEP(*(.isr_vector))
53        *(.text*)
54
55        KEEP(*(.init))
56        KEEP(*(.fini))
57
58        /* .ctors */
59        *crtbegin.o(.ctors)
60        *crtbegin?.o(.ctors)
61        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
62        *(SORT(.ctors.*))
63        *(.ctors)
64
65        /* .dtors */
66        *crtbegin.o(.dtors)
67        *crtbegin?.o(.dtors)
68        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
69        *(SORT(.dtors.*))
70        *(.dtors)
71
72        *(.rodata*)
73
74        *(.eh_frame*)
75        . = ALIGN(4);
76    } > FLASH
77
78
79    .ARM.extab :
80    {
81        *(.ARM.extab* .gnu.linkonce.armextab.*)
82        . = ALIGN(4);
83    } > FLASH
84
85    __exidx_start = .;
86    .ARM.exidx :
87    {
88        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
89        . = ALIGN(4);
90    } > FLASH
91    __exidx_end = .;
92
93    __etext = .;
94
95    .data : AT (__etext)
96    {
97        __data_start__ = .;
98        *(vtable)
99        *(.data*)
100
101        . = ALIGN(4);
102        /* preinit data */
103        PROVIDE_HIDDEN (__preinit_array_start = .);
104        KEEP(*(.preinit_array))
105        PROVIDE_HIDDEN (__preinit_array_end = .);
106
107        . = ALIGN(4);
108        /* init data */
109        PROVIDE_HIDDEN (__init_array_start = .);
110        KEEP(*(SORT(.init_array.*)))
111        KEEP(*(.init_array))
112        PROVIDE_HIDDEN (__init_array_end = .);
113
114
115        . = ALIGN(4);
116        /* finit data */
117        PROVIDE_HIDDEN (__fini_array_start = .);
118        KEEP(*(SORT(.fini_array.*)))
119        KEEP(*(.fini_array))
120        PROVIDE_HIDDEN (__fini_array_end = .);
121
122        *(.jcr)
123        . = ALIGN(4);
124        /* All data end */
125        __data_end__ = .;
126
127    } > RAM
128
129    .bss :
130    {
131        . = ALIGN(4);
132        __bss_start__ = .;
133        *(.bss*)
134        *(COMMON)
135        . = ALIGN(4);
136        __bss_end__ = .;
137    } > RAM
138
139    .heap (COPY):
140    {
141        __end__ = .;
142        end = __end__;
143        *(.heap*)
144        __HeapLimit = .;
145    } > RAM
146
147    /* .stack_dummy section doesn't contains any symbols. It is only
148     * used for linker to calculate size of stack sections, and assign
149     * values to stack symbols later */
150    .stack_dummy (COPY):
151    {
152        *(.stack*)
153    } > RAM
154
155    /* Set stack top to end of RAM, and stack limit move down by
156     * size of stack_dummy section */
157    __StackTop = ORIGIN(RAM) + LENGTH(RAM);
158    __StackLimit = __StackTop - SIZEOF(.stack_dummy);
159    PROVIDE(__stack = __StackTop);
160
161    /* Check if data + heap + stack exceeds RAM limit */
162    ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
163}