public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] Makefile: apply dynamic relocations for LLD
@ 2022-09-26 20:47 Alistair Delva
  2022-10-11 13:56 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Alistair Delva @ 2022-09-26 20:47 UTC (permalink / raw)
  To: u-boot; +Cc: Fangrui Song, Nick Desaulniers, Simon Glass, Tom Rini

From: Nick Desaulniers <ndesaulniers@google.com>

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 <maskray@google.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Alistair Delva <adelva@google.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Makefile: apply dynamic relocations for LLD
  2022-09-26 20:47 [PATCH] Makefile: apply dynamic relocations for LLD Alistair Delva
@ 2022-10-11 13:56 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2022-10-11 13:56 UTC (permalink / raw)
  To: Alistair Delva; +Cc: u-boot, Fangrui Song, Nick Desaulniers, Simon Glass

[-- Attachment #1: Type: text/plain, Size: 1025 bytes --]

On Mon, Sep 26, 2022 at 08:47:40PM +0000, Alistair Delva wrote:

> From: Nick Desaulniers <ndesaulniers@google.com>
> 
> 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 <maskray@google.com>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Alistair Delva <adelva@google.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Nick Desaulniers <ndesaulniers@google.com>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-11 13:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-26 20:47 [PATCH] Makefile: apply dynamic relocations for LLD Alistair Delva
2022-10-11 13:56 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox