diff --git a/Execute/Elf/Exec.cpp b/Execute/Elf/Exec.cpp index c02f3f4a..64182583 100644 --- a/Execute/Elf/Exec.cpp +++ b/Execute/Elf/Exec.cpp @@ -15,6 +15,7 @@ using namespace Tasking; namespace Execute { void ELFLoadExec(void *BaseImage, + size_t Length, Elf64_Ehdr *ELFHeader, Memory::Virtual &pva, SpawnData *ret, @@ -139,6 +140,14 @@ namespace Execute UNUSED(SymbolTable); UNUSED(RelaPlt); + char *NeededLibraries[256]; + uint64_t InitAddress = 0; + uint64_t FiniAddress = 0; + + UNUSED(NeededLibraries); + UNUSED(InitAddress); + UNUSED(FiniAddress); + if (!DynamicString) DynamicString = StringTable; @@ -172,10 +181,6 @@ namespace Execute 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++) { switch (Dynamic[i].d_tag) @@ -376,11 +381,15 @@ namespace Execute FileSystem::FILE *InterpreterFile = vfs->Open(InterpreterPath); if (InterpreterFile->Status != FileSystem::FileStatus::OK) { - error("Failed to open interpreter file: %s", InterpreterPath); + warn("Failed to open interpreter file: %s", InterpreterPath); } else { + // TODO: Load interpreter file + fixme("Interpreter file loaded: %s", InterpreterPath); } + vfs->Close(InterpreterFile); + break; } /* ... */ diff --git a/Execute/Spawn.cpp b/Execute/Spawn.cpp index 3d4c0b8b..31b40724 100644 --- a/Execute/Spawn.cpp +++ b/Execute/Spawn.cpp @@ -19,6 +19,7 @@ namespace Execute SpawnData ret = {.Status = ExStatus::Unknown, .Process = nullptr, .Thread = nullptr}; + FileSystem::FILE *ExFile = vfs->Open(Path); if (ExFile->Status == FileSystem::FileStatus::OK) { @@ -121,7 +122,7 @@ namespace Execute 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; } else if (ELFHeader->e_type == ET_DYN) diff --git a/include/exec.hpp b/include/exec.hpp index 28815c5b..315c5d62 100644 --- a/include/exec.hpp +++ b/include/exec.hpp @@ -43,8 +43,8 @@ namespace Execute SpawnData Spawn(char *Path, const char **argv, const char **envp); void *ELFLoadRel(Elf64_Ehdr *Header); - void ELFLoadExec(void *BaseImage, + size_t Length, Elf64_Ehdr *ELFHeader, Memory::Virtual &pva, SpawnData *ret,