From e6421b240b07a8f5381a3c674b9f7f818b771718 Mon Sep 17 00:00:00 2001 From: Abhishek Akkabathula Date: Mon, 11 Mar 2024 15:41:22 +0530 Subject: [PATCH] os/Makefile.unix, external, apps: include entire archives in common binary common binary was earlier compiled by only including the undefined symbols from the app binaries. However, because of this, it is tightly coupled with apps. So, irrespective of undefined app symbols, include all the symbols from USERLIBS in common binary --- apps/platform/gnu/Make.defs | 2 + apps/platform/gnu/gnu_unwind_find_exidx.c | 50 +++++++++++++++++++ build/configs/rtl8730e/Make.defs | 6 --- .../configs/rtl8730e/loadable_apps/defconfig | 30 +++-------- external/libcxx/Makefile | 2 - external/libcxx/new.cxx | 2 + lib/libc/machine/arm/armv7-a/arch_elf.c | 10 +++- os/Makefile.unix | 2 +- os/dbuild.sh | 2 +- os/include/wctype.h | 8 +++ os/userspace/userspace_apps.ld | 12 +++++ 11 files changed, 93 insertions(+), 33 deletions(-) create mode 100644 apps/platform/gnu/gnu_unwind_find_exidx.c diff --git a/apps/platform/gnu/Make.defs b/apps/platform/gnu/Make.defs index b9b4ba1c5f..8562aeeddf 100644 --- a/apps/platform/gnu/Make.defs +++ b/apps/platform/gnu/Make.defs @@ -56,6 +56,8 @@ ifeq ($(CONFIG_HAVE_CXXINITIALIZE),y) CSRCS += gnu_cxxinitialize.c endif +CSRCS += gnu_unwind_find_exidx.c + # Add the gnu/ sub-directory to the build VPATH += :gnu diff --git a/apps/platform/gnu/gnu_unwind_find_exidx.c b/apps/platform/gnu/gnu_unwind_find_exidx.c new file mode 100644 index 0000000000..c3da252334 --- /dev/null +++ b/apps/platform/gnu/gnu_unwind_find_exidx.c @@ -0,0 +1,50 @@ +/**************************************************************************** + * + * Copyright 2023 Samsung Electronics All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +extern void *__exidx_start; +extern void *__exidx_end; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: __gnu_Unwind_Find_exidx + * + * Description: + * This function is called (if exists) by the gcc generated unwind + * run-time in order to retrieve an alternative .ARM.exidx Exception + * index section. + * + ****************************************************************************/ + +volatile _Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr return_address, int *nrecp) +{ + *nrecp = &__exidx_end - &__exidx_start; + return (_Unwind_Ptr)&__exidx_start; +} diff --git a/build/configs/rtl8730e/Make.defs b/build/configs/rtl8730e/Make.defs index ab6f4823d4..688be42ea6 100755 --- a/build/configs/rtl8730e/Make.defs +++ b/build/configs/rtl8730e/Make.defs @@ -57,15 +57,9 @@ include ${TOPDIR}/arch/$(CONFIG_ARCH)/src/$(ARCH_FAMILY)/Toolchain.defs LDSCRIPT = rlx8730e_img2.ld ifeq ($(CONFIG_LIBCXX_HAVE_LIBSUPCXX),y) -ifeq ($(CONFIG_LIBCXX_EXCEPTION),y) LIBSUPXX = ${shell $(CC) $(CXXFLAGS) --print-file-name=libsupc++.a} EXTRA_LIBPATHS += -L "${shell dirname "$(LIBSUPXX)"}" EXTRA_LIBS += -lsupc++ -else -LIBSUPXX = ${shell $(CC) $(CXXFLAGS) --print-file-name=libsupc++_nano.a} -EXTRA_LIBPATHS += -L "${shell dirname "$(LIBSUPXX)"}" -EXTRA_LIBS += -lsupc++_nano -endif endif ifeq ($(WINTOOL),y) diff --git a/build/configs/rtl8730e/loadable_apps/defconfig b/build/configs/rtl8730e/loadable_apps/defconfig index 7636133c1f..b2b9843b35 100644 --- a/build/configs/rtl8730e/loadable_apps/defconfig +++ b/build/configs/rtl8730e/loadable_apps/defconfig @@ -24,7 +24,9 @@ CONFIG_TOOLS_DIR="../tools" CONFIG_APP_BINARY_SEPARATION=y CONFIG_NUM_APPS=2 # CONFIG_APPS_RAM_REGION_SHAREABLE is not set -# CONFIG_SUPPORT_COMMON_BINARY is not set +CONFIG_SUPPORT_COMMON_BINARY=y +CONFIG_COMMON_BINARY_VERSION="200204" +CONFIG_COMMON_BINARY_NAME="common" CONFIG_NUM_L2_PER_APP=4 CONFIG_BUILD_PROTECTED=y CONFIG_BUILD_2PASS=y @@ -304,9 +306,9 @@ CONFIG_ARCH_BOARD_HAVE_FLASH=y # CONFIG_FLASH_PARTITION=y CONFIG_FLASH_MINOR=0 -CONFIG_FLASH_PART_SIZE="60,40,12,400,1844,4808,384,1844,4808,384,512,1280,8," -CONFIG_FLASH_PART_TYPE="none,none,none,none,kernel,bin,bin,kernel,bin,bin,smartfs,ftl,bootparam," -CONFIG_FLASH_PART_NAME="bl1,reserved,ftl,ss,kernel,app1,app2,kernel,app1,app2,userfs,reserved,bootparam," +CONFIG_FLASH_PART_SIZE="60,40,12,400,1844,2808,384,2000,1844,2808,384,2000,512,1280,8," +CONFIG_FLASH_PART_TYPE="none,none,none,none,kernel,bin,bin,bin,kernel,bin,bin,bin,smartfs,ftl,bootparam," +CONFIG_FLASH_PART_NAME="bl1,reserved,ftl,ss,kernel,common,app1,app2,kernel,common,app1,app2,userfs,reserved,bootparam," # CONFIG_ARCH_BOARD_HAVE_SECOND_FLASH is not set CONFIG_AUTOMOUNT=y CONFIG_AUTOMOUNT_USERFS=y @@ -1177,7 +1179,7 @@ CONFIG_LIBC_SCANSET=y # CONFIG_NOPRINTF_LONGLONG_TO_ASCII is not set CONFIG_LIBC_IOCTL_VARIADIC=y CONFIG_LIBC_WCHAR=y -# CONFIG_LIBC_LOCALE is not set +CONFIG_LIBC_LOCALE=y CONFIG_LIB_RAND_ORDER=1 # CONFIG_EOL_IS_CR is not set # CONFIG_EOL_IS_LF is not set @@ -1255,22 +1257,7 @@ CONFIG_LIBCXX_HAVE_LIBSUPCXX=y # CONFIG_ENABLE_CURL is not set # CONFIG_ERROR_REPORT is not set # CONFIG_GMOCK is not set -CONFIG_ENABLE_IOTIVITY=y - -# -# IOTIVITY Config Parameters -# -CONFIG_IOTIVITY_RELEASE_VERSION="1.2-rel" -CONFIG_IOTIVITY_ROUTING="EP" -CONFIG_IOTIVITY_PTHREAD_STACKSIZE=16384 -CONFIG_IOTIVITY_QUEING_PTHREAD_STACKSIZE=5120 -CONFIG_IOTIVITY_RETRANSMIT_PTHREAD_STACKSIZE=2048 -CONFIG_IOTIVITY_TCPRECEIVE_PTHREAD_STACKSIZE=8192 -CONFIG_IOTIVITY_RECEIVEHANDLER_PTHREAD_STACKSIZE=8192 -CONFIG_ENABLE_IOTIVITY_SECURED=y -CONFIG_ENABLE_IOTIVITY_CLOUD=y -# CONFIG_IOTIVITY_DEBUG is not set -# CONFIG_IOTIVITY_NS_PROVIDER is not set +# CONFIG_ENABLE_IOTIVITY is not set CONFIG_NETUTILS_JSON=y # CONFIG_LIBTUV is not set # CONFIG_PROTOBUF is not set @@ -1361,7 +1348,6 @@ CONFIG_BUILTIN_APPS=y CONFIG_EXAMPLES_HELLO=y # CONFIG_EXAMPLES_HELLOXX is not set # CONFIG_EXAMPLES_IOTBUS_TEST is not set -# CONFIG_EXAMPLES_IOTIVITY is not set # CONFIG_EXAMPLES_IOTJS_STARTUP is not set # CONFIG_EXAMPLES_KERNEL_SAMPLE is not set # CONFIG_EXAMPLES_KERNEL_UPDATE is not set diff --git a/external/libcxx/Makefile b/external/libcxx/Makefile index 9f171b8771..85a19800d2 100644 --- a/external/libcxx/Makefile +++ b/external/libcxx/Makefile @@ -68,9 +68,7 @@ CXXSRCS += locale.cxx # Exception handling logic -ifeq ($(CONFIG_LIBCXX_EXCEPTION),y) CXXSRCS += exception.cxx stdexcept.cxx -endif # libsupc++ replacement diff --git a/external/libcxx/new.cxx b/external/libcxx/new.cxx index decbb26ed1..7c955db1c5 100644 --- a/external/libcxx/new.cxx +++ b/external/libcxx/new.cxx @@ -367,6 +367,7 @@ bad_array_length::~bad_array_length() _NOEXCEPT #ifndef LIBSTDCXX +#if 0 // definition already present in libxx_stdthrow.cxx void __throw_bad_alloc() { @@ -376,6 +377,7 @@ __throw_bad_alloc() _VSTD::abort(); #endif } +#endif #endif // !LIBSTDCXX diff --git a/lib/libc/machine/arm/armv7-a/arch_elf.c b/lib/libc/machine/arm/armv7-a/arch_elf.c index e072e42bdc..2e6daa6e76 100644 --- a/lib/libc/machine/arm/armv7-a/arch_elf.c +++ b/lib/libc/machine/arm/armv7-a/arch_elf.c @@ -350,7 +350,15 @@ int up_relocate(const Elf32_Rel *rel, const Elf32_Sym *sym, uintptr_t addr) binfo("insn [%04x %04x]\n", (int)upper_insn, (int)lower_insn); } - break; + break; + case R_ARM_TARGET2: /* TARGET2 is a platform-specific relocation: gcc-arm-none-eabi + * performs a self relocation */ + { + binfo("Performing TARGET2 link at addr=%08lx [%08lx] to sym=%p st_value=%08lx\n", (long)addr, (long)(*(uint32_t *)addr), sym, (long)sym->st_value); + + *(uint32_t *)addr += sym->st_value - addr; + } + break; case R_ARM_THM_CALL: case R_ARM_THM_JUMP24: diff --git a/os/Makefile.unix b/os/Makefile.unix index 755505411b..d817de5c4a 100644 --- a/os/Makefile.unix +++ b/os/Makefile.unix @@ -450,7 +450,7 @@ pass1: pass1deps ifeq ($(CONFIG_BUILD_2PASS),y) $(Q) $(MAKE) -C $(LOADABLE_APPDIR) TOPDIR="$(TOPDIR)" LOADABLEDIR="${LOADABLE_APPDIR}" LIBRARIES_DIR="$(LIBRARIES_DIR)" USERLIBS="$(USERLIBS)" all KERNEL=n ifeq ($(CONFIG_SUPPORT_COMMON_BINARY),y) - $(Q) $(LD) -r -o $(OUTBIN_DIR)/$(CONFIG_COMMON_BINARY_NAME) -T $(TOPDIR)/userspace/userspace_apps.ld -L $(LIBRARIES_DIR) --start-group $(USERLIBS) $(LIBGCC) $(LIBSUPXX) --end-group $$(cat $(OUTBIN_DIR)/lib_symbols.txt) + $(Q) $(LD) --force-group-allocation -r -o $(OUTBIN_DIR)/$(CONFIG_COMMON_BINARY_NAME) -T $(TOPDIR)/userspace/userspace_apps.ld -L $(LIBRARIES_DIR) --whole-archive $(USERLIBS) --no-whole-archive --start-group $(LIBGCC) $(LIBSUPXX) --end-group endif endif diff --git a/os/dbuild.sh b/os/dbuild.sh index 695b84bf14..e1cbd7fd62 100755 --- a/os/dbuild.sh +++ b/os/dbuild.sh @@ -26,7 +26,7 @@ BINDIR="${BUILDDIR}/output/bin" CONFIGDIR="${BUILDDIR}/configs" DOCKER_IMAGE= DOCKER_PUBLIC_IMAGE="tizenrt/tizenrt" -DOCKER_VERSION="1.5.8" +DOCKER_VERSION="2.0.0" STATUS_LIST="NOT_CONFIGURED BOARD_CONFIGURED CONFIGURED BUILT PREPARE_DL DOWNLOAD_READY" BUILD_CMD=make diff --git a/os/include/wctype.h b/os/include/wctype.h index ab4ab4a336..5f75e8a27b 100644 --- a/os/include/wctype.h +++ b/os/include/wctype.h @@ -105,6 +105,10 @@ typedef int wctrans_t; * Reference: Opengroup.org */ +#if defined(__cplusplus) +extern "C" { +#endif + int iswalnum(wint_t); int iswalpha(wint_t); int iswblank(wint_t); @@ -124,4 +128,8 @@ wint_t towupper(wint_t); wctrans_t wctrans(FAR const char *); wctype_t wctype(FAR const char *); +#if defined(__cplusplus) +} /* extern "C" */ +#endif + #endif /* INCLUDE_WTYPE_H */ diff --git a/os/userspace/userspace_apps.ld b/os/userspace/userspace_apps.ld index 5c76b05a8c..efa9949fce 100644 --- a/os/userspace/userspace_apps.ld +++ b/os/userspace/userspace_apps.ld @@ -128,6 +128,18 @@ SECTIONS _edtors = . ; } + .ARM.extab : + { + *(.ARM.extab*) + } + + .ARM.exidx : + { + __exidx_start = . ; + *(.ARM.exidx*) + __exidx_end = . ; + } + .bss : { _sbss = . ;