mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-13 16:29:21 +00:00
Fix type sizes
This commit is contained in:
@ -35,6 +35,7 @@ namespace Execute
|
||||
VirtualFileSystem::File &ExFile,
|
||||
Tasking::PCB *Process)
|
||||
{
|
||||
#if defined(a64)
|
||||
debug("Executable");
|
||||
ELFBaseLoad ELFBase = {};
|
||||
/* This should be deleted inside BaseLoad.cpp */
|
||||
@ -221,5 +222,8 @@ namespace Execute
|
||||
|
||||
ELFBase.Success = true;
|
||||
return ELFBase;
|
||||
#elif defined(a32)
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ namespace Execute
|
||||
|
||||
Elf64_Sym *ELFLookupSymbol(Elf64_Ehdr *Header, const char *Name)
|
||||
{
|
||||
#if defined(a64)
|
||||
Elf64_Shdr *SymbolTable = nullptr;
|
||||
Elf64_Shdr *StringTable = nullptr;
|
||||
Elf64_Sym *Symbol = nullptr;
|
||||
@ -84,11 +85,14 @@ namespace Execute
|
||||
if (strcmp(String, Name) == 0)
|
||||
return Symbol;
|
||||
}
|
||||
#elif defined(a32)
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uintptr_t ELFGetSymbolValue(Elf64_Ehdr *Header, uint64_t Table, uint64_t Index)
|
||||
{
|
||||
#if defined(a64)
|
||||
if (Table == SHN_UNDEF || Index == SHN_UNDEF)
|
||||
return 0;
|
||||
Elf64_Shdr *SymbolTable = GetELFSection(Header, Table);
|
||||
@ -129,10 +133,14 @@ namespace Execute
|
||||
Elf64_Shdr *Target = GetELFSection(Header, Symbol->st_shndx);
|
||||
return (uintptr_t)Header + Symbol->st_value + Target->sh_offset;
|
||||
}
|
||||
#elif defined(a32)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
Elf64_Dyn *ELFGetDynamicTag(void *ElfFile, enum DynamicArrayTags Tag)
|
||||
{
|
||||
#if defined(a64)
|
||||
Elf64_Ehdr *ELFHeader = (Elf64_Ehdr *)ElfFile;
|
||||
|
||||
Elf64_Phdr ItrPhdr;
|
||||
@ -159,10 +167,14 @@ namespace Execute
|
||||
}
|
||||
debug("Dynamic tag %d not found.", Tag);
|
||||
return nullptr;
|
||||
#elif defined(a32)
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
MmImage ELFCreateMemoryImage(Memory::MemMgr *mem, Memory::Virtual &pV, void *ElfFile, size_t Length)
|
||||
{
|
||||
#if defined(a64)
|
||||
void *MemoryImage = nullptr;
|
||||
Elf64_Ehdr *ELFHeader = (Elf64_Ehdr *)ElfFile;
|
||||
bool IsPIC = ELFHeader->e_type == ET_DYN;
|
||||
@ -222,6 +234,9 @@ namespace Execute
|
||||
debug("Remapped: %#lx -> %#lx", (uintptr_t)FirstProgramHeaderVirtualAddress + (i * PAGE_SIZE), (uintptr_t)MemoryImage + (i * PAGE_SIZE));
|
||||
}
|
||||
return {MemoryImage, (void *)FirstProgramHeaderVirtualAddress};
|
||||
#elif defined(a32)
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
uintptr_t LoadELFInterpreter(Memory::MemMgr *mem, Memory::Virtual &pV, const char *Interpreter)
|
||||
@ -235,6 +250,7 @@ namespace Execute
|
||||
/* No need to check if it's valid, the GetBinaryType() call above does that. */
|
||||
VirtualFileSystem::File File = vfs->Open(Interpreter);
|
||||
|
||||
#if defined(a64)
|
||||
Elf64_Ehdr *ELFHeader = (Elf64_Ehdr *)File.node->Address;
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -306,5 +322,9 @@ namespace Execute
|
||||
debug("Interpreter entry point: %#lx (%#lx + %#lx)", (uintptr_t)MemoryImage.Physical + ELFHeader->e_entry,
|
||||
(uintptr_t)MemoryImage.Physical, ELFHeader->e_entry);
|
||||
return (uintptr_t)MemoryImage.Physical + ELFHeader->e_entry;
|
||||
#elif defined(a32)
|
||||
vfs->Close(File);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ namespace Execute
|
||||
VirtualFileSystem::File &ExFile,
|
||||
Tasking::PCB *Process)
|
||||
{
|
||||
#if defined(a64)
|
||||
UNUSED(ExFile);
|
||||
debug("Relocatable");
|
||||
/* TODO: I have to fully implement this, but for now I will leave it as it is now. */
|
||||
@ -105,5 +106,8 @@ namespace Execute
|
||||
}
|
||||
}
|
||||
return ELFBase;
|
||||
#elif defined(a32)
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -100,8 +100,9 @@ namespace Execute
|
||||
sl.MemoryImage = r_cst(uint64_t, ELFCreateMemoryImage(mem, ncpV, LibFile, Length).Physical);
|
||||
debug("MemoryImage: %#lx", sl.MemoryImage);
|
||||
|
||||
uintptr_t BaseAddress = UINTPTR_MAX;
|
||||
{
|
||||
uintptr_t BaseAddress = UINTPTR_MAX;
|
||||
#if defined(a64)
|
||||
Elf64_Phdr ItrProgramHeader;
|
||||
|
||||
for (Elf64_Half i = 0; i < ((Elf64_Ehdr *)LibFile)->e_phnum; i++)
|
||||
@ -128,8 +129,11 @@ namespace Execute
|
||||
memcpy((void *)MAddr, (uint8_t *)LibFile + ItrProgramHeader.p_offset, ItrProgramHeader.p_filesz);
|
||||
debug("memcpy: %#lx => %#lx (%ld bytes)", (uint8_t *)LibFile + ItrProgramHeader.p_offset, (uintptr_t)MAddr, ItrProgramHeader.p_filesz);
|
||||
break;
|
||||
#elif defined(a32)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(a64)
|
||||
struct Elf64_Dyn *JmpRel = ELFGetDynamicTag((void *)LibFile, DT_JMPREL);
|
||||
struct Elf64_Dyn *SymTab = ELFGetDynamicTag((void *)LibFile, DT_SYMTAB);
|
||||
struct Elf64_Dyn *StrTab = ELFGetDynamicTag((void *)LibFile, DT_STRTAB);
|
||||
@ -230,6 +234,9 @@ namespace Execute
|
||||
|
||||
Libs.push_back(sl);
|
||||
return true;
|
||||
#elif defined(a32)
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void SearchLibrary(char *Identifier)
|
||||
|
Reference in New Issue
Block a user