summaryrefslogtreecommitdiffstats
path: root/arch/sandbox
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sandbox')
-rw-r--r--arch/sandbox/Kconfig8
-rw-r--r--arch/sandbox/Makefile14
-rw-r--r--arch/sandbox/include/asm/barebox.h1
-rw-r--r--arch/sandbox/lib/Makefile1
-rw-r--r--arch/sandbox/lib/unwind.c11
5 files changed, 32 insertions, 3 deletions
diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index d153846efa..6ec71a99e5 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -2,6 +2,8 @@ config SANDBOX
bool
select OFTREE
select GPIOLIB
+ select ARCH_HAS_UBSAN_SANITIZE_ALL
+ select HAVE_ARCH_KASAN
default y
config ARCH_TEXT_BASE
@@ -12,3 +14,9 @@ config LINUX
bool
default y
select GENERIC_FIND_NEXT_BIT
+
+config SANDBOX_UNWIND
+ bool
+ default y
+ select ARCH_HAS_STACK_DUMP
+ depends on UBSAN || KASAN
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index 780783a1e0..b127560a2b 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -47,11 +47,21 @@ ifeq ($(CONFIG_GPIO_LIBFTDI1),y)
FTDI1_LIBS := $(shell pkg-config libftdi1 --libs)
endif
+ifeq ($(CONFIG_KASAN),y)
+CPPFLAGS += -fsanitize=address
+SANITIZER_LIBS += -fsanitize=address
+endif
+
+ifeq ($(CONFIG_UBSAN),y)
+SANITIZER_LIBS += -fsanitize=undefined
+endif
+
cmd_barebox__ = $(CC) -o $@ -Wl,-T,$(barebox-lds) \
-Wl,--start-group $(barebox-common) -Wl,--end-group \
- -lrt -lpthread $(SDL_LIBS) $(FTDI1_LIBS)
+ -lrt -lpthread $(SDL_LIBS) $(FTDI1_LIBS) \
+ $(SANITIZER_LIBS)
-common-y += $(BOARD) arch/sandbox/os/
+common-y += $(BOARD) arch/sandbox/os/ arch/sandbox/lib/
common-$(CONFIG_OFTREE) += arch/sandbox/dts/
diff --git a/arch/sandbox/include/asm/barebox.h b/arch/sandbox/include/asm/barebox.h
deleted file mode 100644
index 2997587d82..0000000000
--- a/arch/sandbox/include/asm/barebox.h
+++ /dev/null
@@ -1 +0,0 @@
-/* dummy */
diff --git a/arch/sandbox/lib/Makefile b/arch/sandbox/lib/Makefile
new file mode 100644
index 0000000000..b32ca6aaf8
--- /dev/null
+++ b/arch/sandbox/lib/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_ARCH_HAS_STACK_DUMP) += unwind.o
diff --git a/arch/sandbox/lib/unwind.c b/arch/sandbox/lib/unwind.c
new file mode 100644
index 0000000000..15a2798cc4
--- /dev/null
+++ b/arch/sandbox/lib/unwind.c
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// Copyright 2019 Ahmad Fatoum
+
+#include <common.h>
+
+void __sanitizer_print_stack_trace(void);
+
+void dump_stack(void)
+{
+ __sanitizer_print_stack_trace();
+}