Skip to content

Commit 234fec5

Browse files
zagorcarlescufi
authored andcommitted
scripts: gen_relocate_app.py: Give sections unique names
The code_relocation feature creates generic section names that sometimes conflict with already existing names. This patch adds a '_reloc_' word to the created names to reduce the risk of conflict. This solves #54785. Signed-off-by: Björn Stenberg <[email protected]>
1 parent e0cdb01 commit 234fec5

File tree

7 files changed

+68
-68
lines changed

7 files changed

+68
-68
lines changed

arch/arm/core/aarch32/mpu/arm_core_mpu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ uint32_t z_arm_mpu_stack_guard_and_fpu_adjust(struct k_thread *thread);
5858
#endif
5959

6060
#if defined(CONFIG_CODE_DATA_RELOCATION_SRAM)
61-
extern char __ram_text_start[];
62-
extern char __ram_text_size[];
61+
extern char __ram_text_reloc_start[];
62+
extern char __ram_text_reloc_size[];
6363
#endif
6464

6565
static const struct z_arm_mpu_partition static_regions[] = {
@@ -92,8 +92,8 @@ static const struct z_arm_mpu_partition static_regions[] = {
9292
#if defined(CONFIG_CODE_DATA_RELOCATION_SRAM)
9393
{
9494
/* RAM area for relocated text */
95-
.start = (uint32_t)&__ram_text_start,
96-
.size = (uint32_t)&__ram_text_size,
95+
.start = (uint32_t)&__ram_text_reloc_start,
96+
.size = (uint32_t)&__ram_text_reloc_size,
9797
.attr = K_MEM_PARTITION_P_RX_U_RX,
9898
},
9999
#endif /* CONFIG_CODE_DATA_RELOCATION_SRAM */

scripts/build/gen_relocate_app.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class OutputSection(NamedTuple):
101101
"""
102102

103103
SECTION_LOAD_MEMORY_SEQ = """
104-
__{0}_{1}_rom_start = LOADADDR(_{2}_{3}_SECTION_NAME);
104+
__{0}_{1}_rom_start = LOADADDR(.{0}_{1}_reloc);
105105
"""
106106

107107
LOAD_ADDRESS_LOCATION_FLASH = """
@@ -135,33 +135,33 @@ class OutputSection(NamedTuple):
135135
136136
/* Linker section for memory region {2} for {3} section */
137137
138-
SECTION_PROLOGUE(_{2}_{3}_SECTION_NAME,,)
138+
SECTION_PROLOGUE(.{0}_{1}_reloc,,)
139139
{{
140140
. = ALIGN(4);
141141
{4}
142142
. = ALIGN(4);
143143
}} {5}
144-
__{0}_{1}_end = .;
145-
__{0}_{1}_start = ADDR(_{2}_{3}_SECTION_NAME);
146-
__{0}_{1}_size = SIZEOF(_{2}_{3}_SECTION_NAME);
144+
__{0}_{1}_reloc_end = .;
145+
__{0}_{1}_reloc_start = ADDR(.{0}_{1}_reloc);
146+
__{0}_{1}_reloc_size = __{0}_{1}_reloc_end - __{0}_{1}_reloc_start;
147147
"""
148148

149149
LINKER_SECTION_SEQ_MPU = """
150150
151151
/* Linker section for memory region {2} for {3} section */
152152
153-
SECTION_PROLOGUE(_{2}_{3}_SECTION_NAME,,)
153+
SECTION_PROLOGUE(.{0}_{1}_reloc,,)
154154
{{
155-
__{0}_{1}_start = .;
155+
__{0}_{1}_reloc_start = .;
156156
{4}
157157
#if {6}
158158
. = ALIGN({6});
159159
#else
160-
MPU_ALIGN(__{0}_{1}_size);
160+
MPU_ALIGN(__{0}_{1}_reloc_size);
161161
#endif
162-
__{0}_{1}_end = .;
162+
__{0}_{1}_reloc_end = .;
163163
}} {5}
164-
__{0}_{1}_size = __{0}_{1}_end - __{0}_{1}_start;
164+
__{0}_{1}_reloc_size = __{0}_{1}_reloc_end - __{0}_{1}_reloc_start;
165165
"""
166166

167167
SOURCE_CODE_INCLUDES = """
@@ -173,9 +173,9 @@ class OutputSection(NamedTuple):
173173
"""
174174

175175
EXTERN_LINKER_VAR_DECLARATION = """
176-
extern char __{0}_{1}_start[];
176+
extern char __{0}_{1}_reloc_start[];
177177
extern char __{0}_{1}_rom_start[];
178-
extern char __{0}_{1}_size[];
178+
extern char __{0}_{1}_reloc_size[];
179179
"""
180180

181181

@@ -194,14 +194,14 @@ class OutputSection(NamedTuple):
194194
"""
195195

196196
MEMCPY_TEMPLATE = """
197-
z_early_memcpy(&__{0}_{1}_start, &__{0}_{1}_rom_start,
198-
(size_t) &__{0}_{1}_size);
197+
z_early_memcpy(&__{0}_{1}_reloc_start, &__{0}_{1}_rom_start,
198+
(size_t) &__{0}_{1}_reloc_size);
199199
200200
"""
201201

202202
MEMSET_TEMPLATE = """
203-
z_early_memset(&__{0}_bss_start, 0,
204-
(size_t) &__{0}_bss_size);
203+
z_early_memset(&__{0}_bss_reloc_start, 0,
204+
(size_t) &__{0}_bss_reloc_size);
205205
"""
206206

207207

tests/application_development/code_relocation/src/test_file1.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ void function_in_custom_section(void);
2929

3030
ZTEST(code_relocation, test_function_in_sram2)
3131
{
32-
extern uintptr_t __sram2_text_start;
33-
extern uintptr_t __sram2_text_end;
34-
extern uintptr_t __sram2_data_start;
35-
extern uintptr_t __sram2_data_end;
36-
extern uintptr_t __sram2_bss_start;
37-
extern uintptr_t __sram2_bss_end;
38-
extern uintptr_t __sram2_rodata_start;
39-
extern uintptr_t __sram2_rodata_end;
32+
extern uintptr_t __sram2_text_reloc_start;
33+
extern uintptr_t __sram2_text_reloc_end;
34+
extern uintptr_t __sram2_data_reloc_start;
35+
extern uintptr_t __sram2_data_reloc_end;
36+
extern uintptr_t __sram2_bss_reloc_start;
37+
extern uintptr_t __sram2_bss_reloc_end;
38+
extern uintptr_t __sram2_rodata_reloc_start;
39+
extern uintptr_t __sram2_rodata_reloc_end;
4040
extern uintptr_t __custom_section_start;
4141
extern uintptr_t __custom_section_end;
4242

@@ -47,20 +47,20 @@ ZTEST(code_relocation, test_function_in_sram2)
4747
printk("Address of var_sram2_bss %p\n\n", &var_sram2_bss);
4848

4949
zassert_between_inclusive((uintptr_t)&var_sram2_data,
50-
(uintptr_t)&__sram2_data_start,
51-
(uintptr_t)&__sram2_data_end,
50+
(uintptr_t)&__sram2_data_reloc_start,
51+
(uintptr_t)&__sram2_data_reloc_end,
5252
"var_sram2_data not in sram2 region");
5353
zassert_between_inclusive((uintptr_t)&k_sem_give,
54-
(uintptr_t)&__sram2_text_start,
55-
(uintptr_t)&__sram2_text_end,
54+
(uintptr_t)&__sram2_text_reloc_start,
55+
(uintptr_t)&__sram2_text_reloc_end,
5656
"k_sem_give not in sram_text region");
5757
zassert_between_inclusive((uintptr_t)&var_sram2_rodata,
58-
(uintptr_t)&__sram2_rodata_start,
59-
(uintptr_t)&__sram2_rodata_end,
58+
(uintptr_t)&__sram2_rodata_reloc_start,
59+
(uintptr_t)&__sram2_rodata_reloc_end,
6060
"var_sram2_rodata not in sram2_rodata region");
6161
zassert_between_inclusive((uintptr_t)&var_sram2_bss,
62-
(uintptr_t)&__sram2_bss_start,
63-
(uintptr_t)&__sram2_bss_end,
62+
(uintptr_t)&__sram2_bss_reloc_start,
63+
(uintptr_t)&__sram2_bss_reloc_end,
6464
"var_sram2_bss not in sram2_bss region");
6565

6666
/* Print values from sram */

tests/application_development/code_relocation/src/test_file3.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ ZTEST(code_relocation, test_function_in_split_multiple)
1515
{
1616
extern uintptr_t __data_start;
1717
extern uintptr_t __data_end;
18-
extern uintptr_t __sram2_bss_start;
19-
extern uintptr_t __sram2_bss_end;
18+
extern uintptr_t __sram2_bss_reloc_start;
19+
extern uintptr_t __sram2_bss_reloc_end;
2020

2121
printk("Address of var_file3_sram_data %p\n", &var_file3_sram_data);
2222
printk("Address of var_file3_sram2_bss %p\n\n", &var_file3_sram2_bss);
@@ -26,7 +26,7 @@ ZTEST(code_relocation, test_function_in_split_multiple)
2626
(uintptr_t)&__data_end,
2727
"var_file3_sram_data not in sram_data region");
2828
zassert_between_inclusive((uintptr_t)&var_file3_sram2_bss,
29-
(uintptr_t)&__sram2_bss_start,
30-
(uintptr_t)&__sram2_bss_end,
29+
(uintptr_t)&__sram2_bss_reloc_start,
30+
(uintptr_t)&__sram2_bss_reloc_end,
3131
"var_file3_sram2_bss not in sram2_bss region");
3232
}

tests/application_development/code_relocation/src/test_file4.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ __in_section(bss, sram2, var) uint32_t var_file4_sram2_bss;
1313

1414
ZTEST(code_relocation, test_function_genex_relocate_1)
1515
{
16-
extern uintptr_t __sram2_data_start;
17-
extern uintptr_t __sram2_data_end;
18-
extern uintptr_t __sram2_bss_start;
19-
extern uintptr_t __sram2_bss_end;
16+
extern uintptr_t __sram2_data_reloc_start;
17+
extern uintptr_t __sram2_data_reloc_end;
18+
extern uintptr_t __sram2_bss_reloc_start;
19+
extern uintptr_t __sram2_bss_reloc_end;
2020

2121
printk("Address of var_file4_sram2_data %p\n", &var_file4_sram2_data);
2222
printk("Address of var_file4_sram2_bss %p\n\n", &var_file4_sram2_bss);
2323

2424
zassert_between_inclusive((uintptr_t)&var_file4_sram2_data,
25-
(uintptr_t)&__sram2_data_start,
26-
(uintptr_t)&__sram2_data_end,
25+
(uintptr_t)&__sram2_data_reloc_start,
26+
(uintptr_t)&__sram2_data_reloc_end,
2727
"var_file4_sram2_data not in sram2_data region");
2828
zassert_between_inclusive((uintptr_t)&var_file4_sram2_bss,
29-
(uintptr_t)&__sram2_bss_start,
30-
(uintptr_t)&__sram2_bss_end,
29+
(uintptr_t)&__sram2_bss_reloc_start,
30+
(uintptr_t)&__sram2_bss_reloc_end,
3131
"var_file4_sram2_bss not in sram2_bss region");
3232
}

tests/application_development/code_relocation/src/test_file5.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ __in_section(bss, sram2, var) uint32_t var_file5_sram2_bss;
1313

1414
ZTEST(code_relocation, test_function_genex_relocate_2)
1515
{
16-
extern uintptr_t __sram2_data_start;
17-
extern uintptr_t __sram2_data_end;
18-
extern uintptr_t __sram2_bss_start;
19-
extern uintptr_t __sram2_bss_end;
16+
extern uintptr_t __sram2_data_reloc_start;
17+
extern uintptr_t __sram2_data_reloc_end;
18+
extern uintptr_t __sram2_bss_reloc_start;
19+
extern uintptr_t __sram2_bss_reloc_end;
2020

2121
printk("Address of var_file5_sram2_data %p\n", &var_file5_sram2_data);
2222
printk("Address of var_file5_sram2_bss %p\n\n", &var_file5_sram2_bss);
2323

2424
zassert_between_inclusive((uintptr_t)&var_file5_sram2_data,
25-
(uintptr_t)&__sram2_data_start,
26-
(uintptr_t)&__sram2_data_end,
25+
(uintptr_t)&__sram2_data_reloc_start,
26+
(uintptr_t)&__sram2_data_reloc_end,
2727
"var_file5_sram2_data not in sram2_data region");
2828
zassert_between_inclusive((uintptr_t)&var_file5_sram2_bss,
29-
(uintptr_t)&__sram2_bss_start,
30-
(uintptr_t)&__sram2_bss_end,
29+
(uintptr_t)&__sram2_bss_reloc_start,
30+
(uintptr_t)&__sram2_bss_reloc_end,
3131
"var_file5_sram2_bss not in sram2_bss region");
3232
}

tests/application_development/code_relocation/test_lib/test_lib1.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,28 @@ extern void relocated_helper(void);
1616

1717
void relocated_library(void)
1818
{
19-
extern uintptr_t __sram2_text_start;
20-
extern uintptr_t __sram2_text_end;
21-
extern uintptr_t __sram2_data_start;
22-
extern uintptr_t __sram2_data_end;
23-
extern uintptr_t __sram2_bss_start;
24-
extern uintptr_t __sram2_bss_end;
19+
extern uintptr_t __sram2_text_reloc_start;
20+
extern uintptr_t __sram2_text_reloc_end;
21+
extern uintptr_t __sram2_data_reloc_start;
22+
extern uintptr_t __sram2_data_reloc_end;
23+
extern uintptr_t __sram2_bss_reloc_start;
24+
extern uintptr_t __sram2_bss_reloc_end;
2525

2626
printk("Address of var_lib1_sram2_data %p\n", &var_lib1_sram2_data);
2727
printk("Address of var_lib1_sram2_bss %p\n", &var_lib1_sram2_bss);
2828
printk("Address of relocated_lib_helper %p\n\n", &relocated_helper);
2929

3030
zassert_between_inclusive((uintptr_t)&var_lib1_sram2_data,
31-
(uintptr_t)&__sram2_data_start,
32-
(uintptr_t)&__sram2_data_end,
31+
(uintptr_t)&__sram2_data_reloc_start,
32+
(uintptr_t)&__sram2_data_reloc_end,
3333
"var_lib1_sram2_data not in sram2_data region");
3434
zassert_between_inclusive((uintptr_t)&var_lib1_sram2_bss,
35-
(uintptr_t)&__sram2_bss_start,
36-
(uintptr_t)&__sram2_bss_end,
35+
(uintptr_t)&__sram2_bss_reloc_start,
36+
(uintptr_t)&__sram2_bss_reloc_end,
3737
"var_lib1_sram2_bss not in sram2_bss region");
3838
zassert_between_inclusive((uintptr_t)&relocated_helper,
39-
(uintptr_t)&__sram2_text_start,
40-
(uintptr_t)&__sram2_text_end,
39+
(uintptr_t)&__sram2_text_reloc_start,
40+
(uintptr_t)&__sram2_text_reloc_end,
4141
"relocated_helper not in sram2_text region");
4242
relocated_helper();
4343
}

0 commit comments

Comments
 (0)