ELFLoader: Do not crash on non-page-aligned sections
This commit is contained in:
parent
fd8a0175d9
commit
293b979e75
@ -89,7 +89,8 @@ namespace ELFLoader
|
||||
program_header.p_offset, program_header.p_vaddr, program_header.p_filesz,
|
||||
program_header.p_memsz);
|
||||
|
||||
check(is_aligned<ARCH_PAGE_SIZE>(program_header.p_vaddr));
|
||||
u64 base_vaddr = align_down<ARCH_PAGE_SIZE>(program_header.p_vaddr);
|
||||
u64 vaddr_diff = program_header.p_vaddr - base_vaddr;
|
||||
/*expect(!can_write_and_execute_segment(program_header.p_flags),
|
||||
"Segment is both writable and executable");*/
|
||||
|
||||
@ -99,8 +100,8 @@ namespace ELFLoader
|
||||
flags &= ~MMU::NoExecute;
|
||||
|
||||
// Allocate physical memory for the segment
|
||||
TRY(MemoryManager::alloc_at(program_header.p_vaddr,
|
||||
get_blocks_from_size(program_header.p_memsz, ARCH_PAGE_SIZE), flags));
|
||||
TRY(MemoryManager::alloc_at(
|
||||
base_vaddr, get_blocks_from_size(program_header.p_memsz + vaddr_diff, ARCH_PAGE_SIZE), flags));
|
||||
|
||||
// Load the file section of the segment
|
||||
stream.read_contents(elf_entry, (void*)program_header.p_vaddr, program_header.p_offset,
|
||||
|
Loading…
Reference in New Issue
Block a user