Re: [PATCH] Makefile: apply dynamic relocations for LLD

2022-10-11 Thread Tom Rini
On Mon, Sep 26, 2022 at 08:47:40PM +, Alistair Delva wrote:

> From: Nick Desaulniers 
> 
> It seems that for aarch64, unless we apply dynamic relocations to the
> location being relocated, we fail to boot.
> 
> As Fangrui notes:
>   For dynamic relocations using the RELA format (readelf -Wr), GNU ld
>   sets the initial content to r_addend; ld.lld doesn't do that by
>   default (needs --apply-dynamic-relocs).
> 
> Otherwise .rodata appears to be full of NUL-bytes before relocation,
> causing crashes when trying to invoke the function pointers in
> init_sequence_f from initcall_run_list().
> 
> Link: https://reviews.llvm.org/D42797
> Suggested-by: Fangrui Song 
> Signed-off-by: Nick Desaulniers 
> Signed-off-by: Alistair Delva 
> Cc: Simon Glass 
> Cc: Tom Rini 
> Cc: Nick Desaulniers 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH] Makefile: apply dynamic relocations for LLD

2022-09-26 Thread Alistair Delva
From: Nick Desaulniers 

It seems that for aarch64, unless we apply dynamic relocations to the
location being relocated, we fail to boot.

As Fangrui notes:
  For dynamic relocations using the RELA format (readelf -Wr), GNU ld
  sets the initial content to r_addend; ld.lld doesn't do that by
  default (needs --apply-dynamic-relocs).

Otherwise .rodata appears to be full of NUL-bytes before relocation,
causing crashes when trying to invoke the function pointers in
init_sequence_f from initcall_run_list().

Link: https://reviews.llvm.org/D42797
Suggested-by: Fangrui Song 
Signed-off-by: Nick Desaulniers 
Signed-off-by: Alistair Delva 
Cc: Simon Glass 
Cc: Tom Rini 
Cc: Nick Desaulniers 
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 010ace9d7c..af06b7aa19 100644
--- a/Makefile
+++ b/Makefile
@@ -1022,7 +1022,7 @@ LDFLAGS_u-boot += $(LDFLAGS_FINAL)
 LDFLAGS_u-boot += $(call ld-option, --no-dynamic-linker)
 
 # ld.lld support
-LDFLAGS_u-boot += -z notext
+LDFLAGS_u-boot += -z notext $(call ld-option,--apply-dynamic-relocs)
 
 LDFLAGS_u-boot += --build-id=none
 
-- 
2.30.2