diff --git a/arch/arm/core/elf.c b/arch/arm/core/elf.c index e16af6199e6..d68b59501f5 100644 --- a/arch/arm/core/elf.c +++ b/arch/arm/core/elf.c @@ -26,6 +26,9 @@ void arch_elf_relocate(elf_rela_t *rel, uintptr_t opaddr, uintptr_t opval) switch (reloc_type) { case R_ARM_ABS32: + /* Add the addend stored at opaddr to opval */ + opval += *((uint32_t *)opaddr); + /* Update the absolute address of a load/store instruction */ *((uint32_t *)opaddr) = (uint32_t)opval; break; diff --git a/subsys/llext/llext.c b/subsys/llext/llext.c index a6ed1e4ac86..9af133d6757 100644 --- a/subsys/llext/llext.c +++ b/subsys/llext/llext.c @@ -769,10 +769,9 @@ static int llext_link(struct llext_loader *ldr, struct llext *ext, bool do_local } } else if (ELF_ST_TYPE(sym.st_info) == STT_SECTION || ELF_ST_TYPE(sym.st_info) == STT_FUNC) { - /* Current relocation location holds an offset into the section */ + /* Link address is relative to the start of the section */ link_addr = (uintptr_t)ext->mem[ldr->sect_map[sym.st_shndx]] - + sym.st_value - + *((uintptr_t *)op_loc); + + sym.st_value; LOG_INF("found section symbol %s addr 0x%lx", name, link_addr); } else {