llext: pass the whole struct llext_load_param
To simplify LLEXT loader parameter extension pass the whole struct llext_load_param to final consumers instead of extracting individual fields from it in the caller function. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
parent
d676d469bd
commit
0aa6b1c9de
3 changed files with 16 additions and 10 deletions
|
@ -135,8 +135,8 @@ static const void *llext_find_extension_sym(const char *sym_name, struct llext *
|
|||
return se.addr;
|
||||
}
|
||||
|
||||
static void llext_link_plt(struct llext_loader *ldr, struct llext *ext,
|
||||
elf_shdr_t *shdr, bool do_local, elf_shdr_t *tgt)
|
||||
static void llext_link_plt(struct llext_loader *ldr, struct llext *ext, elf_shdr_t *shdr,
|
||||
const struct llext_load_param *ldr_parm, elf_shdr_t *tgt)
|
||||
{
|
||||
unsigned int sh_cnt = shdr->sh_size / shdr->sh_entsize;
|
||||
/*
|
||||
|
@ -252,7 +252,7 @@ static void llext_link_plt(struct llext_loader *ldr, struct llext *ext,
|
|||
*(const void **)(text + got_offset) = link_addr;
|
||||
break;
|
||||
case STB_LOCAL:
|
||||
if (do_local) {
|
||||
if (ldr_parm->relocate_local) {
|
||||
arch_elf_relocate_local(ldr, ext, &rela, &sym, got_offset);
|
||||
}
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ static void llext_link_plt(struct llext_loader *ldr, struct llext *ext,
|
|||
}
|
||||
}
|
||||
|
||||
int llext_link(struct llext_loader *ldr, struct llext *ext, bool do_local)
|
||||
int llext_link(struct llext_loader *ldr, struct llext *ext, const struct llext_load_param *ldr_parm)
|
||||
{
|
||||
uintptr_t sect_base = 0;
|
||||
elf_rela_t rel;
|
||||
|
@ -330,7 +330,7 @@ int llext_link(struct llext_loader *ldr, struct llext *ext, bool do_local)
|
|||
tgt = ldr->sect_hdrs + shdr->sh_info;
|
||||
}
|
||||
|
||||
llext_link_plt(ldr, ext, shdr, do_local, tgt);
|
||||
llext_link_plt(ldr, ext, shdr, ldr_parm, tgt);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -527,7 +527,7 @@ static int llext_export_symbols(struct llext_loader *ldr, struct llext *ext)
|
|||
}
|
||||
|
||||
static int llext_copy_symbols(struct llext_loader *ldr, struct llext *ext,
|
||||
bool pre_located)
|
||||
const struct llext_load_param *ldr_parm)
|
||||
{
|
||||
size_t ent_size = ldr->sects[LLEXT_MEM_SYMTAB].sh_entsize;
|
||||
size_t syms_size = ldr->sects[LLEXT_MEM_SYMTAB].sh_size;
|
||||
|
@ -586,7 +586,7 @@ static int llext_copy_symbols(struct llext_loader *ldr, struct llext *ext,
|
|||
}
|
||||
}
|
||||
|
||||
if (pre_located) {
|
||||
if (ldr_parm->pre_located) {
|
||||
sym_tab->syms[j].addr = (uint8_t *)sym.st_value +
|
||||
(ldr->hdr.e_type == ET_REL ? section_addr : 0);
|
||||
} else {
|
||||
|
@ -609,8 +609,13 @@ static int llext_copy_symbols(struct llext_loader *ldr, struct llext *ext,
|
|||
int do_llext_load(struct llext_loader *ldr, struct llext *ext,
|
||||
const struct llext_load_param *ldr_parm)
|
||||
{
|
||||
const struct llext_load_param default_ldr_parm = LLEXT_LOAD_PARAM_DEFAULT;
|
||||
int ret;
|
||||
|
||||
if (!ldr_parm) {
|
||||
ldr_parm = &default_ldr_parm;
|
||||
}
|
||||
|
||||
/* Zero all memory that is affected by the loading process
|
||||
* (see the NOTICE at the top of this file).
|
||||
*/
|
||||
|
@ -681,14 +686,14 @@ int do_llext_load(struct llext_loader *ldr, struct llext *ext,
|
|||
}
|
||||
|
||||
LOG_DBG("Copying symbols...");
|
||||
ret = llext_copy_symbols(ldr, ext, ldr_parm ? ldr_parm->pre_located : false);
|
||||
ret = llext_copy_symbols(ldr, ext, ldr_parm);
|
||||
if (ret != 0) {
|
||||
LOG_ERR("Failed to copy symbols, ret %d", ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
LOG_DBG("Linking ELF...");
|
||||
ret = llext_link(ldr, ext, ldr_parm ? ldr_parm->relocate_local : true);
|
||||
ret = llext_link(ldr, ext, ldr_parm);
|
||||
if (ret != 0) {
|
||||
LOG_ERR("Failed to link, ret %d", ret);
|
||||
goto out;
|
||||
|
|
|
@ -62,7 +62,8 @@ static inline const char *llext_string(struct llext_loader *ldr, struct llext *e
|
|||
* Relocation (llext_link.c)
|
||||
*/
|
||||
|
||||
int llext_link(struct llext_loader *ldr, struct llext *ext, bool do_local);
|
||||
int llext_link(struct llext_loader *ldr, struct llext *ext,
|
||||
const struct llext_load_param *ldr_parm);
|
||||
void llext_dependency_remove_all(struct llext *ext);
|
||||
|
||||
#endif /* ZEPHYR_SUBSYS_LLEXT_PRIV_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue