summaryrefslogtreecommitdiffstats
path: root/arch/sandbox/Makefile
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-03-10 09:47:48 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-03-17 11:55:30 +0100
commite74e330216baff384b844fde06720b022614168b (patch)
treebbd2baba1378e43b36d37b65dac48f5d1f4be3a6 /arch/sandbox/Makefile
parent01064a3c91492e09c13c2d158f1d2fa63cb90468 (diff)
downloadbarebox-e74e330216baff384b844fde06720b022614168b.tar.gz
barebox-e74e330216baff384b844fde06720b022614168b.tar.xz
sandbox: asm: implement setjmp/longjmp/initjmp
To extend incoming bthread support to sandbox, implement setjmp, longjmp and initjmp. Unlike bare metal platforms, setjmp() and longjmp() are readily provided on standard-conforming hosted platforms. initjmp() on the other hand requires us to be able to invoke a function with a user-supplied stack pointer, which isn't possible in standard C. For POSIX systems, there are two methods to portably achieve this though: - Use makecontext(2) to set up a new context. makecontext(2) was however removed in POSIX.1-2008 and at least GCC 10.2.1 ASan complains that it "doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!" - Use sigaltstack to set a new signal stack, raise the signal call, setjmp in the signal handler to store the new stack pointer, return regularly from signal handler and then longjmp back Both methods are implemented in QEMU. While QEMU uses the makecontext method by default, for the reasons described, import the second implementation and use it implement initjmp. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/sandbox/Makefile')
-rw-r--r--arch/sandbox/Makefile5
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index ea594944e4..5fc7e227be 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -27,7 +27,8 @@ KBUILD_CFLAGS += -Dmalloc=barebox_malloc -Dcalloc=barebox_calloc \
-Dftruncate=barebox_ftruncate -Dasprintf=barebox_asprintf \
-Dopendir=barebox_opendir -Dreaddir=barebox_readdir \
-Dclosedir=barebox_closedir -Dreadlink=barebox_readlink \
- -Doptarg=barebox_optarg -Doptind=barebox_optind
+ -Doptarg=barebox_optarg -Doptind=barebox_optind \
+ -Dsetjmp=barebox_setjmp -Dlongjmp=barebox_longjmp
machdirs := $(patsubst %,arch/sandbox/mach-%/,$(machine-y))
@@ -64,7 +65,7 @@ endif
BAREBOX_LDFLAGS += \
-Wl,-T,$(BAREBOX_LDS) \
-Wl,--whole-archive $(BAREBOX_OBJS) -Wl,--no-whole-archive \
- -lrt $(SDL_LIBS) $(FTDI1_LIBS) \
+ -lrt -pthread $(SDL_LIBS) $(FTDI1_LIBS) \
$(SANITIZER_LIBS)
cmd_barebox__ = $(CC) -o $@ $(BAREBOX_LDFLAGS)