mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-29 07:47:59 +00:00
Do not read the header if it's not "PT_LOAD"
This commit is contained in:
parent
b1e09147bf
commit
bade38e173
@ -183,18 +183,21 @@ namespace Execute
|
|||||||
uintptr_t MAddr;
|
uintptr_t MAddr;
|
||||||
|
|
||||||
if (ItrProgramHeader.p_type == PT_LOAD)
|
if (ItrProgramHeader.p_type == PT_LOAD)
|
||||||
|
{
|
||||||
debug("PT_LOAD");
|
debug("PT_LOAD");
|
||||||
|
MAddr = (ItrProgramHeader.p_vaddr - BaseAddress) + (uintptr_t)MemoryImage;
|
||||||
|
|
||||||
|
memset(MemoryImage, 0, ItrProgramHeader.p_memsz);
|
||||||
|
memcpy(MemoryImage, (uint8_t *)BaseImage + ItrProgramHeader.p_offset, ItrProgramHeader.p_filesz);
|
||||||
|
debug("MemoryImage: %#lx", MemoryImage);
|
||||||
|
debug("MAddr: %#lx", MAddr);
|
||||||
|
debug("memset operation: 0 to %#lx for length %ld", MemoryImage + MAddr, ItrProgramHeader.p_memsz);
|
||||||
|
debug("memcpy operation: %#lx to %#lx for length %ld", (uint8_t *)BaseImage + ItrProgramHeader.p_offset, MemoryImage + MAddr, ItrProgramHeader.p_filesz);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
debug("Not PT_LOAD");
|
{
|
||||||
|
fixme("Not PT_LOAD (%ld)", ItrProgramHeader.p_type);
|
||||||
MAddr = (ItrProgramHeader.p_vaddr - BaseAddress) + (uintptr_t)MemoryImage;
|
}
|
||||||
|
|
||||||
memset(MemoryImage, 0, ItrProgramHeader.p_memsz);
|
|
||||||
memcpy(MemoryImage, (uint8_t *)BaseImage + ItrProgramHeader.p_offset, ItrProgramHeader.p_filesz);
|
|
||||||
debug("MemoryImage: %#lx", MemoryImage);
|
|
||||||
debug("MAddr: %#lx", MAddr);
|
|
||||||
debug("memset operation: 0 to %#lx for length %ld", MemoryImage + MAddr, ItrProgramHeader.p_memsz);
|
|
||||||
debug("memcpy operation: %#lx to %#lx for length %ld", (uint8_t *)BaseImage + ItrProgramHeader.p_offset, MemoryImage + MAddr, ItrProgramHeader.p_filesz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("Entry Point: %#lx", ELFHeader->e_entry);
|
debug("Entry Point: %#lx", ELFHeader->e_entry);
|
||||||
|
@ -239,6 +239,7 @@ enum SegmentTypes
|
|||||||
PT_NOTE = 4,
|
PT_NOTE = 4,
|
||||||
PT_SHLIB = 5,
|
PT_SHLIB = 5,
|
||||||
PT_PHDR = 6,
|
PT_PHDR = 6,
|
||||||
|
PT_TLS = 7,
|
||||||
PT_LOSUNW = 0x6ffffffa,
|
PT_LOSUNW = 0x6ffffffa,
|
||||||
PT_SUNWBSS = 0x6ffffffb,
|
PT_SUNWBSS = 0x6ffffffb,
|
||||||
PT_SUNWSTACK = 0x6ffffffa,
|
PT_SUNWSTACK = 0x6ffffffa,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user