Change in simtrace2[master]: firmware: fix builds with gcc stack smashing protection enabled

2020-08-06 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/19527 )

Change subject: firmware: fix builds with gcc stack smashing protection enabled
..

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
---
M firmware/Makefile
A firmware/libcommon/source/stack_check.c
2 files changed, 15 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, approved



diff --git a/firmware/Makefile b/firmware/Makefile
index bdca6e5..7be5c30 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -100,7 +100,7 @@
 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 000..3130dd8
--- /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");
+}

--
To view, visit https://gerrit.osmocom.org/c/simtrace2/+/19527
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: Ic2f68f16b0730e7b5db17c30effc29a2909d1997
Gerrit-Change-Number: 19527
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in simtrace2[master]: firmware: fix builds with gcc stack smashing protection enabled

2020-08-05 Thread fixeria
fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/simtrace2/+/19527 )

Change subject: firmware: fix builds with gcc stack smashing protection enabled
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/simtrace2/+/19527
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: Ic2f68f16b0730e7b5db17c30effc29a2909d1997
Gerrit-Change-Number: 19527
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Comment-Date: Wed, 05 Aug 2020 11:59:45 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in simtrace2[master]: firmware: fix builds with gcc stack smashing protection enabled

2020-08-05 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/simtrace2/+/19527 )


Change subject: firmware: fix builds with gcc stack smashing protection enabled
..

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
---
M firmware/Makefile
A firmware/libcommon/source/stack_check.c
2 files changed, 15 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/27/19527/1

diff --git a/firmware/Makefile b/firmware/Makefile
index bdca6e5..7be5c30 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -100,7 +100,7 @@
 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 000..3130dd8
--- /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");
+}

--
To view, visit https://gerrit.osmocom.org/c/simtrace2/+/19527
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: Ic2f68f16b0730e7b5db17c30effc29a2909d1997
Gerrit-Change-Number: 19527
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange