aboutsummaryrefslogtreecommitdiff
path: root/tests/nrf
diff options
context:
space:
mode:
authorPriit Laes <[email protected]>2024-01-05 14:47:56 +0200
committerPriit Laes <[email protected]>2024-01-05 14:47:56 +0200
commit17346fdfc22a34d651d9d30bcc35125916ee44b5 (patch)
tree51e9e0d379215c790626c176bcf3d392b18ec13c /tests/nrf
parent9c2d2ff64d302437e2e0568372c76bf37bbfacf4 (diff)
tests: nrf: Sync link_ram.x from upstream
Upstream has added bunch of improvements and fixes to linker script, so sync these while keeping the FLASH -> RAM changes.
Diffstat (limited to 'tests/nrf')
-rw-r--r--tests/nrf/link_ram.x46
1 files changed, 34 insertions, 12 deletions
diff --git a/tests/nrf/link_ram.x b/tests/nrf/link_ram.x
index 26da86baa..5cb23a642 100644
--- a/tests/nrf/link_ram.x
+++ b/tests/nrf/link_ram.x
@@ -1,5 +1,5 @@
1/* ##### EMBASSY NOTE 1/* ##### EMBASSY NOTE
2 Originally from https://github.com/rust-embedded/cortex-m-rt/blob/master/link.x.in 2 Originally from https://github.com/rust-embedded/cortex-m/blob/master/cortex-m-rt/link.x.in
3 Adjusted to put everything in RAM 3 Adjusted to put everything in RAM
4*/ 4*/
5 5
@@ -65,22 +65,30 @@ PROVIDE(__pre_init = DefaultPreInit);
65/* # Sections */ 65/* # Sections */
66SECTIONS 66SECTIONS
67{ 67{
68 PROVIDE(_stack_start = ORIGIN(RAM) + LENGTH(RAM)); 68 PROVIDE(_ram_start = ORIGIN(RAM));
69 PROVIDE(_ram_end = ORIGIN(RAM) + LENGTH(RAM));
70 PROVIDE(_stack_start = _ram_end);
69 71
70 /* ## Sections in RAM */ 72 /* ## Sections in RAM */
71 /* ### Vector table */ 73 /* ### Vector table */
72 .vector_table ORIGIN(RAM) : 74 .vector_table ORIGIN(RAM) :
73 { 75 {
74 /* Initial Stack Pointer (SP) value */ 76 __vector_table = .;
75 LONG(_stack_start); 77
78 /* Initial Stack Pointer (SP) value.
79 * We mask the bottom three bits to force 8-byte alignment.
80 * Despite having an assert for this later, it's possible that a separate
81 * linker script could override _stack_start after the assert is checked.
82 */
83 LONG(_stack_start & 0xFFFFFFF8);
76 84
77 /* Reset vector */ 85 /* Reset vector */
78 KEEP(*(.vector_table.reset_vector)); /* this is the `__RESET_VECTOR` symbol */ 86 KEEP(*(.vector_table.reset_vector)); /* this is the `__RESET_VECTOR` symbol */
79 __reset_vector = .;
80 87
81 /* Exceptions */ 88 /* Exceptions */
89 __exceptions = .; /* start of exceptions */
82 KEEP(*(.vector_table.exceptions)); /* this is the `__EXCEPTIONS` symbol */ 90 KEEP(*(.vector_table.exceptions)); /* this is the `__EXCEPTIONS` symbol */
83 __eexceptions = .; 91 __eexceptions = .; /* end of exceptions */
84 92
85 /* Device specific interrupts */ 93 /* Device specific interrupts */
86 KEEP(*(.vector_table.interrupts)); /* this is the `__INTERRUPTS` symbol */ 94 KEEP(*(.vector_table.interrupts)); /* this is the `__INTERRUPTS` symbol */
@@ -125,7 +133,6 @@ SECTIONS
125 { 133 {
126 . = ALIGN(4); 134 . = ALIGN(4);
127 __sdata = .; 135 __sdata = .;
128 __edata = .;
129 *(.data .data.*); 136 *(.data .data.*);
130 . = ALIGN(4); /* 4-byte align the end (VMA) of this section */ 137 . = ALIGN(4); /* 4-byte align the end (VMA) of this section */
131 } > RAM 138 } > RAM
@@ -133,6 +140,7 @@ SECTIONS
133 * use the .data loading mechanism by pushing __edata. Note: do not change 140 * use the .data loading mechanism by pushing __edata. Note: do not change
134 * output region or load region in those user sections! */ 141 * output region or load region in those user sections! */
135 . = ALIGN(4); 142 . = ALIGN(4);
143 __edata = .;
136 144
137 /* LMA of .data */ 145 /* LMA of .data */
138 __sidata = LOADADDR(.data); 146 __sidata = LOADADDR(.data);
@@ -147,8 +155,12 @@ SECTIONS
147 __veneer_base = .; 155 __veneer_base = .;
148 *(.gnu.sgstubs*) 156 *(.gnu.sgstubs*)
149 . = ALIGN(32); 157 . = ALIGN(32);
150 __veneer_limit = .;
151 } > RAM 158 } > RAM
159 /* Place `__veneer_limit` outside the `.gnu.sgstubs` section because veneers are
160 * always inserted last in the section, which would otherwise be _after_ the `__veneer_limit` symbol.
161 */
162 . = ALIGN(32);
163 __veneer_limit = .;
152 164
153 /* ### .bss */ 165 /* ### .bss */
154 .bss (NOLOAD) : ALIGN(4) 166 .bss (NOLOAD) : ALIGN(4)
@@ -213,10 +225,21 @@ BUG(cortex-m-rt): .bss is not 4-byte aligned");
213ASSERT(__sheap % 4 == 0, " 225ASSERT(__sheap % 4 == 0, "
214BUG(cortex-m-rt): start of .heap is not 4-byte aligned"); 226BUG(cortex-m-rt): start of .heap is not 4-byte aligned");
215 227
228ASSERT(_stack_start % 8 == 0, "
229ERROR(cortex-m-rt): stack start address is not 8-byte aligned.
230If you have set _stack_start, check it's set to an address which is a multiple of 8 bytes.
231If you haven't, stack starts at the end of RAM by default. Check that both RAM
232origin and length are set to multiples of 8 in the `memory.x` file.");
233
216/* # Position checks */ 234/* # Position checks */
217 235
218/* ## .vector_table */ 236/* ## .vector_table
219ASSERT(__reset_vector == ADDR(.vector_table) + 0x8, " 237 *
238 * If the *start* of exception vectors is not 8 bytes past the start of the
239 * vector table, then we somehow did not place the reset vector, which should
240 * live 4 bytes past the start of the vector table.
241 */
242ASSERT(__exceptions == ADDR(.vector_table) + 0x8, "
220BUG(cortex-m-rt): the reset vector is missing"); 243BUG(cortex-m-rt): the reset vector is missing");
221 244
222ASSERT(__eexceptions == ADDR(.vector_table) + 0x40, " 245ASSERT(__eexceptions == ADDR(.vector_table) + 0x40, "
@@ -248,7 +271,6 @@ the 'cc' crate then modify your build script to compile the C code _without_
248the -fPIC flag. See the documentation of the `cc::Build.pic` method for details."); 271the -fPIC flag. See the documentation of the `cc::Build.pic` method for details.");
249/* Do not exceed this mark in the error messages above | */ 272/* Do not exceed this mark in the error messages above | */
250 273
251
252/* Provides weak aliases (cf. PROVIDED) for device specific interrupt handlers */ 274/* Provides weak aliases (cf. PROVIDED) for device specific interrupt handlers */
253/* This will usually be provided by a device crate generated using svd2rust (see `device.x`) */ 275/* This will usually be provided by a device crate generated using svd2rust (see `device.x`) */
254INCLUDE device.x \ No newline at end of file 276INCLUDE device.x