From 2f9bfcc6ee436ee3568d0c8158a8e43c9ef02623 Mon Sep 17 00:00:00 2001 From: zhushengle Date: Thu, 29 Apr 2021 10:38:54 +0800 Subject: [PATCH] fix: L0 GN compilation problem Close: #I3ORHS Change-Id: Ia105084336f2ba66f91546226a9383646a0148ce --- components/fs/fatfs/fatfs.c | 5 ++--- kal/posix/include/wchar.h | 1 + kernel/arch/arm/cortex-m4/gcc/los_interrupt.c | 10 ++++++++++ kernel/arch/include/los_interrupt.h | 5 +++++ utils/BUILD.gn | 1 + 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/components/fs/fatfs/fatfs.c b/components/fs/fatfs/fatfs.c index 2bf57118..58b683ca 100644 --- a/components/fs/fatfs/fatfs.c +++ b/components/fs/fatfs/fatfs.c @@ -29,12 +29,11 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#define _GNU_SOURCE 1 #include "ff.h" -#if FF_USE_EXPAND -#define _GNU_SOURCE -#endif #include "fatfs.h" #include "errno.h" +#include "stdbool.h" #include "limits.h" #include "pthread.h" #include "time.h" diff --git a/kal/posix/include/wchar.h b/kal/posix/include/wchar.h index 6369f116..903746d6 100644 --- a/kal/posix/include/wchar.h +++ b/kal/posix/include/wchar.h @@ -19,6 +19,7 @@ extern "C" { #define __NEED_mbstate_t #if __STDC_VERSION__ < 201112L +#define __NEED_off_t #define __NEED_struct__IO_FILE #endif diff --git a/kernel/arch/arm/cortex-m4/gcc/los_interrupt.c b/kernel/arch/arm/cortex-m4/gcc/los_interrupt.c index 05af9a2d..74e4a5da 100644 --- a/kernel/arch/arm/cortex-m4/gcc/los_interrupt.c +++ b/kernel/arch/arm/cortex-m4/gcc/los_interrupt.c @@ -490,6 +490,16 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U HalSysExit(); } +/* stack protector */ +WEAK UINT32 __stack_chk_guard = 0xd00a0dff; + +WEAK VOID __stack_chk_fail(VOID) +{ + /* __builtin_return_address is a builtin function, building in gcc */ + LOS_Panic("stack-protector: Kernel stack is corrupted in: %p\n", + __builtin_return_address(0)); +} + /* **************************************************************************** Function : HalHwiInit Description : initialization of the hardware interrupt diff --git a/kernel/arch/include/los_interrupt.h b/kernel/arch/include/los_interrupt.h index a0d7f90d..3fa2fe33 100644 --- a/kernel/arch/include/los_interrupt.h +++ b/kernel/arch/include/los_interrupt.h @@ -62,6 +62,11 @@ typedef VOID (*HWI_PROC_FUNC)(VOID *parm); typedef VOID (*HWI_PROC_FUNC)(void); #endif +/* stack protector */ +extern UINT32 __stack_chk_guard; + +extern VOID __stack_chk_fail(VOID); + UINT32 HalIsIntActive(VOID); #define OS_INT_ACTIVE (HalIsIntActive()) #define OS_INT_INACTIVE (!(OS_INT_ACTIVE)) diff --git a/utils/BUILD.gn b/utils/BUILD.gn index b4dcfa48..202eab8a 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -31,6 +31,7 @@ static_library("utils") { sources = [ "los_debug.c", "los_error.c", + "los_hook.c", ] include_dirs = [