Skip to content

Commit ec02b81

Browse files
lyakhnashif
authored andcommitted
LLEXT: (cosmetic) reduce the scope of a variable
Move a variable calculation inside the block, where it is actually used. Signed-off-by: Guennadi Liakhovetski <[email protected]>
1 parent 835cbad commit ec02b81

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

subsys/llext/llext_load.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -587,28 +587,29 @@ static int llext_copy_symbols(struct llext_loader *ldr, struct llext *ext,
587587

588588
elf_shdr_t *shdr = ldr->sect_hdrs + shndx;
589589
uintptr_t section_addr = shdr->sh_addr;
590-
const void *base;
591-
592-
base = llext_loaded_sect_ptr(ldr, ext, shndx);
593-
if (!base) {
594-
/* If the section is not mapped, try to peek.
595-
* Be noisy about it, since this is addressing
596-
* data that was missed by llext_map_sections.
597-
*/
598-
base = llext_peek(ldr, shdr->sh_offset);
599-
if (base) {
600-
LOG_DBG("section %d peeked at %p", shndx, base);
601-
} else {
602-
LOG_ERR("No data for section %d", shndx);
603-
return -ENOTSUP;
604-
}
605-
}
606590

607591
if (ldr_parm->pre_located &&
608592
(!ldr_parm->section_detached || !ldr_parm->section_detached(shdr))) {
609593
sym_tab->syms[j].addr = (uint8_t *)sym.st_value +
610594
(ldr->hdr.e_type == ET_REL ? section_addr : 0);
611595
} else {
596+
const void *base;
597+
598+
base = llext_loaded_sect_ptr(ldr, ext, shndx);
599+
if (!base) {
600+
/* If the section is not mapped, try to peek.
601+
* Be noisy about it, since this is addressing
602+
* data that was missed by llext_map_sections.
603+
*/
604+
base = llext_peek(ldr, shdr->sh_offset);
605+
if (base) {
606+
LOG_DBG("section %d peeked at %p", shndx, base);
607+
} else {
608+
LOG_ERR("No data for section %d", shndx);
609+
return -ENOTSUP;
610+
}
611+
}
612+
612613
sym_tab->syms[j].addr = (uint8_t *)base + sym.st_value -
613614
(ldr->hdr.e_type == ET_REL ? 0 : section_addr);
614615
}

0 commit comments

Comments
 (0)