mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
The ELF loader now uses errno.
This commit is contained in:
parent
6986963b4b
commit
9deb183786
3 changed files with 5 additions and 3 deletions
|
@ -17,5 +17,6 @@
|
||||||
#define EISDIR 25
|
#define EISDIR 25
|
||||||
#define EPERM 26
|
#define EPERM 26
|
||||||
#define EIO 27
|
#define EIO 27
|
||||||
|
#define ENOEXEC 28
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -60,6 +60,7 @@ namespace Maxsi
|
||||||
case EISDIR: return (char*) "Is a directory";
|
case EISDIR: return (char*) "Is a directory";
|
||||||
case EPERM: return (char*) "Permission denied";
|
case EPERM: return (char*) "Permission denied";
|
||||||
case EIO: return (char*) "Input/output error";
|
case EIO: return (char*) "Input/output error";
|
||||||
|
case ENOEXEC: return (char*) "Not executable";
|
||||||
default: return (char*) "Unknown error condition";
|
default: return (char*) "Unknown error condition";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
#include <libmaxsi/error.h>
|
||||||
#include <libmaxsi/memory.h>
|
#include <libmaxsi/memory.h>
|
||||||
#include "elf.h"
|
#include "elf.h"
|
||||||
#include "memorymanagement.h"
|
#include "memorymanagement.h"
|
||||||
|
@ -117,14 +118,13 @@ namespace Sortix
|
||||||
|
|
||||||
addr_t Construct(Process* process, const void* file, size_t filelen)
|
addr_t Construct(Process* process, const void* file, size_t filelen)
|
||||||
{
|
{
|
||||||
// TODO: These messages should be returned by errno instead!
|
if ( filelen < sizeof(Header) ) { Error::Set(ENOEXEC); return 0; }
|
||||||
if ( filelen < sizeof(Header) ) { Log::PrintF("File is not executable\n"); return 0; }
|
|
||||||
const Header* header = (const Header*) file;
|
const Header* header = (const Header*) file;
|
||||||
|
|
||||||
if ( !(header->magic[0] == 0x7F && header->magic[1] == 'E' &&
|
if ( !(header->magic[0] == 0x7F && header->magic[1] == 'E' &&
|
||||||
header->magic[2] == 'L' && header->magic[3] == 'F' ) )
|
header->magic[2] == 'L' && header->magic[3] == 'F' ) )
|
||||||
{
|
{
|
||||||
Log::PrintF("File is not executable\n");
|
Error::Set(ENOEXEC);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue