Zephyr API Documentation
3.7.0
A Scalable Open Source RTOS
|
Modules | |
ELF constants and data types | |
ELF loader context | |
Exported symbol definitions | |
Data Structures | |
struct | llext |
Structure describing a linkable loadable extension. More... | |
struct | llext_load_param |
Advanced llext_load parameters. More... | |
Macros | |
#define | LLEXT_LOAD_PARAM_DEFAULT { .relocate_local = true, } |
Default initializer for llext_load_param. | |
Enumerations | |
enum | llext_mem { LLEXT_MEM_TEXT , LLEXT_MEM_DATA , LLEXT_MEM_RODATA , LLEXT_MEM_BSS , LLEXT_MEM_EXPORT , LLEXT_MEM_SYMTAB , LLEXT_MEM_STRTAB , LLEXT_MEM_SHSTRTAB , LLEXT_MEM_COUNT } |
List of memory regions stored or referenced in the LLEXT subsystem. More... | |
Functions | |
struct llext * | llext_by_name (const char *name) |
Find an llext by name. | |
int | llext_iterate (int(*fn)(struct llext *ext, void *arg), void *arg) |
Iterate over all loaded extensions. | |
int | llext_load (struct llext_loader *loader, const char *name, struct llext **ext, struct llext_load_param *ldr_parm) |
Load and link an extension. | |
int | llext_unload (struct llext **ext) |
Unload an extension. | |
const void * | llext_find_sym (const struct llext_symtable *sym_table, const char *sym_name) |
Find the address for an arbitrary symbol. | |
int | llext_call_fn (struct llext *ext, const char *sym_name) |
Call a function by name. | |
int | llext_add_domain (struct llext *ext, struct k_mem_domain *domain) |
Add an extension to a memory domain. | |
int | arch_elf_relocate (elf_rela_t *rel, uintptr_t loc, uintptr_t sym_base_addr, const char *sym_name, uintptr_t load_bias) |
Architecture specific opcode update function. | |
ssize_t | llext_find_section (struct llext_loader *loader, const char *search_name) |
Locates an ELF section in the file. | |
void | arch_elf_relocate_local (struct llext_loader *loader, struct llext *ext, const elf_rela_t *rel, const elf_sym_t *sym, size_t got_offset) |
Architecture specific function for updating addresses via relocation table. | |
#define LLEXT_LOAD_PARAM_DEFAULT { .relocate_local = true, } |
#include <zephyr/llext/llext.h>
Default initializer for llext_load_param.
enum llext_mem |
#include <zephyr/llext/llext.h>
List of memory regions stored or referenced in the LLEXT subsystem.
This enum lists the different types of memory regions that are used by the LLEXT subsystem. The names match common ELF file section names; but note that at load time multiple ELF sections with similar flags may be merged together into a single memory region.
int arch_elf_relocate | ( | elf_rela_t * | rel, |
uintptr_t | loc, | ||
uintptr_t | sym_base_addr, | ||
const char * | sym_name, | ||
uintptr_t | load_bias | ||
) |
#include <zephyr/llext/llext.h>
Architecture specific opcode update function.
ELF files include sections describing a series of relocations, which are instructions on how to rewrite opcodes given the actual placement of some symbolic data such as a section, function, or object. These relocations are architecture specific and each architecture supporting LLEXT must implement this.
[in] | rel | Relocation data provided by ELF |
[in] | loc | Address of opcode to rewrite |
[in] | sym_base_addr | Address of symbol referenced by relocation |
[in] | sym_name | Name of symbol referenced by relocation |
[in] | load_bias | .text load address |
0 | Success |
-ENOTSUP | Unsupported relocation |
-ENOEXEC | Invalid relocation |
void arch_elf_relocate_local | ( | struct llext_loader * | loader, |
struct llext * | ext, | ||
const elf_rela_t * | rel, | ||
const elf_sym_t * | sym, | ||
size_t | got_offset | ||
) |
#include <zephyr/llext/llext.h>
Architecture specific function for updating addresses via relocation table.
[in] | loader | Extension loader data and context |
[in] | ext | Extension to call function in |
[in] | rel | Relocation data provided by elf |
[in] | sym | Corresponding symbol table entry |
[in] | got_offset | Offset within a relocation table |
int llext_add_domain | ( | struct llext * | ext, |
struct k_mem_domain * | domain | ||
) |
#include <zephyr/llext/llext.h>
Add an extension to a memory domain.
Allows an extension to be executed in user mode threads when memory protection hardware is enabled by adding memory partitions covering the extension's memory regions to a memory domain.
[in] | ext | Extension to add to a domain |
[in] | domain | Memory domain to add partitions to |
-ENOSYS | CONFIG_USERSPACE is not enabled or supported |
struct llext * llext_by_name | ( | const char * | name | ) |
#include <zephyr/llext/llext.h>
Find an llext by name.
[in] | name | String name of the llext |
NULL
if not found int llext_call_fn | ( | struct llext * | ext, |
const char * | sym_name | ||
) |
#include <zephyr/llext/llext.h>
Call a function by name.
Expects a symbol representing a void fn(void)
style function exists and may be called.
[in] | ext | Extension to call function in |
[in] | sym_name | Function name (exported symbol) in the extension |
0 | Success |
-ENOENT | Symbol name not found |
ssize_t llext_find_section | ( | struct llext_loader * | loader, |
const char * | search_name | ||
) |
#include <zephyr/llext/llext.h>
Locates an ELF section in the file.
Searches for a section by name in the ELF file and returns its offset.
loader | Extension loader data and context |
search_name | Section name to search for |
const void * llext_find_sym | ( | const struct llext_symtable * | sym_table, |
const char * | sym_name | ||
) |
#include <zephyr/llext/llext.h>
Find the address for an arbitrary symbol.
Searches for a symbol address, either in the list of symbols exported by the main Zephyr binary or in an extension's symbol table.
[in] | sym_table | Symbol table to lookup symbol in, or NULL to search in the main Zephyr symbol table |
[in] | sym_name | Symbol name to find |
NULL
if not found int llext_iterate | ( | int(*)(struct llext *ext, void *arg) | fn, |
void * | arg | ||
) |
#include <zephyr/llext/llext.h>
Iterate over all loaded extensions.
Calls a provided callback function for each registered extension or until the callback function returns a non-0 value.
[in] | fn | callback function |
[in] | arg | a private argument to be provided to the callback function |
0 | if no extensions are registered |
int llext_load | ( | struct llext_loader * | loader, |
const char * | name, | ||
struct llext ** | ext, | ||
struct llext_load_param * | ldr_parm | ||
) |
#include <zephyr/llext/llext.h>
Load and link an extension.
Loads relevant ELF data into memory and provides a structure to work with it.
[in] | loader | An extension loader that provides input data and context |
[in] | name | A string identifier for the extension |
[out] | ext | Pointer to the newly allocated llext structure |
[in] | ldr_parm | Optional advanced load parameters (may be NULL ) |
-ENOMEM | Not enough memory |
-ENOEXEC | Invalid ELF stream |
-ENOTSUP | Unsupported ELF features |
int llext_unload | ( | struct llext ** | ext | ) |