From 34ab1a1e5184f18edfcecabf87d3c91ceea8dc7c Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Tue, 2 Apr 2024 15:02:24 +0200 Subject: [PATCH] llext: xtensa: add support for in-place relocatable extensions Currently LLEXT on Xtensa supports relocatable extensions, linked for a specific address range, while relocation itself takes place in a temporary buffer. For this section addresses have to be set correctly by the linker for their target locations. This commit adds support for relocatable extensions, built without using specific memory addresses and run at the same addresses, where they are loaded. Signed-off-by: Guennadi Liakhovetski --- arch/xtensa/core/elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/xtensa/core/elf.c b/arch/xtensa/core/elf.c index 46da8eb908a..e85fab84c69 100644 --- a/arch/xtensa/core/elf.c +++ b/arch/xtensa/core/elf.c @@ -37,7 +37,7 @@ void arch_elf_relocate_local(struct llext_loader *ldr, struct llext *ext, if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) { elf_shdr_t *shdr = llext_peek(ldr, ldr->hdr.e_shoff + sym->st_shndx * ldr->hdr.e_shentsize); - sh_addr = shdr->sh_addr; + sh_addr = shdr->sh_addr ? : (uintptr_t)llext_peek(ldr, shdr->sh_offset); } else { sh_addr = ldr->sects[LLEXT_MEM_TEXT].sh_addr; }