mirror of
https://github.com/apache/nuttx.git
synced 2025-05-08 22:32:04 +08:00
binfmt:use crt0 inside of starthook
test: 1.use mps3-an547 build helloxx as module and run it 2.use qemu-armv7a:knsh test kernel build helloxx and run it Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
parent
297a1cb1fe
commit
422c43949a
@ -169,11 +169,14 @@ $(AOBJS) $(UAOBJS) $(HEAD_OBJ): %$(OBJEXT): %.S
|
||||
$(COBJS) $(UCOBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
$(STARTUP_OBJS): %$(OBJEXT): %.c
|
||||
$(Q) $(CC) $(CELFFLAGS) -c common$(DELIM)crt0.c -o crt0$(OBJEXT)
|
||||
|
||||
ifeq ($(CONFIG_BUILD_FLAT),y)
|
||||
$(BIN): $(OBJS)
|
||||
$(BIN): $(STARTUP_OBJS) $(OBJS)
|
||||
$(call ARCHIVE, $@, $(OBJS))
|
||||
else
|
||||
$(BIN): $(UOBJS)
|
||||
$(BIN): $(STARTUP_OBJS) $(UOBJS)
|
||||
$(call ARCHIVE, $@, $(UOBJS))
|
||||
endif
|
||||
|
||||
|
@ -29,13 +29,6 @@ include common/Make.defs
|
||||
|
||||
HEAD_ASRC += arm_vectortab.S
|
||||
|
||||
ifeq ($(CONFIG_BUILD_KERNEL),y)
|
||||
crt0$(OBJEXT): crt0.c
|
||||
$(CC) $(CFLAGS) -c armv7-a$(DELIM)crt0.c -o crt0$(OBJEXT)
|
||||
|
||||
STARTUP_OBJS = crt0$(OBJEXT)
|
||||
endif
|
||||
|
||||
# Common assembly language files
|
||||
|
||||
CMN_ASRCS += arm_cpuhead.S arm_vectors.S arm_saveusercontext.S
|
||||
|
@ -20,6 +20,8 @@
|
||||
#
|
||||
############################################################################
|
||||
|
||||
STARTUP_OBJS = crt0$(OBJEXT)
|
||||
|
||||
# Common ARM files
|
||||
|
||||
CMN_CSRCS += arm_allocateheap.c arm_createstack.c arm_exit.c
|
||||
|
@ -551,7 +551,14 @@ else
|
||||
endif
|
||||
endif
|
||||
|
||||
LDELFFLAGS += -e main -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
ifneq ($(CONFIG_BUILD_KERNEL),y)
|
||||
# Flat build and protected elf entry point use crt0,
|
||||
# Kernel build will use apps/import/scripts/crt0
|
||||
|
||||
LDELFFLAGS += $(TOPDIR)$(DELIM)arch$(DELIM)arm$(DELIM)src$(DELIM)crt0.o
|
||||
endif
|
||||
|
||||
LDELFFLAGS += -e __start -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
||||
# Zig toolchain
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/armv7-a/crt0.c
|
||||
* arch/arm/src/common/crt0.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
@ -34,8 +34,6 @@
|
||||
|
||||
#include <arch/syscall.h>
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
@ -80,6 +78,7 @@ int main(int argc, char *argv[]);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
static void sig_trampoline(void) naked_function;
|
||||
static void sig_trampoline(void)
|
||||
{
|
||||
@ -99,6 +98,7 @@ static void sig_trampoline(void)
|
||||
"i"(SYS_syscall)
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_HAVE_CXXINITIALIZE
|
||||
|
||||
@ -135,6 +135,7 @@ static void exec_dtors(void)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -167,7 +168,9 @@ void __start(int argc, char *argv[])
|
||||
* that is visible to the RTOS.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
ARCH_DATA_RESERVE->ar_sigtramp = (addrenv_sigtramp_t)sig_trampoline;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_HAVE_CXXINITIALIZE
|
||||
/* Call C++ constructors */
|
||||
@ -193,5 +196,3 @@ void __start(int argc, char *argv[])
|
||||
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BUILD_KERNEL */
|
@ -142,11 +142,14 @@ $(AOBJS) $(UAOBJS) $(HEAD_OBJ): %$(OBJEXT): %.S
|
||||
$(COBJS) $(UCOBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
$(STARTUP_OBJS): %$(OBJEXT): %.c
|
||||
$(Q) $(CC) $(CELFFLAGS) -c common$(DELIM)crt0.c -o crt0$(OBJEXT)
|
||||
|
||||
ifeq ($(CONFIG_BUILD_FLAT),y)
|
||||
$(BIN): $(OBJS)
|
||||
$(BIN): $(OBJS) $(STARTUP_OBJS)
|
||||
$(call ARCHIVE, $@, $(OBJS))
|
||||
else
|
||||
$(BIN): $(UOBJS)
|
||||
$(BIN): $(UOBJS) $(STARTUP_OBJS)
|
||||
$(call ARCHIVE, $@, $(UOBJS))
|
||||
endif
|
||||
|
||||
|
@ -247,5 +247,11 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden -mlong-calls # --target1-abs
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden -mlong-calls # --target1-abs
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
ifneq ($(CONFIG_BUILD_KERNEL),y)
|
||||
# Flat build and protected elf entry point use crt0,
|
||||
# Kernel build will use apps/import/scripts/crt0
|
||||
|
||||
LDELFFLAGS += $(TOPDIR)$(DELIM)arch$(DELIM)arm64$(DELIM)src$(DELIM)crt0.o
|
||||
endif
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
@ -25,12 +25,7 @@
|
||||
|
||||
HEAD_ASRC = arm64_head.S
|
||||
|
||||
ifeq ($(CONFIG_BUILD_KERNEL),y)
|
||||
crt0$(OBJEXT): crt0.c
|
||||
$(CC) $(CFLAGS) -c common$(DELIM)crt0.c -o crt0$(OBJEXT)
|
||||
|
||||
STARTUP_OBJS = crt0$(OBJEXT)
|
||||
endif
|
||||
|
||||
# Force the start-up logic to be at the beginning of the .text to simplify
|
||||
# debug.
|
||||
|
@ -34,8 +34,6 @@
|
||||
|
||||
#include <arch/syscall.h>
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
@ -69,6 +67,7 @@ int main(int argc, char *argv[]);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
static void sig_trampoline(void) naked_function;
|
||||
static void sig_trampoline(void)
|
||||
{
|
||||
@ -91,6 +90,7 @@ static void sig_trampoline(void)
|
||||
:
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
@ -107,7 +107,7 @@ extern initializer_t _edtors[];
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_HAVE_CXX
|
||||
#ifdef CONFIG_HAVE_CXXINITIALIZE
|
||||
|
||||
/****************************************************************************
|
||||
* Name: exec_ctors
|
||||
@ -175,25 +175,31 @@ void __start(int argc, char *argv[])
|
||||
* that is visible to the RTOS.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
ARCH_DATA_RESERVE->ar_sigtramp = (addrenv_sigtramp_t)sig_trampoline;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_HAVE_CXX
|
||||
#ifdef CONFIG_HAVE_CXXINITIALIZE
|
||||
/* Call C++ constructors */
|
||||
|
||||
exec_ctors();
|
||||
|
||||
/* Setup so that C++ destructors called on task exit */
|
||||
|
||||
# if CONFIG_LIBC_MAX_EXITFUNS > 0
|
||||
atexit(exec_dtors);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Call the main() entry point passing argc and argv. */
|
||||
|
||||
ret = main(argc, argv);
|
||||
|
||||
#if defined(CONFIG_HAVE_CXXINITIALIZE) && CONFIG_LIBC_MAX_EXITFUNS <= 0
|
||||
exec_dtors();
|
||||
#endif
|
||||
|
||||
/* Call exit() if/when the main() returns */
|
||||
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BUILD_KERNEL */
|
||||
|
@ -180,5 +180,5 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
@ -110,5 +110,5 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
@ -99,5 +99,5 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
@ -104,5 +104,5 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
@ -325,5 +325,5 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
@ -141,5 +141,5 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
@ -89,5 +89,5 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
@ -127,5 +127,5 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
@ -20,9 +20,7 @@
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_BUILD_KERNEL),y)
|
||||
STARTUP_OBJS = crt0$(OBJEXT)
|
||||
endif
|
||||
|
||||
# Specify our general Assembly files
|
||||
CMN_ASRCS += riscv_vectors.S riscv_exception_common.S
|
||||
|
@ -433,7 +433,7 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -e main
|
||||
LDELFFLAGS = -e __start
|
||||
|
||||
ifeq ($(CONFIG_BINFMT_ELF_RELOCATABLE),y)
|
||||
LDELFFLAGS += -r
|
||||
|
@ -35,8 +35,6 @@
|
||||
|
||||
#include "riscv_internal.h"
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
@ -66,6 +64,7 @@ int main(int argc, char *argv[]);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
static void sig_trampoline(void) naked_function;
|
||||
static void sig_trampoline(void)
|
||||
{
|
||||
@ -88,6 +87,7 @@ static void sig_trampoline(void)
|
||||
:
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
@ -104,7 +104,7 @@ extern initializer_t _edtors[];
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_HAVE_CXX
|
||||
#ifdef CONFIG_HAVE_CXXINITIALIZE
|
||||
|
||||
/****************************************************************************
|
||||
* Name: exec_ctors
|
||||
@ -172,25 +172,31 @@ void __start(int argc, char *argv[])
|
||||
* that is visible to the RTOS.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
ARCH_DATA_RESERVE->ar_sigtramp = (addrenv_sigtramp_t)sig_trampoline;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_HAVE_CXX
|
||||
#ifdef CONFIG_HAVE_CXXINITIALIZE
|
||||
/* Call C++ constructors */
|
||||
|
||||
exec_ctors();
|
||||
|
||||
/* Setup so that C++ destructors called on task exit */
|
||||
|
||||
# if CONFIG_LIBC_MAX_EXITFUNS > 0
|
||||
atexit(exec_dtors);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Call the main() entry point passing argc and argv. */
|
||||
|
||||
ret = main(argc, argv);
|
||||
|
||||
#if defined(CONFIG_HAVE_CXXINITIALIZE) && CONFIG_LIBC_MAX_EXITFUNS <= 0
|
||||
exec_dtors();
|
||||
#endif
|
||||
|
||||
/* Call exit() if/when the main() returns */
|
||||
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BUILD_KERNEL */
|
||||
|
@ -136,5 +136,5 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
@ -138,5 +138,5 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
@ -90,5 +90,5 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
@ -115,11 +115,14 @@ $(AOBJS): %$(OBJEXT): %.S
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
$(STARTUP_OBJS): %$(OBJEXT): %.c
|
||||
$(Q) $(CC) $(CELFFLAGS) -c common$(DELIM)crt0.c -o crt0$(OBJEXT)
|
||||
|
||||
ifeq ($(CONFIG_BUILD_FLAT),y)
|
||||
$(BIN): $(OBJS)
|
||||
$(BIN): $(OBJS) $(STARTUP_OBJS)
|
||||
$(call ARCHIVE, $@, $(OBJS))
|
||||
else
|
||||
$(BIN): $(UOBJS)
|
||||
$(BIN): $(UOBJS) $(STARTUP_OBJS)
|
||||
$(call ARCHIVE, $@, $(UOBJS))
|
||||
endif
|
||||
|
||||
|
@ -20,12 +20,7 @@
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_BUILD_KERNEL),y)
|
||||
crt0$(OBJEXT): crt0.c
|
||||
$(CC) $(CFLAGS) -c common$(DELIM)crt0.c -o crt0$(OBJEXT)
|
||||
|
||||
STARTUP_OBJS = crt0$(OBJEXT)
|
||||
endif
|
||||
|
||||
# Common x86_64 files
|
||||
|
||||
|
@ -248,7 +248,14 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
ifneq ($(CONFIG_BUILD_KERNEL),y)
|
||||
# Flat build and protected elf entry point use crt0,
|
||||
# Kernel build will use apps/import/scripts/crt0
|
||||
|
||||
LDELFFLAGS += $(TOPDIR)$(DELIM)arch$(DELIM)x86_64$(DELIM)src$(DELIM)crt0.o
|
||||
endif
|
||||
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
||||
# -fno-pic to avoid GOT relocations
|
||||
|
@ -30,10 +30,20 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <nuttx/addrenv.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include <arch/syscall.h>
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* Linker defined symbols to .ctors and .dtors */
|
||||
|
||||
extern initializer_t _sctors[];
|
||||
extern initializer_t _ectors[];
|
||||
extern initializer_t _sdtors[];
|
||||
extern initializer_t _edtors[];
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
@ -58,6 +68,7 @@ int main(int argc, char *argv[]);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
static void sig_trampoline(void) naked_function;
|
||||
static void sig_trampoline(void)
|
||||
{
|
||||
@ -77,6 +88,43 @@ static void sig_trampoline(void)
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_HAVE_CXXINITIALIZE
|
||||
|
||||
/****************************************************************************
|
||||
* Name: exec_ctors
|
||||
*
|
||||
* Description:
|
||||
* Call static constructors
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void exec_ctors(void)
|
||||
{
|
||||
for (initializer_t *ctor = _sctors; ctor != _ectors; ctor++)
|
||||
{
|
||||
(*ctor)();
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: exec_dtors
|
||||
*
|
||||
* Description:
|
||||
* Call static destructors
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void exec_dtors(void)
|
||||
{
|
||||
for (initializer_t *dtor = _sdtors; dtor != _edtors; dtor++)
|
||||
{
|
||||
(*dtor)();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -109,15 +157,31 @@ void __start(int argc, char *argv[])
|
||||
* that is visible to the RTOS.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
ARCH_DATA_RESERVE->ar_sigtramp = (addrenv_sigtramp_t)sig_trampoline;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_HAVE_CXXINITIALIZE
|
||||
/* Call C++ constructors */
|
||||
|
||||
exec_ctors();
|
||||
|
||||
/* Setup so that C++ destructors called on task exit */
|
||||
|
||||
# if CONFIG_LIBC_MAX_EXITFUNS > 0
|
||||
atexit(exec_dtors);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Call the main() entry point passing argc and argv. */
|
||||
|
||||
ret = main(argc, argv);
|
||||
|
||||
#if defined(CONFIG_HAVE_CXXINITIALIZE) && CONFIG_LIBC_MAX_EXITFUNS <= 0
|
||||
exec_dtors();
|
||||
#endif
|
||||
|
||||
/* Call exit() if/when the main() returns */
|
||||
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BUILD_KERNEL */
|
||||
|
@ -217,5 +217,5 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden -mtext-section-literals
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden -mtext-section-literals
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
@ -221,5 +221,5 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden -mtext-section-literals
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden -mtext-section-literals
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
@ -222,5 +222,5 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
@ -120,5 +120,5 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
@ -145,5 +145,5 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
@ -120,5 +120,5 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
|
@ -66,7 +66,7 @@ endif
|
||||
config BINFMT_CONSTRUCTORS
|
||||
bool "C++ Static Constructor Support"
|
||||
default n
|
||||
depends on HAVE_CXX && SCHED_STARTHOOK && ELF
|
||||
depends on HAVE_CXX && ELF
|
||||
---help---
|
||||
Built-in support for C++ constructors in loaded modules. Currently
|
||||
only support for ELF binary formats.
|
||||
|
@ -52,55 +52,10 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* If C++ constructors are used, then CONFIG_SCHED_STARTHOOK must also be
|
||||
* selected be the start hook is used to schedule execution of the
|
||||
* constructors.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_BINFMT_CONSTRUCTORS) && !defined(CONFIG_SCHED_STARTHOOK)
|
||||
# error "CONFIG_SCHED_STARTHOOK must be defined to use constructors"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: exec_ctors
|
||||
*
|
||||
* Description:
|
||||
* Execute C++ static constructors. This function is registered as a
|
||||
* start hook and runs on the thread of the newly created task before
|
||||
* the new task's main function is called.
|
||||
*
|
||||
* Input Parameters:
|
||||
* arg - Argument is instance of load state info structure cast to void *.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||
static void exec_ctors(FAR void *arg)
|
||||
{
|
||||
FAR const struct binary_s *binp = (FAR const struct binary_s *)arg;
|
||||
binfmt_ctor_t *ctor = (CODE binfmt_ctor_t *)binp->mod.initarr;
|
||||
int i;
|
||||
|
||||
/* Execute each constructor */
|
||||
|
||||
for (i = 0; i < binp->mod.ninit; i++)
|
||||
{
|
||||
binfo("Calling ctor %d at %p\n", i, ctor);
|
||||
|
||||
(*ctor)();
|
||||
ctor++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: exec_swap
|
||||
*
|
||||
@ -356,18 +311,6 @@ int exec_module(FAR struct binary_s *binp,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BINFMT_CONSTRUCTORS
|
||||
/* Setup a start hook that will execute all of the C++ static constructors
|
||||
* on the newly created thread. The struct binary_s must persist at least
|
||||
* until the new task has been started.
|
||||
*/
|
||||
|
||||
if (binp->mod.ninit > 0)
|
||||
{
|
||||
nxtask_starthook(tcb, exec_ctors, binp);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SCHED_USER_IDENTITY
|
||||
if (binp->mode & S_ISUID)
|
||||
{
|
||||
|
@ -44,7 +44,6 @@ CONFIG_RAM_START=0x0d000000
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_RTC=y
|
||||
CONFIG_RTC_DRIVER=y
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_STACK_COLORATION=y
|
||||
|
@ -47,7 +47,6 @@ CONFIG_RAM_START=0x10000000
|
||||
CONFIG_RAM_VSTART=0x10000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_STACK_COLORATION=y
|
||||
CONFIG_START_DAY=17
|
||||
|
@ -103,7 +103,6 @@ CONFIG_RTC=y
|
||||
CONFIG_RTC_HIRES=y
|
||||
CONFIG_SCHED_CHILD_STATUS=y
|
||||
CONFIG_SCHED_HAVE_PARENT=y
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_SERIAL_TERMIOS=y
|
||||
CONFIG_SMP=y
|
||||
CONFIG_SMP_NCPUS=2
|
||||
|
@ -122,7 +122,6 @@ CONFIG_SCHED_CHILD_STATUS=y
|
||||
CONFIG_SCHED_HAVE_PARENT=y
|
||||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_LPWORKPRIORITY=60
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_SENSORS=y
|
||||
CONFIG_SERIAL_TERMIOS=y
|
||||
CONFIG_SMP=y
|
||||
|
@ -53,7 +53,6 @@ CONFIG_SCHED_CHILD_STATUS=y
|
||||
CONFIG_SCHED_HAVE_PARENT=y
|
||||
CONFIG_SCHED_INSTRUMENTATION=y
|
||||
CONFIG_SCHED_INSTRUMENTATION_SWITCH=y
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SERIAL_TERMIOS=y
|
||||
CONFIG_START_DAY=3
|
||||
|
@ -52,7 +52,6 @@ CONFIG_SCHED_CHILD_STATUS=y
|
||||
CONFIG_SCHED_HAVE_PARENT=y
|
||||
CONFIG_SCHED_INSTRUMENTATION=y
|
||||
CONFIG_SCHED_INSTRUMENTATION_SWITCH=y
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SENSORS=y
|
||||
CONFIG_SERIAL_TERMIOS=y
|
||||
|
@ -95,7 +95,6 @@ CONFIG_SCHED_CHILD_STATUS=y
|
||||
CONFIG_SCHED_HAVE_PARENT=y
|
||||
CONFIG_SCHED_INSTRUMENTATION=y
|
||||
CONFIG_SCHED_INSTRUMENTATION_SWITCH=y
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SERIAL_TERMIOS=y
|
||||
CONFIG_SPI=y
|
||||
|
@ -151,7 +151,6 @@ CONFIG_SCHED_INSTRUMENTATION_PREEMPTION=y
|
||||
CONFIG_SCHED_INSTRUMENTATION_SWITCH=y
|
||||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_LPWORKPRIORITY=60
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SENSORS=y
|
||||
CONFIG_SERIAL_TERMIOS=y
|
||||
|
@ -97,7 +97,6 @@ CONFIG_RTC=y
|
||||
CONFIG_RTC_DATETIME=y
|
||||
CONFIG_SCHED_CHILD_STATUS=y
|
||||
CONFIG_SCHED_HAVE_PARENT=y
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SERIAL_TERMIOS=y
|
||||
CONFIG_SMP=y
|
||||
|
@ -52,7 +52,6 @@ CONFIG_SCHED_CHILD_STATUS=y
|
||||
CONFIG_SCHED_HAVE_PARENT=y
|
||||
CONFIG_SCHED_INSTRUMENTATION=y
|
||||
CONFIG_SCHED_INSTRUMENTATION_SWITCH=y
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SERIAL_TERMIOS=y
|
||||
CONFIG_START_DAY=3
|
||||
|
@ -147,7 +147,6 @@ CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_HPWORKPRIORITY=192
|
||||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_LPWORKPRIORITY=60
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_SENSORS=y
|
||||
CONFIG_SERIAL_TERMIOS=y
|
||||
CONFIG_SMP=y
|
||||
|
@ -99,7 +99,6 @@ CONFIG_RTC=y
|
||||
CONFIG_RTC_DATETIME=y
|
||||
CONFIG_SCHED_CHILD_STATUS=y
|
||||
CONFIG_SCHED_HAVE_PARENT=y
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_SENSORS=y
|
||||
CONFIG_SERIAL_TERMIOS=y
|
||||
CONFIG_SMP=y
|
||||
|
@ -44,7 +44,6 @@ CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=4
|
||||
CONFIG_START_MONTH=8
|
||||
|
@ -35,7 +35,6 @@ CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_START_DAY=26
|
||||
CONFIG_START_MONTH=10
|
||||
CONFIG_START_YEAR=2012
|
||||
|
@ -37,7 +37,6 @@ CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_START_DAY=26
|
||||
CONFIG_START_MONTH=10
|
||||
CONFIG_START_YEAR=2012
|
||||
|
@ -46,7 +46,6 @@ CONFIG_SCHED_CHILD_STATUS=y
|
||||
CONFIG_SCHED_HAVE_PARENT=y
|
||||
CONFIG_SCHED_INSTRUMENTATION=y
|
||||
CONFIG_SCHED_INSTRUMENTATION_SWITCH=y
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_SMP=y
|
||||
CONFIG_SMP_NCPUS=2
|
||||
CONFIG_STACK_COLORATION=y
|
||||
|
@ -52,7 +52,6 @@ CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_STACK_COLORATION=y
|
||||
CONFIG_START_DAY=6
|
||||
|
@ -51,7 +51,6 @@ CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
|
@ -297,12 +297,6 @@ union entry_u
|
||||
|
||||
typedef union entry_u entry_t;
|
||||
|
||||
/* This is the type of the function called at task startup */
|
||||
|
||||
#ifdef CONFIG_SCHED_STARTHOOK
|
||||
typedef CODE void (*starthook_t)(FAR void *arg);
|
||||
#endif
|
||||
|
||||
/* struct sporadic_s ********************************************************/
|
||||
|
||||
#ifdef CONFIG_SCHED_SPORADIC
|
||||
@ -744,13 +738,6 @@ struct task_tcb_s
|
||||
/* Task Group *************************************************************/
|
||||
|
||||
struct task_group_s group; /* Shared task group data */
|
||||
|
||||
/* Task Management Fields *************************************************/
|
||||
|
||||
#ifdef CONFIG_SCHED_STARTHOOK
|
||||
starthook_t starthook; /* Task startup function */
|
||||
FAR void *starthookarg; /* The argument passed to the hook */
|
||||
#endif
|
||||
};
|
||||
|
||||
/* struct pthread_tcb_s *****************************************************/
|
||||
@ -1129,30 +1116,6 @@ int nxtask_delete(pid_t pid);
|
||||
|
||||
void nxtask_activate(FAR struct tcb_s *tcb);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtask_starthook
|
||||
*
|
||||
* Description:
|
||||
* Configure a start hook... a function that will be called on the thread
|
||||
* of the new task before the new task's main entry point is called.
|
||||
* The start hook is useful, for example, for setting up automatic
|
||||
* configuration of C++ constructors.
|
||||
*
|
||||
* Input Parameters:
|
||||
* tcb - The new, unstarted task task that needs the start hook
|
||||
* starthook - The pointer to the start hook function
|
||||
* arg - The argument to pass to the start hook function.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SCHED_STARTHOOK
|
||||
void nxtask_starthook(FAR struct task_tcb_s *tcb, starthook_t starthook,
|
||||
FAR void *arg);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtask_startup
|
||||
*
|
||||
|
@ -1564,16 +1564,6 @@ config BOARD_INITTHREAD_PRIORITY
|
||||
|
||||
endif # BOARD_LATE_INITIALIZE
|
||||
|
||||
config SCHED_STARTHOOK
|
||||
bool "Enable startup hook"
|
||||
default n
|
||||
---help---
|
||||
Enable a non-standard, internal OS API call nxtask_starthook().
|
||||
nxtask_starthook() registers a function that will be called on task
|
||||
startup before that actual task entry point is called. The
|
||||
starthook is useful, for example, for setting up automatic
|
||||
configuration of C++ constructors.
|
||||
|
||||
endmenu # RTOS hooks
|
||||
|
||||
menu "Signal Configuration"
|
||||
|
@ -60,8 +60,4 @@ if(NOT CONFIG_BINFMT_DISABLE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_SCHED_STARTHOOK)
|
||||
list(APPEND SRCS task_starthook.c)
|
||||
endif()
|
||||
|
||||
target_sources(sched PRIVATE ${SRCS})
|
||||
|
@ -44,10 +44,6 @@ CSRCS += task_execve.c task_posixspawn.c
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SCHED_STARTHOOK),y)
|
||||
CSRCS += task_starthook.c
|
||||
endif
|
||||
|
||||
# Include task build support
|
||||
|
||||
DEPPATH += --dep-path task
|
||||
|
@ -69,9 +69,6 @@ void nxtask_start(void)
|
||||
{
|
||||
FAR struct tcb_s *tcb = this_task();
|
||||
uint8_t ttype = tcb->flags & TCB_FLAG_TTYPE_MASK;
|
||||
#ifdef CONFIG_SCHED_STARTHOOK
|
||||
FAR struct task_tcb_s *ttcb = (FAR struct task_tcb_s *)tcb;
|
||||
#endif
|
||||
int exitcode = EXIT_FAILURE;
|
||||
FAR char **argv;
|
||||
int argc;
|
||||
@ -87,15 +84,6 @@ void nxtask_start(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Execute the start hook if one has been registered */
|
||||
|
||||
#ifdef CONFIG_SCHED_STARTHOOK
|
||||
if (ttype != TCB_FLAG_TTYPE_KERNEL && ttcb->starthook != NULL)
|
||||
{
|
||||
ttcb->starthook(ttcb->starthookarg);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Take args from stack, as group is shared for kthreads */
|
||||
|
||||
argv = nxsched_get_stackargs(tcb);
|
||||
|
@ -1,78 +0,0 @@
|
||||
/****************************************************************************
|
||||
* sched/task/task_starthook.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you 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 <nuttx/config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <nuttx/sched.h>
|
||||
|
||||
#include "task/task.h"
|
||||
|
||||
#ifdef CONFIG_SCHED_STARTHOOK
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtask_starthook
|
||||
*
|
||||
* Description:
|
||||
* Configure a start hook... a function that will be called on the thread
|
||||
* of the new task before the new task's main entry point is called.
|
||||
* The start hook is useful, for example, for setting up automatic
|
||||
* configuration of C++ constructors.
|
||||
*
|
||||
* Input Parameters:
|
||||
* tcb - The new, unstarted task task that needs the start hook
|
||||
* starthook - The pointer to the start hook function
|
||||
* arg - The argument to pass to the start hook function.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxtask_starthook(FAR struct task_tcb_s *tcb, starthook_t starthook,
|
||||
FAR void *arg)
|
||||
{
|
||||
/* Only tasks can have starthooks. The starthook will be called when the
|
||||
* task is started (or restarted).
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_DISABLE_PTHREAD
|
||||
DEBUGASSERT(tcb &&
|
||||
(tcb->cmn.flags & TCB_FLAG_TTYPE_MASK) !=
|
||||
TCB_FLAG_TTYPE_PTHREAD);
|
||||
#endif
|
||||
|
||||
/* Set up the start hook */
|
||||
|
||||
tcb->starthook = starthook;
|
||||
tcb->starthookarg = arg;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SCHED_STARTHOOK */
|
Loading…
x
Reference in New Issue
Block a user