Skip to contentSkip to conversation

boot/arm-trusted-firmware: add -fno-PIE to CFLAGS

PATCH In review Kory Maincent via buildroot 2 participants 5 messages May 31, 2022 – Jun 7, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 boot/arm-trusted-firmware: add -fno-PIE to CFLAGS

From: Kory Maincent <[email protected]>

By default the toolchain-wrapper enable -fPIE to the build of all packages. TF-A support Position Independent Executable(PIE) only in few build cases, therefore it should be disable by default.
If you still want to enable PIE, TF-A provide a "ENABLE_PIE" build options that will override the cflags for the supported cases.

---
 boot/arm-trusted-firmware/arm-trusted-firmware.mk | 1 +
 1 file changed, 1 insertion(+)
boot/arm-trusted-firmware/arm-trusted-firmware.mk +1 -0
index 03fa83b7b5..b0dec13a4c 100644
@@ -50,6 +50,7 @@ endif
 
 ARM_TRUSTED_FIRMWARE_MAKE_OPTS += \
 	CROSS_COMPILE="$(TARGET_CROSS)" \
+	CFLAGS="-fno-PIE" \
 	$(call qstrip,$(BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_VARIABLES)) \
 	PLAT=$(ARM_TRUSTED_FIRMWARE_PLATFORM)
 
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Kory" == Kory Maincent via buildroot <[email protected]> writes:

From: Kory Maincent <[email protected]>
By default the toolchain-wrapper enable -fPIE to the build of all packages. TF-A support Position Independent Executable(PIE) only in few build cases, therefore it should be disable by default.
If you still want to enable PIE, TF-A provide a "ENABLE_PIE" build options that will override the cflags for the supported cases.

Funny, I ran into the same issue yesterday and figured out the same workaround.

boot/arm-trusted-firmware/arm-trusted-firmware.mk endif · line 53

Quoted 13 lines
---
 boot/arm-trusted-firmware/arm-trusted-firmware.mk | 1 +
 1 file changed, 1 insertion(+)
boot/arm-trusted-firmware/arm-trusted-firmware.mk +1 -0
index 03fa83b7b5..b0dec13a4c 100644
@@ -50,6 +50,7 @@ endif
 
 ARM_TRUSTED_FIRMWARE_MAKE_OPTS += \
 	CROSS_COMPILE="$(TARGET_CROSS)" \
+	CFLAGS="-fno-PIE" \

ATF already has logic to detect if a toolchain is configured with default PIE (looking at gcc -v output), so I think we should only do this if we add the "hidden" -fPIE in the toolchain wrapper.

I've changed this to be conditional of BR2_PIC_PIE and applied, thanks!

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw
Quoted 10 lines · On Fri, 03 Jun 2022 11:21:46 +0200 Peter Korsgaard <[email protected]> wrote:
Quoted 9 lines
 boot/arm-trusted-firmware/arm-trusted-firmware.mk | 1 +
 1 file changed, 1 insertion(+)  
(quoted diff) +0 -0

b/boot/arm-trusted-firmware/arm-trusted-firmware.mk index 03fa83b7b5..b0dec13a4c 100644 --- a/boot/arm-trusted-firmware/arm-trusted-firmware.mk +++ b/boot/arm-trusted-firmware/arm-trusted-firmware.mk @@ -50,6 +50,7 @@ endif

Quoted 7 lines

boot/arm-trusted-firmware/arm-trusted-firmware.mk endif · line 53

Quoted 3 lines

ARM_TRUSTED_FIRMWARE_MAKE_OPTS += \

boot/arm-trusted-firmware/arm-trusted-firmware.mk +1 -0
 	CROSS_COMPILE="$(TARGET_CROSS)" \
+	CFLAGS="-fno-PIE" \  

ATF already has logic to detect if a toolchain is configured with default PIE (looking at gcc -v output), so I think we should only do this if we add the "hidden" -fPIE in the toolchain wrapper.

FYI it is the opposite, if TF-A detects the default PIE in gcc it disable it (ifneq) because it seems to bring issue.
Take a look at the commit f7ec31db2db3c69a7bd970f4e7fd829e7cc0c53a.

Quoted 2 lines

I've changed this to be conditional of BR2_PIC_PIE and applied, thanks!

Ok, thanks.

Regards,
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw
Quoted 23 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Köry" == Köry Maincent <[email protected]> writes:

Quoted 10 lines · On Fri, 03 Jun 2022 11:21:46 +0200 Peter Korsgaard <[email protected]> wrote:
Quoted 9 lines
 boot/arm-trusted-firmware/arm-trusted-firmware.mk | 1 +
 1 file changed, 1 insertion(+)  
(quoted diff) +0 -0

b/boot/arm-trusted-firmware/arm-trusted-firmware.mk index 03fa83b7b5..b0dec13a4c 100644 --- a/boot/arm-trusted-firmware/arm-trusted-firmware.mk +++ b/boot/arm-trusted-firmware/arm-trusted-firmware.mk @@ -50,6 +50,7 @@ endif

Quoted 7 lines

boot/arm-trusted-firmware/arm-trusted-firmware.mk endif · line 53

Quoted 3 lines

ARM_TRUSTED_FIRMWARE_MAKE_OPTS += \

boot/arm-trusted-firmware/arm-trusted-firmware.mk +1 -0
 	CROSS_COMPILE="$(TARGET_CROSS)" \
+	CFLAGS="-fno-PIE" \  

ATF already has logic to detect if a toolchain is configured with default PIE (looking at gcc -v output), so I think we should only do this if we add the "hidden" -fPIE in the toolchain wrapper.

Quoted 3 lines

FYI it is the opposite, if TF-A detects the default PIE in gcc it disable it (ifneq) because it seems to bring issue.
Take a look at the commit f7ec31db2db3c69a7bd970f4e7fd829e7cc0c53a.

Yes, that is what I meant. The logic added in that commit will not trigger for setups where the toolchain is NOT built with -enable-default-pie but where we still add -fPIE in the toolchain wrapper (E.G. when BR2_PIC_PIE is enabled).

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw
In reply to Kory Maincent via buildroot
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Kory" == Kory Maincent via buildroot <[email protected]> writes:

From: Kory Maincent <[email protected]>
By default the toolchain-wrapper enable -fPIE to the build of all packages. TF-A support Position Independent Executable(PIE) only in few build cases, therefore it should be disable by default.
If you still want to enable PIE, TF-A provide a "ENABLE_PIE" build options that will override the cflags for the supported cases.

Committed to 2022.02.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot