diff --git a/arch/xtensa/core/elf.c b/arch/xtensa/core/elf.c index 0ce9885eed6..04dac478215 100644 --- a/arch/xtensa/core/elf.c +++ b/arch/xtensa/core/elf.c @@ -124,9 +124,11 @@ void arch_elf_relocate_local(struct llext_loader *ldr, struct llext *ext, const 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); + + /* shdr->sh_addr is NULL when not built for a specific address */ sh_addr = shdr->sh_addr && (!ldr_parm->section_detached || !ldr_parm->section_detached(shdr)) ? - shdr->sh_addr : (uintptr_t)llext_peek(ldr, shdr->sh_offset); + shdr->sh_addr : (uintptr_t)llext_loaded_sect_ptr(ldr, ext, sym->st_shndx); } else { sh_addr = ldr->sects[LLEXT_MEM_TEXT].sh_addr; }