Browse Source

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 <guennadi.liakhovetski@linux.intel.com>
pull/81485/head
Guennadi Liakhovetski 8 months ago committed by Anas Nashif
parent
commit
ec02b815a7
  1. 33
      subsys/llext/llext_load.c

33
subsys/llext/llext_load.c

@ -587,28 +587,29 @@ static int llext_copy_symbols(struct llext_loader *ldr, struct llext *ext,
elf_shdr_t *shdr = ldr->sect_hdrs + shndx; elf_shdr_t *shdr = ldr->sect_hdrs + shndx;
uintptr_t section_addr = shdr->sh_addr; uintptr_t section_addr = shdr->sh_addr;
const void *base;
base = llext_loaded_sect_ptr(ldr, ext, shndx);
if (!base) {
/* If the section is not mapped, try to peek.
* Be noisy about it, since this is addressing
* data that was missed by llext_map_sections.
*/
base = llext_peek(ldr, shdr->sh_offset);
if (base) {
LOG_DBG("section %d peeked at %p", shndx, base);
} else {
LOG_ERR("No data for section %d", shndx);
return -ENOTSUP;
}
}
if (ldr_parm->pre_located && if (ldr_parm->pre_located &&
(!ldr_parm->section_detached || !ldr_parm->section_detached(shdr))) { (!ldr_parm->section_detached || !ldr_parm->section_detached(shdr))) {
sym_tab->syms[j].addr = (uint8_t *)sym.st_value + sym_tab->syms[j].addr = (uint8_t *)sym.st_value +
(ldr->hdr.e_type == ET_REL ? section_addr : 0); (ldr->hdr.e_type == ET_REL ? section_addr : 0);
} else { } else {
const void *base;
base = llext_loaded_sect_ptr(ldr, ext, shndx);
if (!base) {
/* If the section is not mapped, try to peek.
* Be noisy about it, since this is addressing
* data that was missed by llext_map_sections.
*/
base = llext_peek(ldr, shdr->sh_offset);
if (base) {
LOG_DBG("section %d peeked at %p", shndx, base);
} else {
LOG_ERR("No data for section %d", shndx);
return -ENOTSUP;
}
}
sym_tab->syms[j].addr = (uint8_t *)base + sym.st_value - sym_tab->syms[j].addr = (uint8_t *)base + sym.st_value -
(ldr->hdr.e_type == ET_REL ? 0 : section_addr); (ldr->hdr.e_type == ET_REL ? 0 : section_addr);
} }

Loading…
Cancel
Save