ARC: MWDT: get rid of MWDT startup libs

__cxa_atexit implementation provided by MWDT startup code calls
malloc which isn't supported right now. As we don't support
calling static destructors in Zephyr let's provide our own
__cxa_atexit stub and get rid of MWDT startup libs
entirely.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
This commit is contained in:
Evgeniy Paltsev 2021-08-30 22:40:45 +03:00 committed by Anas Nashif
commit 60fdec616b
6 changed files with 34 additions and 14 deletions

View file

@ -20,3 +20,7 @@ if(CONFIG_ISA_ARCV2)
endif()
add_subdirectory(core)
if(COMPILER STREQUAL arcmwdt)
add_subdirectory(arcmwdt)
endif()

View file

@ -0,0 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
if(CONFIG_ARCMWDT_LIBC OR CONFIG_CPLUSPLUS)
zephyr_sources(arcmwdt-dtr-stubs.c)
endif()

View file

@ -0,0 +1,22 @@
/*
* Copyright (c) 2021 Synopsys.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <toolchain.h>
__weak void *__dso_handle;
int __cxa_atexit(void (*destructor)(void *), void *objptr, void *dso)
{
ARG_UNUSED(destructor);
ARG_UNUSED(objptr);
ARG_UNUSED(dso);
return 0;
}
int atexit(void (*function)(void))
{
return 0;
}

View file

@ -119,13 +119,9 @@ macro(toolchain_ld_baremetal)
-Hhostlib=
-Hheap=0
-Hnoivt
-Hnocrt
)
# We only use CPP initialization code from crt
if(NOT CONFIG_CPLUSPLUS)
zephyr_ld_options(-Hnocrt)
endif()
# There are two options:
# - We have full MWDT libc support and we link MWDT libc - this is default
# behavior and we don't need to do something for that.

View file

@ -88,13 +88,6 @@ SECTIONS {
#include <linker/kobject-text.ld>
} GROUP_LINK_IN(ROMABLE_REGION)
#if defined(CONFIG_CPLUSPLUS) && !defined(CONFIG_CPP_STATIC_INIT_GNU) && defined(__MWDT_LINKER_CMD__)
/* .init section with code iterating over static objects constructors */
SECTION_PROLOGUE(.init,,ALIGN(4)) {
KEEP(*(.init*))
} GROUP_LINK_IN(ROMABLE_REGION)
#endif /* CONFIG_CPLUSPLUS && !CONFIG_CPP_STATIC_INIT_GNU && __MWDT_LINKER_CMD__ */
__text_region_end = .;
__rodata_region_start = .;

View file

@ -20,11 +20,11 @@ void z_cpp_init_static(void)
#else
#ifdef __CCAC__
void _init(void);
void __do_global_ctors_aux(void);
void z_cpp_init_static(void)
{
_init();
__do_global_ctors_aux();
}
#endif /* __CCAC__ */