zephyr/tests/application_development/code_relocation/test_lib/test_lib1.c
Björn Stenberg 234fec579a 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 <bjorn@haxx.se>
2023-06-20 16:33:49 +02:00

44 lines
1.4 KiB
C

/*
* Copyright 2022 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include <zephyr/sys/printk.h>
#include <zephyr/ztest.h>
__in_section(data, sram2, var) uint32_t var_lib1_sram2_data = 10U;
__in_section(bss, sram2, var) uint32_t var_lib1_sram2_bss;
/* Helper function, declared in test_lib2.c */
extern void relocated_helper(void);
void relocated_library(void)
{
extern uintptr_t __sram2_text_reloc_start;
extern uintptr_t __sram2_text_reloc_end;
extern uintptr_t __sram2_data_reloc_start;
extern uintptr_t __sram2_data_reloc_end;
extern uintptr_t __sram2_bss_reloc_start;
extern uintptr_t __sram2_bss_reloc_end;
printk("Address of var_lib1_sram2_data %p\n", &var_lib1_sram2_data);
printk("Address of var_lib1_sram2_bss %p\n", &var_lib1_sram2_bss);
printk("Address of relocated_lib_helper %p\n\n", &relocated_helper);
zassert_between_inclusive((uintptr_t)&var_lib1_sram2_data,
(uintptr_t)&__sram2_data_reloc_start,
(uintptr_t)&__sram2_data_reloc_end,
"var_lib1_sram2_data not in sram2_data region");
zassert_between_inclusive((uintptr_t)&var_lib1_sram2_bss,
(uintptr_t)&__sram2_bss_reloc_start,
(uintptr_t)&__sram2_bss_reloc_end,
"var_lib1_sram2_bss not in sram2_bss region");
zassert_between_inclusive((uintptr_t)&relocated_helper,
(uintptr_t)&__sram2_text_reloc_start,
(uintptr_t)&__sram2_text_reloc_end,
"relocated_helper not in sram2_text region");
relocated_helper();
}