llext: fix .bss on heap
With writable LLEXT but without pre-assigned section addresses .bss section offset in its ELF header will not match .bss eventual location as it's allocated on the heap. Use llext_loaded_sect_ptr() to get a correct address in both cases. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
parent
b3d8766126
commit
acbd183b72
1 changed files with 3 additions and 1 deletions
|
|
@ -124,9 +124,11 @@ void arch_elf_relocate_local(struct llext_loader *ldr, struct llext *ext, const
|
||||||
if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) {
|
if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) {
|
||||||
elf_shdr_t *shdr = llext_peek(ldr, ldr->hdr.e_shoff +
|
elf_shdr_t *shdr = llext_peek(ldr, ldr->hdr.e_shoff +
|
||||||
sym->st_shndx * ldr->hdr.e_shentsize);
|
sym->st_shndx * ldr->hdr.e_shentsize);
|
||||||
|
|
||||||
|
/* shdr->sh_addr is NULL when not built for a specific address */
|
||||||
sh_addr = shdr->sh_addr &&
|
sh_addr = shdr->sh_addr &&
|
||||||
(!ldr_parm->section_detached || !ldr_parm->section_detached(shdr)) ?
|
(!ldr_parm->section_detached || !ldr_parm->section_detached(shdr)) ?
|
||||||
shdr->sh_addr : (uintptr_t)llext_peek(ldr, shdr->sh_offset);
|
shdr->sh_addr : (uintptr_t)llext_loaded_sect_ptr(ldr, ext, sym->st_shndx);
|
||||||
} else {
|
} else {
|
||||||
sh_addr = ldr->sects[LLEXT_MEM_TEXT].sh_addr;
|
sh_addr = ldr->sects[LLEXT_MEM_TEXT].sh_addr;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue