From: Koakuma koachan@protonmail.com
[ Upstream commit 05457d96175d25c976ab6241c332ae2eb5e07833 ]
This is needed so that the kernel can handle R_SPARC_UA64 relocations, which is emitted by LLVM's IAS.
Signed-off-by: Koakuma koachan@protonmail.com Reviewed-by: Andreas Larsson andreas@gaisler.com Signed-off-by: Andreas Larsson andreas@gaisler.com Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
YES – this patch fixes a real module-loading bug for sparc64 systems without touching unrelated code.
- `arch/sparc/include/asm/elf_64.h:61` adds the missing ABI constant `R_SPARC_UA64` (value 54), so the loader can even recognise relocations that LLVM’s integrated assembler already emits. - `arch/sparc/kernel/module.c:90` folds `R_SPARC_UA64` into the existing `R_SPARC_64` handler, writing the eight relocation bytes individually just like the aligned case. Without this case the switch drops into the default branch (`module.c:134`) and aborts module loading with “Unknown relocation” and `-ENOEXEC`, so clang-built modules simply cannot load today. - Scope and risk stay minimal: the bytes written are identical to the long-standing `R_SPARC_64` path, so nothing changes for GCC-produced objects; the new code only runs when the UA64 relocation is present, avoiding regressions elsewhere.
Given it unbreaks a supported toolchain configuration with a tiny, well- contained fix, this is an appropriate stable backport.
arch/sparc/include/asm/elf_64.h | 1 + arch/sparc/kernel/module.c | 1 + 2 files changed, 2 insertions(+)
diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h index 8fb09eec8c3e7..694ed081cf8d9 100644 --- a/arch/sparc/include/asm/elf_64.h +++ b/arch/sparc/include/asm/elf_64.h @@ -58,6 +58,7 @@ #define R_SPARC_7 43 #define R_SPARC_5 44 #define R_SPARC_6 45 +#define R_SPARC_UA64 54
/* Bits present in AT_HWCAP, primarily for Sparc32. */ #define HWCAP_SPARC_FLUSH 0x00000001 diff --git a/arch/sparc/kernel/module.c b/arch/sparc/kernel/module.c index b8c51cc23d969..6e3d4dde4f9ab 100644 --- a/arch/sparc/kernel/module.c +++ b/arch/sparc/kernel/module.c @@ -87,6 +87,7 @@ int apply_relocate_add(Elf_Shdr *sechdrs, break; #ifdef CONFIG_SPARC64 case R_SPARC_64: + case R_SPARC_UA64: location[0] = v >> 56; location[1] = v >> 48; location[2] = v >> 40;