linker: align _ramfunc_ram/rom_start/size linker symbol names

Cleanup and preparation commit for linker script generator.

Zephyr linker scripts provides start and end symbols for each section,
and sometimes even size and LMA start symbols.

Generally, start and end symbols uses the following pattern, as:
Section name:             foo
Section start symbol:     __foo_start
Section end symbol:       __foo_end

However, this pattern is not followed consistently.
To allow for linker script generation and ensure consistent naming of
symbols then the following pattern is introduced consistently to allow
for cleaner linker script generation.
Section name:             foo
Section start symbol:     __foo_start
Section end symbol:       __foo_end
Section size symbol:      __foo_size
Section LMA start symbol: __foo_load_start

This commit aligns the symbols for _ramfunc_ram/rom to other symbols and
in such a way they follow consistent pattern which allows for linker
script and scatter file generation.

The symbols are named according to the section name they describe.
Section name is `ramfunc`

The following symbols are aligned in this commit:
-  _ramfunc_ram_start  -> __ramfunc_start
-  _ramfunc_ram_end    -> __ramfunc_end
-  _ramfunc_ram_size   -> __ramfunc_size
-  _ramfunc_rom_start  -> __ramfunc_load_start

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2021-05-21 21:29:59 +02:00 committed by Anas Nashif
parent 65a2de84a9
commit 510d7dbfb6
5 changed files with 21 additions and 21 deletions

View File

@ -82,8 +82,8 @@ static const struct z_arm_mpu_partition static_regions[] = {
#if defined(CONFIG_ARCH_HAS_RAMFUNC_SUPPORT)
{
/* Special RAM area for program text */
.start = (uint32_t)&_ramfunc_ram_start,
.size = (uint32_t)&_ramfunc_ram_size,
.start = (uint32_t)&__ramfunc_start,
.size = (uint32_t)&__ramfunc_size,
.attr = K_MEM_PARTITION_P_RX_U_RX,
},
#endif /* CONFIG_ARCH_HAS_RAMFUNC_SUPPORT */

View File

@ -9,12 +9,12 @@
SECTION_DATA_PROLOGUE(.ramfunc,,)
{
MPU_ALIGN(_ramfunc_ram_size);
_ramfunc_ram_start = .;
MPU_ALIGN(__ramfunc_size);
__ramfunc_start = .;
*(.ramfunc)
*(".ramfunc.*")
MPU_ALIGN(_ramfunc_ram_size);
_ramfunc_ram_end = .;
MPU_ALIGN(__ramfunc_size);
__ramfunc_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
_ramfunc_ram_size = _ramfunc_ram_end - _ramfunc_ram_start;
_ramfunc_rom_start = LOADADDR(.ramfunc);
__ramfunc_size = __ramfunc_end - __ramfunc_start;
__ramfunc_load_start = LOADADDR(.ramfunc);

View File

@ -336,10 +336,10 @@ extern char _nocache_ram_size[];
* section, stored in RAM instead of FLASH.
*/
#ifdef CONFIG_ARCH_HAS_RAMFUNC_SUPPORT
extern char _ramfunc_ram_start[];
extern char _ramfunc_ram_end[];
extern char _ramfunc_ram_size[];
extern char _ramfunc_rom_start[];
extern char __ramfunc_start[];
extern char __ramfunc_end[];
extern char __ramfunc_size[];
extern char __ramfunc_load_start[];
#endif /* CONFIG_ARCH_HAS_RAMFUNC_SUPPORT */
/* Memory owned by the kernel. Memory region for thread privilege stack buffers,

View File

@ -28,8 +28,8 @@ void z_data_copy(void)
(void)memcpy(&__data_region_start, &__data_region_load_start,
__data_region_end - __data_region_start);
#ifdef CONFIG_ARCH_HAS_RAMFUNC_SUPPORT
(void)memcpy(&_ramfunc_ram_start, &_ramfunc_rom_start,
(uintptr_t) &_ramfunc_ram_size);
(void)memcpy(&__ramfunc_start, &__ramfunc_load_start,
(uintptr_t) &__ramfunc_size);
#endif /* CONFIG_ARCH_HAS_RAMFUNC_SUPPORT */
#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_ccm), okay)
(void)memcpy(&__ccm_data_start, &__ccm_data_rom_start,

View File

@ -26,22 +26,22 @@ void test_arm_ramfunc(void)
* inside SRAM, and that arm_ram_function(.) is located inside
* the .ramfunc section.
*/
zassert_true((uint32_t)&_ramfunc_ram_size != 0,
zassert_true((uint32_t)&__ramfunc_size != 0,
".ramfunc linker section is empty");
zassert_true(((uint32_t)&_ramfunc_ram_start >= (uint32_t)&_image_ram_start)
&& ((uint32_t)&_ramfunc_ram_end < (uint32_t)&_image_ram_end),
zassert_true(((uint32_t)&__ramfunc_start >= (uint32_t)&_image_ram_start)
&& ((uint32_t)&__ramfunc_end < (uint32_t)&_image_ram_end),
".ramfunc linker section not in RAM");
zassert_true(
(((uint32_t)&_ramfunc_ram_start) <= (uint32_t)arm_ram_function) &&
(((uint32_t)&_ramfunc_ram_end) > (uint32_t)arm_ram_function),
(((uint32_t)&__ramfunc_start) <= (uint32_t)arm_ram_function) &&
(((uint32_t)&__ramfunc_end) > (uint32_t)arm_ram_function),
"arm_ram_function not loaded into .ramfunc");
/* If we build with User Mode support, verify that the
* arm_ram_function(.) is user (read) accessible.
*/
#if defined(CONFIG_USERSPACE)
zassert_true(arch_buffer_validate((void *)&_ramfunc_ram_start,
(size_t)&_ramfunc_ram_size, 0) == 0 /* Success */,
zassert_true(arch_buffer_validate((void *)&__ramfunc_start,
(size_t)&__ramfunc_size, 0) == 0 /* Success */,
".ramfunc section not user accessible");
#endif /* CONFIG_USERSPACE */