Skip to content

Commit 678c39b

Browse files
ARC: init constructors for MWDT
Signed-off-by: Evgeniy Paltsev <[email protected]>
1 parent 9b86169 commit 678c39b

File tree

6 files changed

+44
-13
lines changed

6 files changed

+44
-13
lines changed

cmake/linker/arcmwdt/target.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ macro(toolchain_ld_baremetal)
110110
zephyr_ld_options(
111111
-Hlld
112112
-Hnosdata
113-
-Hnocrt
114113
-Xtimer0 # to suppress the warning message
115114
-Hnoxcheck_obj
116115
-Hnocplus
117116
-Hcl
118117
-Hheap=0
119118
-Hnoivt
119+
-arcv2hs
120120
)
121121

122122
# Funny thing is if this is set to =error, some architectures will

include/arch/arc/v2/linker.ld

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ SECTIONS {
8787
* zephyr_linker_sources() Cmake function.
8888
*/
8989
#include <snippets-rom-start.ld>
90-
*(.text .text.*)
90+
*(.text .text* .text.*)
9191
*(.gnu.linkonce.t.*)
9292

9393
. = ALIGN(4);
@@ -115,6 +115,32 @@ SECTIONS {
115115

116116
#ifdef __MWDT_LINKER_CMD__
117117
/* TODO: add mwdt specific ROM C++ sections */
118+
119+
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,) {
120+
. = ALIGN(4);
121+
_fctors = .;
122+
KEEP(*(.ctors .ctors* .ctors.*))
123+
_ectors = .;
124+
125+
. = ALIGN(4);
126+
_fdtors = .;
127+
KEEP(*(.dtors .dtors* .dtors.*))
128+
_edtors = .;
129+
130+
. = ALIGN(4);
131+
_feh_frame = .;
132+
KEEP(*(.eh_frame .eh_frame* .eh_frame.*))
133+
_eeh_frame = .;
134+
} GROUP_LINK_IN(ROMABLE_REGION)
135+
136+
SECTION_PROLOGUE(.init,,ALIGN(4)) {
137+
KEEP(*(.init*))
138+
} GROUP_LINK_IN(ROMABLE_REGION)
139+
140+
SECTION_PROLOGUE(.fini,,ALIGN(4)) {
141+
KEEP(*(.fini*))
142+
} GROUP_LINK_IN(ROMABLE_REGION)
143+
118144
#else
119145
#include <linker/cplusplus-rom.ld>
120146
#endif /* __MWDT_LINKER_CMD__ */

include/linker/common-rom.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
}
3838
ASSERT(SIZEOF(initlevel_error) == 0, "Undefined initialization levels used.")
3939

40-
#ifdef CONFIG_CPLUSPLUS
40+
#if defined(CONFIG_CPLUSPLUS) && !defined(__MWDT_LINKER_CMD__)
4141
SECTION_PROLOGUE(_CTOR_SECTION_NAME,,)
4242
{
4343
/*

include/sys/cbprintf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
extern "C" {
2121
#endif
2222

23+
#define Z_C_GENERIC 0
24+
2325
/* Determine if _Generic is supported.
2426
* In general it's a C11 feature but it was added also in:
2527
* - GCC 4.9.0 https://gcc.gnu.org/gcc-4.9/changes.html

kernel/init.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,14 @@ static void bg_thread_main(void *unused1, void *unused2, void *unused3)
153153
boot_banner();
154154

155155
#ifdef CONFIG_CPLUSPLUS
156-
/* Process the .ctors and .init_array sections */
157-
extern void __do_global_ctors_aux(void);
158-
extern void __do_init_array_aux(void);
159-
__do_global_ctors_aux();
160-
__do_init_array_aux();
156+
// /* Process the .ctors and .init_array sections */
157+
// extern void __do_global_ctors_aux(void);
158+
// extern void __do_init_array_aux(void);
159+
// __do_global_ctors_aux();
160+
// __do_init_array_aux();
161+
162+
_init();
163+
// _mwrtl_init();
161164
#endif
162165

163166
/* Final init level before app starts */

subsys/cpp/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# SPDX-License-Identifier: Apache-2.0
22

3-
zephyr_sources(
4-
cpp_init_array.c
5-
cpp_ctors.c
6-
cpp_dtors.c
7-
)
3+
#zephyr_sources(
4+
# cpp_init_array.c
5+
# cpp_ctors.c
6+
# cpp_dtors.c
7+
#)
88

99
if (NOT CONFIG_LIB_CPLUSPLUS AND
1010
(NOT CONFIG_MINIMAL_LIBC OR

0 commit comments

Comments
 (0)