aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/libcommon
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2020-08-05 11:59:26 +0200
committerHarald Welte <laforge@osmocom.org>2020-08-05 11:59:26 +0200
commit1afb70a69d01c320ff9d268cd37dada451126f0f (patch)
treead25dee91af7bef48bc083918f61dc8ff799307b /firmware/libcommon
parent859f1b0974daee3dd5e4a650f7077148d9d61cf5 (diff)
firmware: fix builds with gcc stack smashing protection enabled
On Ubuntu 20.04 when builiding dpkg packages, even when cross-compiling firmware, gcc stack smashing protection is enabled. Let's provide what is minimally required in order to sucessfully complete builds on such platforms. Change-Id: Ic2f68f16b0730e7b5db17c30effc29a2909d1997 Closes: OS#4687
Diffstat (limited to 'firmware/libcommon')
-rw-r--r--firmware/libcommon/source/stack_check.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/firmware/libcommon/source/stack_check.c b/firmware/libcommon/source/stack_check.c
new file mode 100644
index 0000000..3130dd8
--- /dev/null
+++ b/firmware/libcommon/source/stack_check.c
@@ -0,0 +1,14 @@
+#include <stdint.h>
+#include <osmocom/core/panic.h>
+
+/* 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");
+}