llext: add a function for finding ELF sections
Applications can use custom ELF sections for their own purposes, add a function for finding them. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
parent
03519afb84
commit
f98b8bb48f
2 changed files with 36 additions and 0 deletions
|
@ -47,6 +47,33 @@ sys_slist_t *llext_list(void)
|
|||
return &_llext_list;
|
||||
}
|
||||
|
||||
ssize_t llext_find_section(struct llext_loader *ldr, const char *search_name)
|
||||
{
|
||||
elf_shdr_t *shdr;
|
||||
unsigned int i;
|
||||
size_t pos;
|
||||
|
||||
for (i = 0, pos = ldr->hdr.e_shoff;
|
||||
i < ldr->hdr.e_shnum;
|
||||
i++, pos += ldr->hdr.e_shentsize) {
|
||||
shdr = llext_peek(ldr, pos);
|
||||
if (!shdr) {
|
||||
/* The peek() method isn't supported */
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
const char *name = llext_peek(ldr,
|
||||
ldr->sects[LLEXT_SECT_SHSTRTAB].sh_offset +
|
||||
shdr->sh_name);
|
||||
|
||||
if (!strcmp(name, search_name)) {
|
||||
return shdr->sh_offset;
|
||||
}
|
||||
}
|
||||
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
struct llext *llext_by_name(const char *name)
|
||||
{
|
||||
sys_slist_t *mlist = llext_list();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue