From 0803b62fc617a140da094a97b1c8dc2b99a3a34f Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 7 Nov 2019 21:01:40 +0100 Subject: [PATCH] uboot-envtools: Add TARGET_LDFLAGS to fix PIE and RELRO Forward the OpenWrt TARGET_LDFLAGS to the linker of the fw_printenv tool. In addition also use the more standard make invocation script. With this change the fw_printenv tool is built with PIE and Full RELRO support when activated globally in OpenWrt. Signed-off-by: Hauke Mehrtens (cherry picked from commit b7b2be0b268ced260ca8df84be1b0d469aaf6e38) --- package/boot/uboot-envtools/Makefile | 15 +++++---------- .../boot/uboot-envtools/patches/001-compile.patch | 5 ++++- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/package/boot/uboot-envtools/Makefile b/package/boot/uboot-envtools/Makefile index 71b842b96e..15579e966b 100644 --- a/package/boot/uboot-envtools/Makefile +++ b/package/boot/uboot-envtools/Makefile @@ -51,16 +51,11 @@ define Build/Configure touch $(PKG_BUILD_DIR)/include/generated/autoconf.h endef -TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include - -define Build/Compile - $(MAKE) -C $(PKG_BUILD_DIR) \ - CROSS_COMPILE="$(TARGET_CROSS)" \ - TARGET_CFLAGS="$(TARGET_CFLAGS)" \ - HOSTLDFLAGS= \ - no-dot-config-targets=envtools \ - envtools -endef +MAKE_FLAGS += \ + TARGET_CFLAGS="$(TARGET_CFLAGS)" \ + TARGET_LDFLAGS="$(TARGET_LDFLAGS)" \ + no-dot-config-targets=envtools \ + envtools define Package/uboot-envtools/conffiles /etc/config/ubootenv diff --git a/package/boot/uboot-envtools/patches/001-compile.patch b/package/boot/uboot-envtools/patches/001-compile.patch index f7ec9130d6..098772f557 100644 --- a/package/boot/uboot-envtools/patches/001-compile.patch +++ b/package/boot/uboot-envtools/patches/001-compile.patch @@ -1,12 +1,15 @@ --- a/tools/env/Makefile +++ b/tools/env/Makefile -@@ -10,6 +10,10 @@ +@@ -10,6 +10,13 @@ # with "CC" here for the maximum code reuse of scripts/Makefile.host. override HOSTCC = $(CC) +ifneq ($(TARGET_CFLAGS),) +HOSTCFLAGS = $(TARGET_CFLAGS) +endif ++ifneq ($(TARGET_LDFLAGS),) ++HOSTLDFLAGS = $(TARGET_LDFLAGS) ++endif + # Compile for a hosted environment on the target HOST_EXTRACFLAGS = $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \ -- 2.30.2