This commit is contained in:
Alex 2022-12-26 08:39:27 +02:00
parent f07c10a2ee
commit 98d58cf655
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
3 changed files with 17 additions and 7 deletions

View File

@ -15,6 +15,7 @@ using namespace Tasking;
namespace Execute namespace Execute
{ {
void ELFLoadExec(void *BaseImage, void ELFLoadExec(void *BaseImage,
size_t Length,
Elf64_Ehdr *ELFHeader, Elf64_Ehdr *ELFHeader,
Memory::Virtual &pva, Memory::Virtual &pva,
SpawnData *ret, SpawnData *ret,
@ -139,6 +140,14 @@ namespace Execute
UNUSED(SymbolTable); UNUSED(SymbolTable);
UNUSED(RelaPlt); UNUSED(RelaPlt);
char *NeededLibraries[256];
uint64_t InitAddress = 0;
uint64_t FiniAddress = 0;
UNUSED(NeededLibraries);
UNUSED(InitAddress);
UNUSED(FiniAddress);
if (!DynamicString) if (!DynamicString)
DynamicString = StringTable; DynamicString = StringTable;
@ -172,10 +181,6 @@ namespace Execute
Elf64_Dyn *Dynamic = (Elf64_Dyn *)((uint8_t *)BaseImage + ItrProgramHeader.p_offset); Elf64_Dyn *Dynamic = (Elf64_Dyn *)((uint8_t *)BaseImage + ItrProgramHeader.p_offset);
char *NeededLibraries[256];
uint64_t InitAddress = 0;
uint64_t FiniAddress = 0;
for (uint64_t i = 0; i < ItrProgramHeader.p_filesz / sizeof(Elf64_Dyn); i++) for (uint64_t i = 0; i < ItrProgramHeader.p_filesz / sizeof(Elf64_Dyn); i++)
{ {
switch (Dynamic[i].d_tag) switch (Dynamic[i].d_tag)
@ -376,11 +381,15 @@ namespace Execute
FileSystem::FILE *InterpreterFile = vfs->Open(InterpreterPath); FileSystem::FILE *InterpreterFile = vfs->Open(InterpreterPath);
if (InterpreterFile->Status != FileSystem::FileStatus::OK) if (InterpreterFile->Status != FileSystem::FileStatus::OK)
{ {
error("Failed to open interpreter file: %s", InterpreterPath); warn("Failed to open interpreter file: %s", InterpreterPath);
} }
else else
{ {
// TODO: Load interpreter file
fixme("Interpreter file loaded: %s", InterpreterPath);
} }
vfs->Close(InterpreterFile);
break; break;
} }
/* ... */ /* ... */

View File

@ -19,6 +19,7 @@ namespace Execute
SpawnData ret = {.Status = ExStatus::Unknown, SpawnData ret = {.Status = ExStatus::Unknown,
.Process = nullptr, .Process = nullptr,
.Thread = nullptr}; .Thread = nullptr};
FileSystem::FILE *ExFile = vfs->Open(Path); FileSystem::FILE *ExFile = vfs->Open(Path);
if (ExFile->Status == FileSystem::FileStatus::OK) if (ExFile->Status == FileSystem::FileStatus::OK)
{ {
@ -121,7 +122,7 @@ namespace Execute
if (ELFHeader->e_type == ET_EXEC) if (ELFHeader->e_type == ET_EXEC)
{ {
ELFLoadExec(BaseImage, ELFHeader, pva, &ret, Path, Process, argv, envp, Arch, Comp); ELFLoadExec(BaseImage, ExFile->Node->Length, ELFHeader, pva, &ret, Path, Process, argv, envp, Arch, Comp);
goto Exit; goto Exit;
} }
else if (ELFHeader->e_type == ET_DYN) else if (ELFHeader->e_type == ET_DYN)

View File

@ -43,8 +43,8 @@ namespace Execute
SpawnData Spawn(char *Path, const char **argv, const char **envp); SpawnData Spawn(char *Path, const char **argv, const char **envp);
void *ELFLoadRel(Elf64_Ehdr *Header); void *ELFLoadRel(Elf64_Ehdr *Header);
void ELFLoadExec(void *BaseImage, void ELFLoadExec(void *BaseImage,
size_t Length,
Elf64_Ehdr *ELFHeader, Elf64_Ehdr *ELFHeader,
Memory::Virtual &pva, Memory::Virtual &pva,
SpawnData *ret, SpawnData *ret,