Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
 4.1.99
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
inspect.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 Arduino SA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_LLEXT_INSPECT_H
8#define ZEPHYR_LLEXT_INSPECT_H
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14#include <stddef.h>
15#include <zephyr/llext/llext.h>
16#include <zephyr/llext/loader.h>
18
48static inline int llext_get_region_info(const struct llext_loader *ldr,
49 const struct llext *ext,
50 enum llext_mem region,
51 const elf_shdr_t **hdr,
52 const void **addr, size_t *size)
53{
54 if ((unsigned int)region >= LLEXT_MEM_COUNT) {
55 return -EINVAL;
56 }
57
58 if (hdr) {
59 *hdr = &ldr->sects[region];
60 }
61 if (addr) {
62 *addr = ext->mem[region];
63 }
64 if (size) {
65 *size = ext->mem_size[region];
66 }
67
68 return 0;
69}
70
84int llext_section_shndx(const struct llext_loader *ldr, const struct llext *ext,
85 const char *section_name);
86
106static inline int llext_get_section_info(const struct llext_loader *ldr,
107 const struct llext *ext,
108 unsigned int shndx,
109 const elf_shdr_t **hdr,
110 enum llext_mem *region,
111 size_t *offset)
112{
113 if (shndx < 0 || shndx >= ext->sect_cnt) {
114 return -EINVAL;
115 }
116 if (!ldr->sect_map) {
117 return -ENOTSUP;
118 }
119
120 if (hdr) {
121 *hdr = &ext->sect_hdrs[shndx];
122 }
123 if (region) {
124 *region = ldr->sect_map[shndx].mem_idx;
125 }
126 if (offset) {
127 *offset = ldr->sect_map[shndx].offset;
128 }
129
130 return 0;
131}
132
137#ifdef __cplusplus
138}
139#endif
140
141#endif /* ZEPHYR_LLEXT_INSPECT_H */
llext_mem
List of memory regions stored or referenced in the LLEXT subsystem.
Definition llext.h:44
@ LLEXT_MEM_COUNT
Number of regions managed by LLEXT.
Definition llext.h:57
static int llext_get_section_info(const struct llext_loader *ldr, const struct llext *ext, unsigned int shndx, const elf_shdr_t **hdr, enum llext_mem *region, size_t *offset)
Get information about a section for the specified extension.
Definition inspect.h:106
int llext_section_shndx(const struct llext_loader *ldr, const struct llext *ext, const char *section_name)
Get the index of a section with the specified name.
static int llext_get_region_info(const struct llext_loader *ldr, const struct llext *ext, enum llext_mem region, const elf_shdr_t **hdr, const void **addr, size_t *size)
Get information about a memory region for the specified extension.
Definition inspect.h:48
#define EINVAL
Invalid argument.
Definition errno.h:60
#define ENOTSUP
Unsupported value.
Definition errno.h:114
Support for linkable loadable extensions.
Private header for linkable loadable extensions.
LLEXT ELF loader context types.
Section Header(64-bit)
Definition elf.h:177
Linkable loadable extension loader context.
Definition loader.h:42
Structure describing a linkable loadable extension.
Definition llext.h:77
size_t mem_size[LLEXT_MEM_COUNT]
Size of each stored region.
Definition llext.h:98
void * mem[LLEXT_MEM_COUNT]
Lookup table of memory regions.
Definition llext.h:92