Skip to content

Commit 6fd80ee

Browse files
committed
llext: (cosmetic) more 'section' to 'region' renaming
This commit continues the effort of removing the use of the 'section' terminology in the LLEXT code that deals with 'enum llext_mem' values. This commit replaces the following terms in 'llext_copy_section' and related functions: * llext_copy_section -> llext_copy_region * ldr->sects[mem_idx] -> region * sect_alloc -> region_alloc * sect_align -> region_align No functional changes are introduced in this commit. Signed-off-by: Luca Burelli <[email protected]>
1 parent c22233a commit 6fd80ee

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

subsys/llext/llext_mem.c

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,24 @@ static void llext_init_mem_part(struct llext *ext, enum llext_mem mem_idx,
5858
LOG_DBG("region %d: start 0x%zx, size %zd", mem_idx, (size_t)start, len);
5959
}
6060

61-
static int llext_copy_section(struct llext_loader *ldr, struct llext *ext,
61+
static int llext_copy_region(struct llext_loader *ldr, struct llext *ext,
6262
enum llext_mem mem_idx)
6363
{
6464
int ret;
65+
elf_shdr_t *region = ldr->sects + mem_idx;
6566

66-
if (!ldr->sects[mem_idx].sh_size) {
67+
if (!region->sh_size) {
6768
return 0;
6869
}
69-
ext->mem_size[mem_idx] = ldr->sects[mem_idx].sh_size;
70+
ext->mem_size[mem_idx] = region->sh_size;
7071

71-
if (ldr->sects[mem_idx].sh_type != SHT_NOBITS &&
72+
if (region->sh_type != SHT_NOBITS &&
7273
IS_ENABLED(CONFIG_LLEXT_STORAGE_WRITABLE)) {
7374
/* Directly use data from the ELF buffer if peek() is supported */
74-
ext->mem[mem_idx] = llext_peek(ldr, ldr->sects[mem_idx].sh_offset);
75+
ext->mem[mem_idx] = llext_peek(ldr, region->sh_offset);
7576
if (ext->mem[mem_idx]) {
7677
llext_init_mem_part(ext, mem_idx, (uintptr_t)ext->mem[mem_idx],
77-
ldr->sects[mem_idx].sh_size);
78+
region->sh_size);
7879
ext->mem_on_heap[mem_idx] = false;
7980
return 0;
8081
}
@@ -85,36 +86,36 @@ static int llext_copy_section(struct llext_loader *ldr, struct llext *ext,
8586
* we are after that we can assign memory permission bits on.
8687
*/
8788
#ifndef CONFIG_ARM_MPU
88-
const uintptr_t sect_alloc = ROUND_UP(ldr->sects[mem_idx].sh_size, LLEXT_PAGE_SIZE);
89-
const uintptr_t sect_align = LLEXT_PAGE_SIZE;
89+
const uintptr_t region_alloc = ROUND_UP(region->sh_size, LLEXT_PAGE_SIZE);
90+
const uintptr_t region_align = LLEXT_PAGE_SIZE;
9091
#else
91-
uintptr_t sect_alloc = LLEXT_PAGE_SIZE;
92+
uintptr_t region_alloc = LLEXT_PAGE_SIZE;
9293

93-
while (sect_alloc < ldr->sects[mem_idx].sh_size) {
94-
sect_alloc *= 2;
94+
while (region_alloc < region->sh_size) {
95+
region_alloc *= 2;
9596
}
96-
uintptr_t sect_align = sect_alloc;
97+
uintptr_t region_align = region_alloc;
9798
#endif
9899

99-
ext->mem[mem_idx] = llext_aligned_alloc(sect_align, sect_alloc);
100+
ext->mem[mem_idx] = llext_aligned_alloc(region_align, region_alloc);
100101
if (!ext->mem[mem_idx]) {
101102
return -ENOMEM;
102103
}
103104

104-
ext->alloc_size += sect_alloc;
105+
ext->alloc_size += region_alloc;
105106

106107
llext_init_mem_part(ext, mem_idx, (uintptr_t)ext->mem[mem_idx],
107-
sect_alloc);
108+
region_alloc);
108109

109-
if (ldr->sects[mem_idx].sh_type == SHT_NOBITS) {
110-
memset(ext->mem[mem_idx], 0, ldr->sects[mem_idx].sh_size);
110+
if (region->sh_type == SHT_NOBITS) {
111+
memset(ext->mem[mem_idx], 0, region->sh_size);
111112
} else {
112-
ret = llext_seek(ldr, ldr->sects[mem_idx].sh_offset);
113+
ret = llext_seek(ldr, region->sh_offset);
113114
if (ret != 0) {
114115
goto err;
115116
}
116117

117-
ret = llext_read(ldr, ext->mem[mem_idx], ldr->sects[mem_idx].sh_size);
118+
ret = llext_read(ldr, ext->mem[mem_idx], region->sh_size);
118119
if (ret != 0) {
119120
goto err;
120121
}
@@ -132,10 +133,10 @@ static int llext_copy_section(struct llext_loader *ldr, struct llext *ext,
132133

133134
int llext_copy_strings(struct llext_loader *ldr, struct llext *ext)
134135
{
135-
int ret = llext_copy_section(ldr, ext, LLEXT_MEM_SHSTRTAB);
136+
int ret = llext_copy_region(ldr, ext, LLEXT_MEM_SHSTRTAB);
136137

137138
if (!ret) {
138-
ret = llext_copy_section(ldr, ext, LLEXT_MEM_STRTAB);
139+
ret = llext_copy_region(ldr, ext, LLEXT_MEM_STRTAB);
139140
}
140141

141142
return ret;
@@ -149,7 +150,7 @@ int llext_copy_regions(struct llext_loader *ldr, struct llext *ext)
149150
continue;
150151
}
151152

152-
int ret = llext_copy_section(ldr, ext, mem_idx);
153+
int ret = llext_copy_region(ldr, ext, mem_idx);
153154

154155
if (ret < 0) {
155156
return ret;

0 commit comments

Comments
 (0)