llext: make llext_loaded_sect_ptr() available to all LLEXT code
Make llext_loaded_sect_ptr() a proper function to be able to call it from platform LLEXT code. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
parent
09fab7e680
commit
43a69f868b
4 changed files with 45 additions and 12 deletions
32
include/zephyr/llext/llext_internal.h
Normal file
32
include/zephyr/llext/llext_internal.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_LLEXT_INTERNAL_H
|
||||
#define ZEPHYR_LLEXT_INTERNAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Private header for linkable loadable extensions
|
||||
*/
|
||||
|
||||
/** @cond ignore */
|
||||
|
||||
struct llext_loader;
|
||||
struct llext;
|
||||
|
||||
const void *llext_loaded_sect_ptr(struct llext_loader *ldr, struct llext *ext, unsigned int sh_ndx);
|
||||
|
||||
/** @endcond */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ZEPHYR_LLEXT_INTERNAL_H */
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
#include <zephyr/llext/elf.h>
|
||||
#include <zephyr/llext/loader.h>
|
||||
#include <zephyr/llext/llext.h>
|
||||
#include <zephyr/llext/llext_internal.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/cache.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <zephyr/llext/elf.h>
|
||||
#include <zephyr/llext/loader.h>
|
||||
#include <zephyr/llext/llext.h>
|
||||
#include <zephyr/llext/llext_internal.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
|
|
@ -38,6 +39,17 @@ LOG_MODULE_DECLARE(llext, CONFIG_LLEXT_LOG_LEVEL);
|
|||
|
||||
static const char ELF_MAGIC[] = {0x7f, 'E', 'L', 'F'};
|
||||
|
||||
const void *llext_loaded_sect_ptr(struct llext_loader *ldr, struct llext *ext, unsigned int sh_ndx)
|
||||
{
|
||||
enum llext_mem mem_idx = ldr->sect_map[sh_ndx].mem_idx;
|
||||
|
||||
if (mem_idx == LLEXT_MEM_COUNT) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (const uint8_t *)ext->mem[mem_idx] + ldr->sect_map[sh_ndx].offset;
|
||||
}
|
||||
|
||||
/*
|
||||
* Load basic ELF file data
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -58,18 +58,6 @@ static inline const char *llext_string(struct llext_loader *ldr, struct llext *e
|
|||
return (char *)ext->mem[mem_idx] + idx;
|
||||
}
|
||||
|
||||
static inline const void *llext_loaded_sect_ptr(struct llext_loader *ldr, struct llext *ext,
|
||||
unsigned int sh_ndx)
|
||||
{
|
||||
enum llext_mem mem_idx = ldr->sect_map[sh_ndx].mem_idx;
|
||||
|
||||
if (mem_idx == LLEXT_MEM_COUNT) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (const uint8_t *)ext->mem[mem_idx] + ldr->sect_map[sh_ndx].offset;
|
||||
}
|
||||
|
||||
/*
|
||||
* Relocation (llext_link.c)
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue