diff --git a/arch/arm/core/elf.c b/arch/arm/core/elf.c index 0a7aa654479..e16af6199e6 100644 --- a/arch/arm/core/elf.c +++ b/arch/arm/core/elf.c @@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(elf, CONFIG_LLEXT_LOG_LEVEL); * The relocation codes for arm are well documented * https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst#relocation */ -void arch_elf_relocate(elf_rel_t *rel, uintptr_t opaddr, uintptr_t opval) +void arch_elf_relocate(elf_rela_t *rel, uintptr_t opaddr, uintptr_t opval) { elf_word reloc_type = ELF32_R_TYPE(rel->r_info); diff --git a/include/zephyr/llext/elf.h b/include/zephyr/llext/elf.h index 6e2b62986dd..6dc3cc4e5c8 100644 --- a/include/zephyr/llext/elf.h +++ b/include/zephyr/llext/elf.h @@ -306,6 +306,12 @@ struct elf32_rel { elf32_word r_info; }; +struct elf32_rela { + elf32_addr r_offset; + elf32_word r_info; + elf32_word r_addend; +}; + /** * @brief Relocation symbol index from r_info * @@ -330,6 +336,12 @@ struct elf64_rel { elf64_xword r_info; }; +struct elf64_rela { + elf64_addr r_offset; + elf64_word r_info; + elf64_word r_addend; +}; + /** @brief Relocation symbol from r_info * * @param i Value of r_info @@ -436,6 +448,7 @@ typedef elf64_half elf_half; typedef elf64_xword elf_word; /** Machine sized relocation struct */ typedef struct elf64_rel elf_rel_t; +typedef struct elf64_rela elf_rela_t; /** Machine sized symbol struct */ typedef struct elf64_sym elf_sym_t; /** Machine sized macro alias for obtaining a relocation symbol */ @@ -461,6 +474,7 @@ typedef elf32_half elf_half; typedef elf32_word elf_word; /** Machine sized relocation struct */ typedef struct elf32_rel elf_rel_t; +typedef struct elf32_rela elf_rela_t; /** Machine sized symbol struct */ typedef struct elf32_sym elf_sym_t; /** Machine sized macro alias for obtaining a relocation symbol */ diff --git a/include/zephyr/llext/llext.h b/include/zephyr/llext/llext.h index 6afb48682be..33feba50bd5 100644 --- a/include/zephyr/llext/llext.h +++ b/include/zephyr/llext/llext.h @@ -135,7 +135,7 @@ int llext_call_fn(struct llext *ext, const char *sym_name); * @param[in] opaddr Address of operation to rewrite with relocation * @param[in] opval Value of looked up symbol to relocate */ -void arch_elf_relocate(elf_rel_t *rel, uintptr_t opaddr, uintptr_t opval); +void arch_elf_relocate(elf_rela_t *rel, uintptr_t opaddr, uintptr_t opval); /** * @} diff --git a/subsys/llext/llext.c b/subsys/llext/llext.c index d46e021b894..24f48414ad8 100644 --- a/subsys/llext/llext.c +++ b/subsys/llext/llext.c @@ -403,7 +403,7 @@ out: return ret; } -__weak void arch_elf_relocate(elf_rel_t *rel, uintptr_t opaddr, uintptr_t opval) +__weak void arch_elf_relocate(elf_rela_t *rel, uintptr_t opaddr, uintptr_t opval) { } @@ -412,7 +412,7 @@ static int llext_link(struct llext_loader *ldr, struct llext *ext) int ret = 0; uintptr_t loc = 0; elf_shdr_t shdr; - elf_rel_t rel; + elf_rela_t rel; elf_sym_t sym; size_t pos = ldr->hdr.e_shoff; elf_word rel_cnt = 0;