Add logic to detect ELF loader collision and skip.

pull/578/head
David Garske 2025-06-24 09:00:36 -07:00 committed by Daniele Lacamera
parent 754d313f3f
commit 499c0812ee
2 changed files with 18 additions and 8 deletions

@ -1 +1 @@
Subproject commit aec13923a7bdacf92e09e744ce40681c92395b67
Subproject commit 978a29da0b76eb868748967f4cb74421dc2382a2

View File

@ -136,15 +136,25 @@ int elf_load_image_mmu(uint8_t *image, uintptr_t *pentry, elf_mmu_map_cb mmu_cb)
}
}
memcpy((void*)(uintptr_t)vaddr, image + offset, file_size);
if (mem_size > file_size) {
memset((void*)(uintptr_t)(vaddr + file_size), 0,
mem_size - file_size);
/* confirm the entry won't clobber any of the headers */
if ((uint8_t*)vaddr + file_size < image ||
(uint8_t*)vaddr > (entry_off + entry_count * entry_size))
{
memcpy((void*)vaddr, image + offset, file_size);
if (mem_size > file_size) {
memset((void*)(uintptr_t)(vaddr + file_size), 0,
mem_size - file_size);
}
#ifdef ARCH_PPC
flush_cache(paddr, mem_size);
#endif
}
#ifdef DEBUG_ELF
else {
wolfBoot_printf("Section would collide with headers! Skipping\n");
}
#ifdef ARCH_PPC
flush_cache(paddr, mem_size);
#endif
#endif
#endif /* !ELF_PARSER */
}
#ifdef DEBUG_ELF