summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Schwebel <r.schwebel@pengutronix.de>2022-11-26 08:27:11 +0100
committerRobert Schwebel <r.schwebel@pengutronix.de>2022-11-28 16:29:20 +0100
commitce323dcb63c735758cd073c4ccea503fb5dcdf4b (patch)
tree5392377f9c8555a1513c0790a8fe013f8603f191
parent2235e8c9d659ec390b872cc000f8dff49be71349 (diff)
downloadDistroKit-ce323dcb63c735758cd073c4ccea503fb5dcdf4b.tar.gz
DistroKit-ce323dcb63c735758cd073c4ccea503fb5dcdf4b.tar.xz
platform-v8a: make imx-atf compile again with gcc 12
gcc 12 brings some new warings which are not fixed in the old imx-atf, but also not in upstream tf-a. Add patches to make it compile again. Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
-rw-r--r--patches/imx-atf-imx_5.4.24_2.1.0/0001-build-makefile-add-helper-to-detect-linker-options.patch38
-rw-r--r--patches/imx-atf-imx_5.4.24_2.1.0/0002-build-makefile-avoid-gcc-warning-that-triggers-with-.patch48
-rw-r--r--patches/imx-atf-imx_5.4.24_2.1.0/0003-feat-build-add-support-for-new-binutils-versions.patch38
-rw-r--r--patches/imx-atf-imx_5.4.24_2.1.0/0004-makefile-link-with-z-noexecstack.patch38
-rw-r--r--patches/imx-atf-imx_5.4.24_2.1.0/series4
5 files changed, 166 insertions, 0 deletions
diff --git a/patches/imx-atf-imx_5.4.24_2.1.0/0001-build-makefile-add-helper-to-detect-linker-options.patch b/patches/imx-atf-imx_5.4.24_2.1.0/0001-build-makefile-add-helper-to-detect-linker-options.patch
new file mode 100644
index 0000000..164f199
--- /dev/null
+++ b/patches/imx-atf-imx_5.4.24_2.1.0/0001-build-makefile-add-helper-to-detect-linker-options.patch
@@ -0,0 +1,38 @@
+From 456257d346b295982761d33f4e24e07a9feee74d Mon Sep 17 00:00:00 2001
+From: Marco Felsch <mfe@pengutronix.de>
+Date: Sat, 26 Nov 2022 08:00:39 +0100
+Subject: [PATCH 1/2] build(makefile): add helper to detect linker options
+
+This is a small helper to check for possible linker options. If the
+linker supports the requested option it is returned and if not nothing
+will be returned, e.g.:
+
+ TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
+
+can be called unconditional.
+
+Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
+---
+ make_helpers/build_macros.mk | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/make_helpers/build_macros.mk b/make_helpers/build_macros.mk
+index b89d87ea6087..9f4f70dbe42f 100644
+--- a/make_helpers/build_macros.mk
++++ b/make_helpers/build_macros.mk
+@@ -67,6 +67,12 @@ $(foreach d,$(0-9),$(eval __numeric := $(subst $(d),,$(__numeric))))
+ $(if $(__numeric),$(error $(1) must be numeric))
+ endef
+
++# Convenience function to check for a given linker option. An call to
++# $(call ld_option, --no-XYZ) will return --no-XYZ if supported by the linker
++define ld_option
++ $(shell if $(LD) $(1) -v >/dev/null 2>&1; then echo $(1); fi )
++endef
++
+ # IMG_LINKERFILE defines the linker script corresponding to a BL stage
+ # $(1) = BL stage (2, 30, 31, 32, 33)
+ define IMG_LINKERFILE
+--
+2.30.2
+
diff --git a/patches/imx-atf-imx_5.4.24_2.1.0/0002-build-makefile-avoid-gcc-warning-that-triggers-with-.patch b/patches/imx-atf-imx_5.4.24_2.1.0/0002-build-makefile-avoid-gcc-warning-that-triggers-with-.patch
new file mode 100644
index 0000000..a433800
--- /dev/null
+++ b/patches/imx-atf-imx_5.4.24_2.1.0/0002-build-makefile-avoid-gcc-warning-that-triggers-with-.patch
@@ -0,0 +1,48 @@
+From 710c027045df0d51e3d83bd26ec954b08108d836 Mon Sep 17 00:00:00 2001
+From: Robert Schwebel <r.schwebel@pengutronix.de>
+Date: Sat, 26 Nov 2022 08:06:40 +0100
+Subject: [PATCH 2/2] build(makefile): avoid gcc warning that triggers with
+ -Werror=array-bounds
+
+With gcc 12, we get these warnings:
+
+make: Entering directory 'imx-atf-imx_5.4.24_2.1.0'
+ CC plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c
+In file included from plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c:20:
+In function 'mmio_read_8',
+ inlined from 'imx8mq_soc_info_init' at plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c:82:16,
+ inlined from 'bl31_platform_setup' at plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c:224:2:
+include/lib/mmio.h:19:16: error: array subscript 0 is outside array bounds of 'volatile uint8_t[0]' {aka 'volatile unsigned char[]'} [-Werror=array-bounds]
+ 19 | return *(volatile uint8_t*)addr;
+ | ^~~~~~~~~~~~~~~~~~~~~~~~
+In function 'mmio_read_8',
+ inlined from 'imx8mq_soc_info_init' at plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c:86:16,
+ inlined from 'bl31_platform_setup' at plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c:224:2:
+include/lib/mmio.h:19:16: error: array subscript 0 is outside array bounds of 'volatile uint8_t[0]' {aka 'volatile unsigned char[]'} [-Werror=array-bounds]
+ 19 | return *(volatile uint8_t*)addr;
+ | ^~~~~~~~~~~~~~~~~~~~~~~~
+cc1: all warnings being treated as errors
+
+According to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523#c9, this
+is the right fix for TF-A, as it is a firmware that has memory at 0.
+
+Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
+---
+ Makefile | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/Makefile b/Makefile
+index 2ae12fda741a..555b46e7b361 100644
+--- a/Makefile
++++ b/Makefile
+@@ -284,6 +284,7 @@ CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
+ ASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \
+ -ffreestanding -Wa,--fatal-warnings
+ TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
++ --param=min-pagesize=0 \
+ -ffreestanding -fno-builtin -Wall -std=gnu99 \
+ -Os -ffunction-sections -fdata-sections
+
+--
+2.30.2
+
diff --git a/patches/imx-atf-imx_5.4.24_2.1.0/0003-feat-build-add-support-for-new-binutils-versions.patch b/patches/imx-atf-imx_5.4.24_2.1.0/0003-feat-build-add-support-for-new-binutils-versions.patch
new file mode 100644
index 0000000..35b2be9
--- /dev/null
+++ b/patches/imx-atf-imx_5.4.24_2.1.0/0003-feat-build-add-support-for-new-binutils-versions.patch
@@ -0,0 +1,38 @@
+From b102865225c8db6a4ef60f346aded5959acc4d1c Mon Sep 17 00:00:00 2001
+From: Marco Felsch <m.felsch@pengutronix.de>
+Date: Wed, 9 Nov 2022 12:59:09 +0100
+Subject: [PATCH 3/4] feat(build): add support for new binutils versions
+
+The new ld.bfd linker version has added new warnings which are enabled by
+default to secure elf binaries:
+ - https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ba951afb99912da01a6e8434126b8fac7aa75107
+ - https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=0d38576a34ec64a1b4500c9277a8e9d0f07e6774
+
+Since the tf-a handles every warning as error we need to tell the linker
+to not warn about this. This is required to make the bl31 target
+buildable with newer toolchain versions.
+
+Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
+Change-Id: I9430f5fa5036ca88da46cd3b945754d62616b617
+---
+ Makefile | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/Makefile b/Makefile
+index 3941f869800a..af7fd1535694 100644
+--- a/Makefile
++++ b/Makefile
+@@ -444,6 +444,10 @@ TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
+ endif
+ endif
+
++# With ld.bfd version 2.29 and newer new warnings are added. Skip those since we
++# are not loaded by a elf loader.
++TF_LDFLAGS += $(call ld_option, --no-warn-rwx-segments)
++
+ DTC_FLAGS += -I dts -O dtb
+ DTC_CPPFLAGS += -P -nostdinc -Iinclude -Ifdts -undef \
+ -x assembler-with-cpp $(DEFINES)
+--
+2.30.2
+
diff --git a/patches/imx-atf-imx_5.4.24_2.1.0/0004-makefile-link-with-z-noexecstack.patch b/patches/imx-atf-imx_5.4.24_2.1.0/0004-makefile-link-with-z-noexecstack.patch
new file mode 100644
index 0000000..727f8af
--- /dev/null
+++ b/patches/imx-atf-imx_5.4.24_2.1.0/0004-makefile-link-with-z-noexecstack.patch
@@ -0,0 +1,38 @@
+From f77451f77ff01dda1a5239a65901ed0b666116b3 Mon Sep 17 00:00:00 2001
+From: Robert Schwebel <r.schwebel@pengutronix.de>
+Date: Sat, 26 Nov 2022 08:24:50 +0100
+Subject: [PATCH 4/4] makefile: link with -z noexecstack
+
+Starting with binutils 2.39+, there is a new warning:
+
+ ld: warning: vmlinux: missing .note.GNU-stack section implies executable stack
+ ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
+ ld: warning: vmlinux has a LOAD segment with RWX permissions
+
+Fix it in a similar way to what the Linux kernel does, see:
+https://lore.kernel.org/all/20220810222442.2296651-1-ndesaulniers@google.com/
+
+Following the reasoning there, we set "-z noexecstack" for all linkers
+(although LLVM's LLD defaults to it).
+
+Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
+---
+ Makefile | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/Makefile b/Makefile
+index 54072a4543ce..86be2e68da3e 100644
+--- a/Makefile
++++ b/Makefile
+@@ -298,6 +298,8 @@ endif
+
+ GCC_V_OUTPUT := $(shell $(CC) -v 2>&1)
+
++TF_LDFLAGS += -z noexecstack
++
+ ifneq ($(findstring armlink,$(notdir $(LD))),)
+ TF_LDFLAGS += --diag_error=warning --lto_level=O1
+ TF_LDFLAGS += --remove --info=unused,unusedsymbols
+--
+2.30.2
+
diff --git a/patches/imx-atf-imx_5.4.24_2.1.0/series b/patches/imx-atf-imx_5.4.24_2.1.0/series
new file mode 100644
index 0000000..c731f9c
--- /dev/null
+++ b/patches/imx-atf-imx_5.4.24_2.1.0/series
@@ -0,0 +1,4 @@
+0001-build-makefile-add-helper-to-detect-linker-options.patch
+0002-build-makefile-avoid-gcc-warning-that-triggers-with-.patch
+0003-feat-build-add-support-for-new-binutils-versions.patch
+0004-makefile-link-with-z-noexecstack.patch