Skip to contentSkip to conversation

tclibc: For newlib and baremetal disable some security features

PATCH In review Nathan Rossi 2 participants 2 messages Sep 10, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tclibc: For newlib and baremetal disable some security features

With GCCPIE being enabled by default with security_flags.inc the compiler will by default attempt to compile and link programs as PIE. The targets that use newlib and baremetal in general do not support PIE or are otherwise unable to use it due to how embedded targets are compiled and executed. As such it makes sense to disable PIE by default for these libc's in order to prevent build failures.

For baremetal tclibc there are no libc features or implementation as such there is no implementation for the strong stack protector by default.

---
 meta/conf/distro/include/tclibc-baremetal.inc | 6 ++++++
 meta/conf/distro/include/tclibc-newlib.inc    | 4 ++++
 2 files changed, 10 insertions(+)
meta/conf/distro/include/tclibc-baremetal.inc +6 -0
index 1bf44c8591..b00917913f 100644
@@ -28,3 +28,9 @@ TOOLCHAIN_HOST_TASK ?= "packagegroup-cross-canadian-${MACHINE}"
 TOOLCHAIN_HOST_TASK_ATTEMPTONLY ?= ""
 TOOLCHAIN_TARGET_TASK ?= "libgcc-dev"
 TOOLCHAIN_NEED_CONFIGSITE_CACHE_remove = "virtual/${MLPREFIX}libc zlib ncurses"
+
+# disable stack protector by default (no-libc, no protector implementation)
+SECURITY_STACK_PROTECTOR_libc-baremetal = ""
+# disable pie security flags by default
+SECURITY_CFLAGS_libc-baremetal = "${SECURITY_NOPIE_CFLAGS}"
+SECURITY_LDFLAGS_libc-baremetal = ""
meta/conf/distro/include/tclibc-newlib.inc +4 -0
index dc631d8ada..896c0b16d7 100644
@@ -42,3 +42,7 @@ TARGET_OS_arm = "eabi"
 TOOLCHAIN_HOST_TASK ?= "packagegroup-cross-canadian-${MACHINE}"
 TOOLCHAIN_TARGET_TASK ?= "${LIBC_DEPENDENCIES}"
 TOOLCHAIN_NEED_CONFIGSITE_CACHE_remove = "zlib ncurses"
+
+# disable pie security flags by default
+SECURITY_CFLAGS_libc-newlib = "${SECURITY_NOPIE_CFLAGS}"
+SECURITY_LDFLAGS_libc-newlib = ""

---
2.18.0

#1 lore raw
Quoted 8 lines · Nathan Rossi

With GCCPIE being enabled by default with security_flags.inc the compiler will by default attempt to compile and link programs as PIE. The targets that use newlib and baremetal in general do not support PIE or are otherwise unable to use it due to how embedded targets are compiled and executed. As such it makes sense to disable PIE by default for these libc's in order to prevent build failures.

Quoted 4 lines

For baremetal tclibc there are no libc features or implementation as such there is no implementation for the strong stack protector by default.

LGTM.

Quoted 39 lines
---
 meta/conf/distro/include/tclibc-baremetal.inc | 6 ++++++
 meta/conf/distro/include/tclibc-newlib.inc    | 4 ++++
 2 files changed, 10 insertions(+)
meta/conf/distro/include/tclibc-baremetal.inc +6 -0
index 1bf44c8591..b00917913f 100644
@@ -28,3 +28,9 @@ TOOLCHAIN_HOST_TASK ?= "packagegroup-cross-canadian-${MACHINE}"
 TOOLCHAIN_HOST_TASK_ATTEMPTONLY ?= ""
 TOOLCHAIN_TARGET_TASK ?= "libgcc-dev"
 TOOLCHAIN_NEED_CONFIGSITE_CACHE_remove = "virtual/${MLPREFIX}libc zlib ncurses"
+
+# disable stack protector by default (no-libc, no protector implementation)
+SECURITY_STACK_PROTECTOR_libc-baremetal = ""
+# disable pie security flags by default
+SECURITY_CFLAGS_libc-baremetal = "${SECURITY_NOPIE_CFLAGS}"
+SECURITY_LDFLAGS_libc-baremetal = ""
meta/conf/distro/include/tclibc-newlib.inc +4 -1
index dc631d8ada..896c0b16d7 100644
@@ -42,3 +42,7 @@ TARGET_OS_arm = "eabi"
 TOOLCHAIN_HOST_TASK ?= "packagegroup-cross-canadian-${MACHINE}"
 TOOLCHAIN_TARGET_TASK ?= "${LIBC_DEPENDENCIES}"
 TOOLCHAIN_NEED_CONFIGSITE_CACHE_remove = "zlib ncurses"
+
+# disable pie security flags by default
+SECURITY_CFLAGS_libc-newlib = "${SECURITY_NOPIE_CFLAGS}"
+SECURITY_LDFLAGS_libc-newlib = ""
---

2.18.0
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core