[v4,1/2] boot/arm-trusted-firmware: v2.11: fix building ST elf file

Message ID 20241031093311.636608-1-dario.binacchi@amarulasolutions.com
State New
Headers show
Series
  • [v4,1/2] boot/arm-trusted-firmware: v2.11: fix building ST elf file
Related show

Commit Message

Dario Binacchi Oct. 31, 2024, 9:33 a.m. UTC
The commit backports a pending, but likely correct, patch that fixes the
following build error:

'buildroot/output/host/bin/arm-buildroot-linux-gnueabihf-gcc' -o buildroot/output/build/arm-trusted-firmware-custom/build/stm32mp1/release/tf-a-stm32mp157c-dk2.elf -Wl,--hash-style=gnu -Wl,--as-needed -nostartfiles -Wl,-Map=buildroot/output/build/arm-trusted-firmware-custom/build/stm32mp1/release/tf-a-stm32mp157c-dk2.map -Wl,-dT buildroot/output/build/arm-trusted-firmware-custom/build/stm32mp1/release/stm32mp1.ld buildroot/output/build/arm-trusted-firmware-custom/build/stm32mp1/release/stm32mp1-stm32mp157c-dk2.o
buildroot/output/host/lib/gcc/arm-buildroot-linux-gnueabihf/13.3.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: buildroot/output/build/arm-trusted-firmware-custom/build/stm32mp1/release/tf-a-stm32mp157c-dk2.elf: error: PHDR segment not covered by LOAD segment
collect2: error: ld returned 1 exit status

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---

Changes v3 -> v4:
- Replace the fixing patch. The previous patch did not pass the
  tests because it caused regressions on platforms other than ST.
  The review process led to a new patch specifically for the ST
  platform.

No changes since v2

Added in v2

 ...pie-option-when-building-ST-elf-file.patch | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 boot/arm-trusted-firmware/v2.11/0001-fix-st-set-no-pie-option-when-building-ST-elf-file.patch

Patch

diff --git a/boot/arm-trusted-firmware/v2.11/0001-fix-st-set-no-pie-option-when-building-ST-elf-file.patch b/boot/arm-trusted-firmware/v2.11/0001-fix-st-set-no-pie-option-when-building-ST-elf-file.patch
new file mode 100644
index 000000000000..d2b82e0921f4
--- /dev/null
+++ b/boot/arm-trusted-firmware/v2.11/0001-fix-st-set-no-pie-option-when-building-ST-elf-file.patch
@@ -0,0 +1,37 @@ 
+From fbd050b61652db732f7a7a1ca36450b1bb339298 Mon Sep 17 00:00:00 2001
+From: Yann Gautier <yann.gautier@st.com>
+Date: Tue, 29 Oct 2024 13:42:07 +0100
+Subject: [PATCH] fix(st): set no-pie option when building ST elf file
+
+This elf file is used to build a binary file that concatenates BL2 and
+its device tree blob. It then does not need PIE option, and this avoids
+the following compilation error with some compiler versions:
+  error: PHDR segment not covered by LOAD segment
+
+Change-Id: I7562e8c1890275fe0409f3a23cc66a8e14ea1ee0
+Signed-off-by: Yann Gautier <yann.gautier@st.com>
+Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
+Upstream: backport from https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/32960
+---
+ plat/st/common/common_rules.mk | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/plat/st/common/common_rules.mk b/plat/st/common/common_rules.mk
+index 212a67d5168c..b9fe3d4d676f 100644
+--- a/plat/st/common/common_rules.mk
++++ b/plat/st/common/common_rules.mk
+@@ -58,9 +58,9 @@ $(eval $(call MAKE_LD,${STM32_TF_LINKERFILE},$(STM32_LD_FILE),bl2))
+ tf-a-%.elf: $(PLAT)-%.o ${STM32_TF_LINKERFILE}
+ 	@echo "  LDS     $<"
+ ifeq ($($(ARCH)-ld-id),gnu-gcc)
+-	${Q}$($(ARCH)-ld) -o $@ $(subst --,-Wl$(comma)--,${STM32_TF_ELF_LDFLAGS}) -nostartfiles -Wl,-Map=$(@:.elf=.map) -Wl,-dT ${STM32_TF_LINKERFILE} $<
++	${Q}$($(ARCH)-ld) -o $@ $(subst --,-Wl$(comma)--,${STM32_TF_ELF_LDFLAGS}) -nostartfiles -Wl,-no-pie -Wl,-Map=$(@:.elf=.map) -Wl,-dT ${STM32_TF_LINKERFILE} $<
+ else
+-	${Q}$($(ARCH)-ld) -o $@ ${STM32_TF_ELF_LDFLAGS} -Map=$(@:.elf=.map) --script ${STM32_TF_LINKERFILE} $<
++	${Q}$($(ARCH)-ld) -o $@ ${STM32_TF_ELF_LDFLAGS} -no-pie -Map=$(@:.elf=.map) --script ${STM32_TF_LINKERFILE} $<
+ endif
+ 
+ tf-a-%.bin: tf-a-%.elf
+-- 
+2.43.0
+