Skip to content

Commit 9ea3b06

Browse files
committed
[cortex-m] Fix linkerscript veneer offset issues
1 parent 735fd68 commit 9ea3b06

File tree

5 files changed

+27
-34
lines changed

5 files changed

+27
-34
lines changed

src/modm/platform/core/cortex/linker.macros

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
5050
%% endmacro
5151

5252

53-
%% macro section_vector_ram(memory)
53+
%% macro section_vector_ram(memory, table_copy)
54+
%% do table_copy.append("vector_table_ram")
5455
.vectors (NOLOAD) :
5556
{
5657
__vector_table_ram_start = .;
@@ -84,25 +85,17 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
8485

8586

8687
%% macro section_tables(memory, copy, zero, heap)
87-
%% if vector_table_location == "ram"
88-
%% do copy.insert(0, "vector_table_ram")
89-
%% endif
9088
.rodata :
9189
{
9290
. = ALIGN(4);
9391
__table_zero_intern_start = .;
94-
LONG(__bss_start)
95-
LONG(__bss_end)
9692
%% for name in zero
9793
LONG(__{{name}}_start)
9894
LONG(__{{name}}_end)
9995
%% endfor
10096
__table_zero_intern_end = .;
10197

10298
__table_copy_intern_start = .;
103-
LONG(__data_load)
104-
LONG(__data_start)
105-
LONG(__data_end)
10699
%% for name in copy
107100
LONG(__{{name}}_load)
108101
LONG(__{{name}}_start)
@@ -143,26 +136,29 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
143136
} >{{memory}}
144137
%% endmacro
145138

146-
%% macro section(memory, name, sections=[])
139+
%% macro section(memory, name, table_copy, sections=[])
140+
%% do table_copy.append(name)
147141
.{{name}} :
148142
{
149143
. = ALIGN(4);
150144
__{{name}}_load = LOADADDR(.{{name}});
151145
__{{name}}_start = .;
152146
*(.{{name}} .{{name}}.*)
153147
. = ALIGN(4);
148+
__{{name}}_end = .;
154149
} >{{memory}}
155150

151+
%% do table_copy.extend(sections)
156152
%% for section in sections
157153
.{{section}} :
158154
{
155+
__{{section}}_load = LOADADDR(.{{section}});
159156
__{{section}}_start = .;
160157
*(.{{section}} .{{section}}.*)
161158
. = ALIGN(4);
162159
__{{section}}_end = .;
163160
} >{{memory}}
164161
%% endfor
165-
__{{name}}_end = .;
166162
%% endmacro
167163

168164

@@ -192,8 +188,7 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
192188
%% for cont_region in cont_ram_regions
193189
%% for region in cont_region.contains
194190
%% if region.index
195-
{{ section(cont_region.name|upper + " AT >FLASH", "data_"+region.name) }}
196-
%% do table_copy.append("data_"+region.name)
191+
{{ section(cont_region.name|upper + " AT >FLASH", "data_"+region.name, table_copy) }}
197192
%% do table_zero.append("bss_"+region.name)
198193
%% endif
199194

@@ -280,16 +275,19 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
280275
%% endmacro
281276

282277

283-
%% macro section_ram(memory, rom, sections_data=[], sections_bss=[])
278+
%% macro section_ram(memory, rom, table_copy, table_zero, sections_data=[], sections_bss=[])
279+
%% do table_copy.append("data")
284280
.data :
285281
{
286282
. = ALIGN(4);
287283
__data_load = LOADADDR(.data);
288284
__data_start = .;
289285
*(.data .data.* .gnu.linkonce.d.*)
290286
. = ALIGN(4);
287+
__data_end = .;
291288
} >{{memory}} AT >{{rom}}
292289

290+
%% do table_copy.extend(sections_data)
293291
%% for section in sections_data
294292
.{{section}} :
295293
{
@@ -300,8 +298,8 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
300298
__{{section}}_end = .;
301299
} >{{memory}} AT >{{rom}}
302300
%% endfor
303-
__data_end = .;
304301

302+
%% do table_zero.append("bss")
305303
.bss (NOLOAD) :
306304
{
307305
__bss_start = . ;
@@ -310,6 +308,7 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
310308
__bss_end = .;
311309
} >{{memory}}
312310

311+
%% do table_zero.extend(sections_bss)
313312
%% for section in sections_bss
314313
.{{section}} (NOLOAD) :
315314
{
@@ -319,7 +318,6 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
319318
__{{section}}_end = .;
320319
} >{{memory}}
321320
%% endfor
322-
__bss_end = .;
323321

324322
.noinit (NOLOAD) :
325323
{

src/modm/platform/core/cortex/ram.ld.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ SECTIONS
2727
{{ linker.section_stack(cont_ram_regions[0].name|upper, "__vec_offset - TOTAL_STACK_SIZE") }}
2828

2929
%% if vector_table_location == "ram"
30-
{{ linker.section_vector_ram(cont_ram_regions[0].name|upper) }}
30+
{{ linker.section_vector_ram(cont_ram_regions[0].name|upper, table_copy) }}
3131
%% endif
3232

33-
{{ linker.section_ram(cont_ram_regions[0].name|upper, "FLASH",
33+
{{ linker.section_ram(cont_ram_regions[0].name|upper, "FLASH", table_copy, table_zero,
3434
sections_data=["fastdata", "fastcode", "data_" + cont_ram_regions[0].contains[0].name],
3535
sections_bss=["bss_" + cont_ram_regions[0].contains[0].name]) }}
3636

src/modm/platform/core/stm32/dccm.ld.in

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,26 @@ SECTIONS
2727
{{ linker.section_stack(cont_ram_regions[0].name|upper, "__vec_offset - TOTAL_STACK_SIZE") }}
2828

2929
%% if vector_table_location == "ram"
30-
{{ linker.section_vector_ram(cont_ram_regions[0].name|upper) }}
30+
{{ linker.section_vector_ram(cont_ram_regions[0].name|upper, table_copy) }}
3131
%% endif
3232

33-
{{ linker.section_ram(cont_ram_regions[0].name|upper, "FLASH",
33+
{{ linker.section_ram(cont_ram_regions[0].name|upper, "FLASH", table_copy, table_zero,
3434
sections_data=["fastcode", "data_" + cont_ram_regions[0].contains[0].name],
3535
sections_bss=["bss_" + cont_ram_regions[0].contains[0].name]) }}
3636

3737
{{ linker.all_heap_sections(table_copy, table_zero, table_heap) }}
3838

3939

4040
%% if "backup" in regions
41-
{{ linker.section("BACKUP AT >FLASH", "data_backup") }}
42-
%% do table_copy.append("data_backup")
41+
{{ linker.section("BACKUP AT >FLASH", "data_backup", table_copy) }}
4342

4443
{{ linker.section_heap("BACKUP", "heap_backup", sections=["bss_backup", "noinit_backup"]) }}
4544
%% do table_heap.append({"name": "heap_backup", "prop": "0x4009"})
4645
%% do table_zero.append("bss_backup")
4746
%% endif
4847

4948

50-
{{ linker.section("CCM AT >FLASH", "fastdata", sections=["data_ccm"]) }}
51-
%% do table_copy.append("fastdata")
49+
{{ linker.section("CCM AT >FLASH", "fastdata", table_copy, sections=["data_ccm"]) }}
5250

5351
{{ linker.section_heap("CCM", "heap_ccm", sections=["bss_ccm", "noinit_ccm"]) }}
5452
%% do table_heap.append({"name": "heap_ccm", "prop": "0x2002"})

src/modm/platform/core/stm32/iccm.ld.in

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ SECTIONS
1818

1919
{{ linker.section_stack(cont_ram_regions[0].name|upper) }}
2020

21-
{{ linker.section_ram(cont_ram_regions[0].name|upper, "FLASH",
21+
{{ linker.section_ram(cont_ram_regions[0].name|upper, "FLASH", table_copy, table_zero,
2222
sections_data=["data_" + cont_ram_regions[0].contains[0].name],
2323
sections_bss=["bss_" + cont_ram_regions[0].contains[0].name]) }}
2424

@@ -29,11 +29,10 @@ SECTIONS
2929

3030

3131
%% if vector_table_location == "ram"
32-
{{ linker.section_vector_ram("CCM") }}
32+
{{ linker.section_vector_ram("CCM", table_copy) }}
3333
%% endif
3434

35-
{{ linker.section("CCM AT >FLASH", "fastcode", sections=["fastdata", "data_ccm"]) }}
36-
%% do table_copy.append("fastcode")
35+
{{ linker.section("CCM AT >FLASH", "fastcode", table_copy, sections=["fastdata", "data_ccm"]) }}
3736

3837
{{ linker.section_heap("CCM", "heap_ccm", sections=["bss_ccm", "noinit_ccm"]) }}
3938
%% do table_heap.append({"name": "heap_ccm", "prop": "0x2006"})

src/modm/platform/core/stm32/idtcm.ld.in

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,18 @@ SECTIONS
1717

1818

1919
%% if vector_table_location == "ram"
20-
{{ linker.section_vector_ram("ITCM") }}
20+
{{ linker.section_vector_ram("ITCM", table_copy) }}
2121
%% endif
2222

23-
{{ linker.section("ITCM AT >FLASH", "fastcode", sections=["data_itcm"]) }}
24-
%% do table_copy.append("fastcode")
23+
{{ linker.section("ITCM AT >FLASH", "fastcode", table_copy, sections=["data_itcm"]) }}
2524

2625
{{ linker.section_heap("ITCM", "heap_itcm", sections=["noinit_itcm"]) }}
2726
%% do table_heap.append({"name": "heap_itcm", "prop": "0x201f"})
2827

2928

3029
{{ linker.section_stack("CONT_DTCM") }}
3130

32-
{{ linker.section_ram(cont_ram_regions[0].name|upper, "FLASH",
31+
{{ linker.section_ram(cont_ram_regions[0].name|upper, "FLASH", table_copy, table_zero,
3332
sections_data=["fastdata", "data_" + cont_ram_regions[0].contains[0].name],
3433
sections_bss=["bss_" + cont_ram_regions[0].contains[0].name]) }}
3534

@@ -40,8 +39,7 @@ SECTIONS
4039

4140

4241
%% if "backup" in regions
43-
{{ linker.section("BACKUP AT >FLASH", "data_backup") }}
44-
%% do table_copy.append("data_backup")
42+
{{ linker.section("BACKUP AT >FLASH", "data_backup", table_copy) }}
4543

4644
{{ linker.section_heap("BACKUP", "heap_backup", sections=["bss_backup", "noinit_backup"]) }}
4745
%% do table_heap.append({"name": "heap_backup", "prop": "0x4009"})

0 commit comments

Comments
 (0)