X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fbinary.c;h=76893a38b73cd5aa09d8467121234be7689b49e4;hb=7d76ac580a19c897ea849d4bc684068ab1fdc6f3;hp=94c347ff7f8d52917d271f35b49000749f46e4eb;hpb=d82586eccb8bc74aec2b2d6cf4ee2b4ed844e957;p=tpg%2Facess2.git diff --git a/Kernel/binary.c b/Kernel/binary.c index 94c347ff..76893a38 100644 --- a/Kernel/binary.c +++ b/Kernel/binary.c @@ -28,7 +28,6 @@ extern char *Threads_GetName(int ID); extern tKernelSymbol gKernelSymbols[]; extern tKernelSymbol gKernelSymbolsEnd[]; extern tBinaryType gELF_Info; -extern void MM_DumpTables(tVAddr, tVAddr); // === PROTOTYPES === int Proc_Execve(const char *File, const char **ArgV, const char **EnvP); @@ -107,7 +106,7 @@ int Proc_Execve(const char *File, const char **ArgV, const char **EnvP) char **argvSaved, **envpSaved; char *savedFile; tVAddr entry; - Uint bases[2] = {0}; // Uint because Proc_StartUser wants it + Uint base; // Uint because Proc_StartUser wants it ENTER("sFile pArgV pEnvP", File, ArgV, EnvP); @@ -159,31 +158,32 @@ int Proc_Execve(const char *File, const char **ArgV, const char **EnvP) MM_ClearUser(); // --- Load new binary - bases[0] = Binary_Load(savedFile, &entry); + base = Binary_Load(savedFile, &entry); free(savedFile); - if(bases[0] == 0) + if(base == 0) { + free(argvSaved); Log_Warning("Binary", "Proc_Execve - Unable to load '%s'", Threads_GetName(-1)); LEAVE('-'); Threads_Exit(0, -10); for(;;); } - LOG("entry = 0x%x, bases[0] = 0x%x", entry, bases[0]); + LOG("entry = 0x%x, base = 0x%x", entry, base); - MM_DumpTables(0, KERNEL_BASE); +// MM_DumpTables(0, KERNEL_BASE); LEAVE('-'); // --- And... Jump to it - Proc_StartUser(entry, bases, argc, argvSaved, envpSaved, argenvBytes); + Proc_StartUser(entry, base, argc, argvSaved, argenvBytes); for(;;); // Tell GCC that we never return } /** - * \fn tVAddr Binary_Load(char *Path, tVAddr *EntryPoint) * \brief Load a binary into the current address space * \param Path Path to binary to load * \param EntryPoint Pointer for exectuable entry point + * \return Virtual address where the binary has been loaded */ tVAddr Binary_Load(const char *Path, tVAddr *EntryPoint) { @@ -218,6 +218,7 @@ tVAddr Binary_Load(const char *Path, tVAddr *EntryPoint) VFS_Close(fd); mount_id = info.mount; inode = info.inode; + LOG("mount_id = %i, inode = %i", mount_id, inode); } // TODO: Also get modifcation time? @@ -344,7 +345,7 @@ tVAddr Binary_MapIn(tBinary *Binary, const char *Path, tVAddr LoadMin, tVAddr Lo tBinarySection *sect = &Binary->LoadSections[i]; Uint protflags, mapflags; tVAddr addr = sect->Virtual - Binary->Base + base; - LOG("%i - %p to 0x%llx (%x)", i, addr, sect->Offset, sect->Flags); + LOG("%i - %p to offset 0x%llx (%x)", i, addr, sect->Offset, sect->Flags); protflags = MMAP_PROT_READ; mapflags = MMAP_MAP_FIXED; @@ -365,10 +366,12 @@ tVAddr Binary_MapIn(tBinary *Binary, const char *Path, tVAddr LoadMin, tVAddr Lo protflags, MMAP_MAP_PRIVATE|mapflags, 0, 0 ); +// memset((void*)(addr + sect->FileSize), 0, sect->MemSize - sect->FileSize); } } Log_Debug("Binary", "PID %i - Mapped '%s' to 0x%x", Threads_GetPID(), Path, base); + VFS_Close(fd); //LOG("*0x%x = 0x%x\n", binary->Pages[0].Virtual, *(Uint*)binary->Pages[0].Virtual); @@ -413,7 +416,7 @@ tBinary *Binary_DoLoad(tMount MountID, tInode Inode, const char *Path) { tBinary *pBinary; int fp; - Uint ident; + Uint32 ident; tBinaryType *bt = gRegBinTypes; ENTER("iMountID XInode sPath", MountID, Inode, Path); @@ -425,19 +428,26 @@ tBinary *Binary_DoLoad(tMount MountID, tInode Inode, const char *Path) LEAVE('n'); return NULL; } + + LOG("fp = 0x%x", fp); // Read File Type VFS_Read(fp, 4, &ident); VFS_Seek(fp, 0, SEEK_SET); + LOG("ident = 0x%x", ident); + // Determine the type for(; bt; bt = bt->Next) { - if( (ident & bt->Mask) != (Uint)bt->Ident ) + if( (ident & bt->Mask) != (Uint32)bt->Ident ) continue; + LOG("bt = %p (%s)", bt, bt->Name); pBinary = bt->Load(fp); break; } + + LOG("pBinary = %p", pBinary); // Close File VFS_Close(fp);