From 77d72fd4403648fd3bb68740fe38340898670149 Mon Sep 17 00:00:00 2001 From: Hubert Badocha Date: Wed, 25 Sep 2024 23:08:07 +0200 Subject: [PATCH 1/2] Makefile: compile as freestanding Without this flag GCC optimized the code to use undefined memset and memcpy. JIRA: RTOS-927 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index be0aa8f1c..639d32419 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ MAKEFLAGS += --no-print-directory include ../phoenix-rtos-build/Makefile.common -CFLAGS += -I. +CFLAGS += -I. -ffreestanding CPPFLAGS += -DVERSION=\"$(VERSION)\" # uncomment to enable stack canary checking From 7718a4348802e05d8fde86bad65e5f80c12a8c1c Mon Sep 17 00:00:00 2001 From: Hubert Badocha Date: Fri, 27 Sep 2024 14:38:19 +0200 Subject: [PATCH 2/2] hal: add cpuGetId sanity check to satify gcc bounds checker JIRA: RTOS-927 --- hal/tlb/tlb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hal/tlb/tlb.c b/hal/tlb/tlb.c index 92c1c9172..374fc0d0d 100644 --- a/hal/tlb/tlb.c +++ b/hal/tlb/tlb.c @@ -82,6 +82,11 @@ void hal_tlbInvalidateEntry(const pmap_t *pmap, const void *vaddr, size_t count) size_t tasks_size; spinlock_ctx_t sc; + if (id >= MAX_CPU_COUNT) { + /* Impossible make gcc array bound checker happy. */ + return; + } + hal_spinlockSet(&tlb_common.tlbs[id].task_spinlock, &sc); tasks_size = tlb_common.tlbs[id].tasks_size;