llext: record size of each stored section
Store the size of each section in the llext structure. Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
This commit is contained in:
parent
cbed9fd785
commit
e96b713caf
3 changed files with 10 additions and 6 deletions
|
@ -58,8 +58,11 @@ struct llext {
|
||||||
/** Memory allocated on heap */
|
/** Memory allocated on heap */
|
||||||
bool mem_on_heap[LLEXT_MEM_COUNT];
|
bool mem_on_heap[LLEXT_MEM_COUNT];
|
||||||
|
|
||||||
/** Total size of the llext memory usage */
|
/** Size of each stored section */
|
||||||
size_t mem_size;
|
size_t mem_size[LLEXT_MEM_COUNT];
|
||||||
|
|
||||||
|
/** Total llext allocation size */
|
||||||
|
size_t alloc_size;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These are all global symbols in the extension, all of them don't
|
* These are all global symbols in the extension, all of them don't
|
||||||
|
|
|
@ -302,6 +302,7 @@ static int llext_copy_section(struct llext_loader *ldr, struct llext *ext,
|
||||||
if (!ldr->sects[sect_idx].sh_size) {
|
if (!ldr->sects[sect_idx].sh_size) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
ext->mem_size[mem_idx] = ldr->sects[sect_idx].sh_size;
|
||||||
|
|
||||||
if (ldr->sects[sect_idx].sh_type != SHT_NOBITS &&
|
if (ldr->sects[sect_idx].sh_type != SHT_NOBITS &&
|
||||||
IS_ENABLED(CONFIG_LLEXT_STORAGE_WRITABLE)) {
|
IS_ENABLED(CONFIG_LLEXT_STORAGE_WRITABLE)) {
|
||||||
|
@ -318,7 +319,7 @@ static int llext_copy_section(struct llext_loader *ldr, struct llext *ext,
|
||||||
if (!ext->mem[mem_idx]) {
|
if (!ext->mem[mem_idx]) {
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
ext->mem_size += ldr->sects[sect_idx].sh_size;
|
ext->alloc_size += ldr->sects[sect_idx].sh_size;
|
||||||
|
|
||||||
if (ldr->sects[sect_idx].sh_type == SHT_NOBITS) {
|
if (ldr->sects[sect_idx].sh_type == SHT_NOBITS) {
|
||||||
memset(ext->mem[mem_idx], 0, ldr->sects[sect_idx].sh_size);
|
memset(ext->mem[mem_idx], 0, ldr->sects[sect_idx].sh_size);
|
||||||
|
@ -431,7 +432,7 @@ static int llext_allocate_symtab(struct llext_loader *ldr, struct llext *ext)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
memset(sym_tab->syms, 0, syms_size);
|
memset(sym_tab->syms, 0, syms_size);
|
||||||
ext->mem_size += syms_size;
|
ext->alloc_size += syms_size;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -801,7 +802,7 @@ static int do_llext_load(struct llext_loader *ldr, struct llext *ext,
|
||||||
memset(ldr->sect_map, 0, sect_map_sz);
|
memset(ldr->sect_map, 0, sect_map_sz);
|
||||||
|
|
||||||
ldr->sect_cnt = ldr->hdr.e_shnum;
|
ldr->sect_cnt = ldr->hdr.e_shnum;
|
||||||
ext->mem_size += sect_map_sz;
|
ext->alloc_size += sect_map_sz;
|
||||||
|
|
||||||
LOG_DBG("Finding ELF tables...");
|
LOG_DBG("Finding ELF tables...");
|
||||||
ret = llext_find_tables(ldr);
|
ret = llext_find_tables(ldr);
|
||||||
|
|
|
@ -93,7 +93,7 @@ static int llext_shell_list_cb(struct llext *ext, void *arg)
|
||||||
{
|
{
|
||||||
struct llext_shell_list *sl = arg;
|
struct llext_shell_list *sl = arg;
|
||||||
|
|
||||||
shell_print(sl->sh, "| %16s | %12d |", ext->name, ext->mem_size);
|
shell_print(sl->sh, "| %16s | %12d |", ext->name, ext->alloc_size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue