From 43b7dcdf343aefa4578532ab97931c4e3b334ad8 Mon Sep 17 00:00:00 2001 From: Alistair Delva Date: Mon, 26 Sep 2022 20:47:10 +0000 Subject: [PATCH 1/3] examples: standalone: Fix build with LLVM toolchain When building the standalone example with llvm, the link step fails: examples/standalone/libstubs.o: In function `dummy': include/_exports.h:10: undefined reference to `jt' include/_exports.h:11: undefined reference to `jt' include/_exports.h:12: undefined reference to `jt' include/_exports.h:13: undefined reference to `jt' include/_exports.h:14: undefined reference to `jt' examples/standalone/libstubs.o:include/_exports.h:15: more undefined references to `jt' follow Indeed, the standalone libstubs.o does use the jt symbol, but it was marked 'static' in stubs.c. It's strange how gcc builds are working. Signed-off-by: Alistair Delva Cc: Rick Chen Cc: Simon Glass Cc: Tom Rini Cc: Nick Desaulniers --- examples/standalone/stubs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/standalone/stubs.c b/examples/standalone/stubs.c index ce05f41b0ce..65115570e8e 100644 --- a/examples/standalone/stubs.c +++ b/examples/standalone/stubs.c @@ -14,7 +14,7 @@ struct cmd_tbl; * from flash memory. The global_data address is passed as argv[-1] * to the application program. */ -static struct jt_funcs *jt; +struct jt_funcs *jt; gd_t *global_data; #define EXPORT_FUNC(f, a, x, ...) \ From 0b943587d28763db7f277ba1c168d86b4dfca288 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Mon, 26 Sep 2022 20:47:40 +0000 Subject: [PATCH 2/3] Makefile: apply dynamic relocations for LLD 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 45f10759a13..3866cc62f9a 100644 --- a/Makefile +++ b/Makefile @@ -1023,7 +1023,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 From db9d55e2103351cfc8925aadaf5584fe84f61c9f Mon Sep 17 00:00:00 2001 From: Alistair Delva Date: Mon, 26 Sep 2022 20:47:55 +0000 Subject: [PATCH 3/3] spl: atf: Fix clang -Wasm-operand-widths warning common/spl/spl_atf.c:187:51: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths] __asm__ __volatile__("msr DAIF, %0\n\t" : : "r" (daif) : "memory"); ^ common/spl/spl_atf.c:187:34: note: use constraint modifier "w" __asm__ __volatile__("msr DAIF, %0\n\t" : : "r" (daif) : "memory"); ^~ %w0 Use %x0 to match what Linux does in write_sysreg(). Signed-off-by: Alistair Delva Cc: Kever Yang Cc: Michael Walle Cc: Simon Glass Cc: Tom Rini Cc: Nick Desaulniers --- common/spl/spl_atf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/spl/spl_atf.c b/common/spl/spl_atf.c index e1b68dd5616..bae5c010c8c 100644 --- a/common/spl/spl_atf.c +++ b/common/spl/spl_atf.c @@ -184,7 +184,7 @@ __weak struct bl_params *bl2_plat_get_bl31_params_v2(uintptr_t bl32_entry, static inline void raw_write_daif(unsigned int daif) { - __asm__ __volatile__("msr DAIF, %0\n\t" : : "r" (daif) : "memory"); + __asm__ __volatile__("msr DAIF, %x0\n\t" : : "r" (daif) : "memory"); } typedef void (*atf_entry_t)(struct bl31_params *params, void *plat_params);