diff --git a/firmware/Makefile b/firmware/Makefile index bdca6e51..7be5c301 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -100,7 +100,7 @@ C_LIBUSB = USBDescriptors.c USBRequests.c USBD.c USBDCallbacks.c USBDDriver. C_LIBUSB_RT = dfu.c dfu_runtime.c C_LIBUSB_DFU = dfu.c dfu_desc.c dfu_driver.c C_LIBCOMMON = string.c stdio.c fputs.c usb_buf.c ringbuffer.c pseudo_talloc.c host_communication.c \ - main_common.c + main_common.c stack_check.c C_BOARD = $(notdir $(wildcard libboard/common/source/*.c)) C_BOARD += $(notdir $(wildcard libboard/$(BOARD)/source/*.c)) diff --git a/firmware/libcommon/source/stack_check.c b/firmware/libcommon/source/stack_check.c new file mode 100644 index 00000000..3130dd8e --- /dev/null +++ b/firmware/libcommon/source/stack_check.c @@ -0,0 +1,14 @@ +#include +#include + +/* This is what's minimally required to fix builds on Ubuntu 20.04, + * where stack smashing protection is enabled by default when using dpkg + * - even when cross-compiling: https://osmocom.org/issues/4687 + */ + +uintptr_t __stack_chk_guard = 0xdeadbeef; + +void __stack_chk_fail(void) +{ + osmo_panic("Stack smashing detected!\r\n"); +}