1 /*
2 * Copyright 2022 NXP
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <zephyr/kernel.h>
8 #include <zephyr/sys/printk.h>
9 #include <zephyr/ztest.h>
10
11 __in_section(data, sram2, var) uint32_t var_lib1_sram2_data = 10U;
__in_section(bss,sram2,var)12 __in_section(bss, sram2, var) uint32_t var_lib1_sram2_bss;
13
14 /* Helper function, declared in test_lib2.c */
15 extern void relocated_helper(void);
16
17 void relocated_library(void)
18 {
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;
25
26 printk("Address of var_lib1_sram2_data %p\n", &var_lib1_sram2_data);
27 printk("Address of var_lib1_sram2_bss %p\n", &var_lib1_sram2_bss);
28 printk("Address of relocated_lib_helper %p\n\n", &relocated_helper);
29
30 zassert_between_inclusive((uintptr_t)&var_lib1_sram2_data,
31 (uintptr_t)&__sram2_data_reloc_start,
32 (uintptr_t)&__sram2_data_reloc_end,
33 "var_lib1_sram2_data not in sram2_data region");
34 zassert_between_inclusive((uintptr_t)&var_lib1_sram2_bss,
35 (uintptr_t)&__sram2_bss_reloc_start,
36 (uintptr_t)&__sram2_bss_reloc_end,
37 "var_lib1_sram2_bss not in sram2_bss region");
38 zassert_between_inclusive((uintptr_t)&relocated_helper,
39 (uintptr_t)&__sram2_text_reloc_start,
40 (uintptr_t)&__sram2_text_reloc_end,
41 "relocated_helper not in sram2_text region");
42 relocated_helper();
43 }
44