Skip to content

Commit 3c29a11

Browse files
committed
Fix link error because of missing file "nrf_common.ld"
1 parent f23ef84 commit 3c29a11

File tree

3 files changed

+173
-1
lines changed

3 files changed

+173
-1
lines changed

gcc_nrf52.ld

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,4 @@ SECTIONS
133133
} INSERT AFTER .text
134134

135135

136-
INCLUDE "nrf_common.ld"
136+
INCLUDE "./nrf_common.ld"

nrf_common.ld

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

src/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,8 @@ include_directories(
7979
libs/date/includes
8080
)
8181

82+
link_directories(
83+
../
84+
)
85+
8286
nRF5x_addExecutable(pinetime-app "${SOURCE_FILES}")

0 commit comments

Comments
 (0)