diff mbox series

[v2,1/6] arm64: PIE: Do not skip static relocation

Message ID 20200930163918.24995-2-andre.przywara@arm.com
State Accepted
Commit eabc0902155aa36f603f628360706767202affb2
Delegated to: Tom Rini
Headers show
Series qemu-arm64: Allow booting via Trusted Firmware | expand

Commit Message

Andre Przywara Sept. 30, 2020, 4:39 p.m. UTC
When we build an arm64 target and enable POSITION_INDEPENDENT, we were
skipping our build-time dynamic relocation fixup routine (STATIC_RELA).

This was probably done because we didn't need it in this case, as the
PIE fixup routine in start.S would take care of that at runtime.

However when we now skip this routine (upon detecting that the fixup
offset is 0), this might lead to uninitialised pointers.

Remove the exception, so that we always do the build-time relocation.

NOTE: GNU binutils starting with v2.27.1 do this build-time relocation
automatically, to be in-line with other architecures. So on newer
toolchains our manual fixup is actually not needed. It doesn't hurt to
have it, though, so that we keep compatibility with the popular Linaro
toolchains, which lack this feature.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
 arch/arm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Warren Sept. 30, 2020, 5:11 p.m. UTC | #1
On 9/30/20 10:39 AM, Andre Przywara wrote:
> When we build an arm64 target and enable POSITION_INDEPENDENT, we were
> skipping our build-time dynamic relocation fixup routine (STATIC_RELA).
> 
> This was probably done because we didn't need it in this case, as the
> PIE fixup routine in start.S would take care of that at runtime.
> 
> However when we now skip this routine (upon detecting that the fixup
> offset is 0), this might lead to uninitialised pointers.
> 
> Remove the exception, so that we always do the build-time relocation.
> 
> NOTE: GNU binutils starting with v2.27.1 do this build-time relocation
> automatically, to be in-line with other architecures. So on newer
> toolchains our manual fixup is actually not needed. It doesn't hurt to
> have it, though, so that we keep compatibility with the popular Linaro
> toolchains, which lack this feature.

Reviewed-by: Stephen Warren <swarren@nvidia.com>
Amit Singh Tomar Oct. 1, 2020, 8:33 a.m. UTC | #2
Hi,

>
> NOTE: GNU binutils starting with v2.27.1 do this build-time relocation
> automatically, to be in-line with other architecures. So on newer
> toolchains our manual fixup is actually not needed. It doesn't hurt to
> have it, though, so that we keep compatibility with the popular Linaro
> toolchains, which lack this feature.
>
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> ---
>
> With this, U-Boot now runs well from ROM when compiled with
> "gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu".
>
> Tested-by: Amit Singh Tomar <amittomer25@gmail.com>
>

Thanks
-Amit
Tom Rini Oct. 9, 2020, 1:02 p.m. UTC | #3
On Wed, Sep 30, 2020 at 05:39:13PM +0100, Andre Przywara wrote:

> When we build an arm64 target and enable POSITION_INDEPENDENT, we were
> skipping our build-time dynamic relocation fixup routine (STATIC_RELA).
> 
> This was probably done because we didn't need it in this case, as the
> PIE fixup routine in start.S would take care of that at runtime.
> 
> However when we now skip this routine (upon detecting that the fixup
> offset is 0), this might lead to uninitialised pointers.
> 
> Remove the exception, so that we always do the build-time relocation.
> 
> NOTE: GNU binutils starting with v2.27.1 do this build-time relocation
> automatically, to be in-line with other architecures. So on newer
> toolchains our manual fixup is actually not needed. It doesn't hurt to
> have it, though, so that we keep compatibility with the popular Linaro
> toolchains, which lack this feature.
> 
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> Reviewed-by: Stephen Warren <swarren@nvidia.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 80702c23d34..b6fb276b6f8 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -76,7 +76,7 @@  config GIC_V3_ITS
 
 config STATIC_RELA
 	bool
-	default y if ARM64 && !POSITION_INDEPENDENT
+	default y if ARM64
 
 config DMA_ADDR_T_64BIT
 	bool