xref: /nrf52832-nimble/nordic/nrfx/mdk/nrf52_common.ld (revision 150812a83cab50279bd772ef6db1bfaf255f2c5b)
1/* Deprecated linker script for Nordic Semiconductor nRF52 devices,
2 * please use nrfx_common.ld. This version exists for backwards
3 * compatibility.
4 *
5 * Version: Sourcery G++ 4.5-1
6 * Support: https://support.codesourcery.com/GNUToolchain/
7 *
8 * Copyright (c) 2007, 2008, 2009, 2010 CodeSourcery, Inc.
9 *
10 * The authors hereby grant permission to use, copy, modify, distribute,
11 * and license this software and its documentation for any purpose, provided
12 * that existing copyright notices are retained in all copies and that this
13 * notice is included verbatim in any distributions.  No written agreement,
14 * license, or royalty fee is required for any of the authorized uses.
15 * Modifications to this software may be copyrighted by their authors
16 * and need not follow the licensing terms described here, provided that
17 * the new terms are clearly indicated on the first page of each file where
18 * they apply.
19 */
20OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
21
22/* Linker script to place sections and symbol values. Should be used together
23 * with other linker script that defines memory regions FLASH and RAM.
24 * It references following symbols, which must be defined in code:
25 *   Reset_Handler : Entry of reset handler
26 *
27 * It defines following symbols, which code can use without definition:
28 *   __exidx_start
29 *   __exidx_end
30 *   __etext
31 *   __data_start__
32 *   __preinit_array_start
33 *   __preinit_array_end
34 *   __init_array_start
35 *   __init_array_end
36 *   __fini_array_start
37 *   __fini_array_end
38 *   __data_end__
39 *   __bss_start__
40 *   __bss_end__
41 *   __end__
42 *   end
43 *   __HeapBase
44 *   __HeapLimit
45 *   __StackLimit
46 *   __StackTop
47 *   __stack
48 */
49ENTRY(Reset_Handler)
50
51SECTIONS
52{
53    .text :
54    {
55        KEEP(*(.isr_vector))
56        *(.text*)
57
58        KEEP(*(.init))
59        KEEP(*(.fini))
60
61        /* .ctors */
62        *crtbegin.o(.ctors)
63        *crtbegin?.o(.ctors)
64        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
65        *(SORT(.ctors.*))
66        *(.ctors)
67
68        /* .dtors */
69        *crtbegin.o(.dtors)
70        *crtbegin?.o(.dtors)
71        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
72        *(SORT(.dtors.*))
73        *(.dtors)
74
75        *(.rodata*)
76
77        KEEP(*(.eh_frame*))
78    } > FLASH
79
80    .ARM.extab :
81    {
82        *(.ARM.extab* .gnu.linkonce.armextab.*)
83    } > FLASH
84
85    __exidx_start = .;
86    .ARM.exidx :
87    {
88        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
89    } > FLASH
90    __exidx_end = .;
91
92    __etext = .;
93
94    .data : AT (__etext)
95    {
96        __data_start__ = .;
97        *(vtable)
98        *(.data*)
99
100        . = ALIGN(4);
101        /* preinit data */
102        PROVIDE_HIDDEN (__preinit_array_start = .);
103        KEEP(*(.preinit_array))
104        PROVIDE_HIDDEN (__preinit_array_end = .);
105
106        . = ALIGN(4);
107        /* init data */
108        PROVIDE_HIDDEN (__init_array_start = .);
109        KEEP(*(SORT(.init_array.*)))
110        KEEP(*(.init_array))
111        PROVIDE_HIDDEN (__init_array_end = .);
112
113
114        . = ALIGN(4);
115        /* finit data */
116        PROVIDE_HIDDEN (__fini_array_start = .);
117        KEEP(*(SORT(.fini_array.*)))
118        KEEP(*(.fini_array))
119        PROVIDE_HIDDEN (__fini_array_end = .);
120
121        KEEP(*(.jcr*))
122        . = ALIGN(4);
123        /* All data end */
124        __data_end__ = .;
125
126    } > RAM
127
128    .bss :
129    {
130        . = ALIGN(4);
131        __bss_start__ = .;
132        *(.bss*)
133        *(COMMON)
134        . = ALIGN(4);
135        __bss_end__ = .;
136    } > RAM
137
138    .heap (COPY):
139    {
140        __HeapBase = .;
141        __end__ = .;
142        PROVIDE(end = .);
143        KEEP(*(.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        KEEP(*(.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
164    /* Check if text sections + data exceeds FLASH limit */
165    DataInitFlashUsed = __bss_start__ - __data_start__;
166    CodeFlashUsed = __etext - ORIGIN(FLASH);
167    TotalFlashUsed = CodeFlashUsed + DataInitFlashUsed;
168    ASSERT(TotalFlashUsed <= LENGTH(FLASH), "region FLASH overflowed with .data and user data")
169
170}
171