UnnamedOS
elf.c File Reference
#include <common.h>
#include <string.h>
#include <tasks/elf.h>
#include <interrupts/isr.h>
+ Include dependency graph for elf.c:

Go to the source code of this file.

Data Structures

struct  elf_program_header_entry_t
 program header entries tell us how to load executables More...
 

Macros

#define MAGIC_0   0x7F
 magic value expected at the beginning of an ELF file
 
#define MAGIC_1   'E'
 magic value expected at the beginning of an ELF file
 
#define MAGIC_2   'L'
 magic value expected at the beginning of an ELF file
 
#define MAGIC_3   'F'
 magic value expected at the beginning of an ELF file
 
#define VERSION   1
 only ELF version 1 is supported (the current version)
 

Enumerations

enum  elf_class { CLASS_32_BIT = 1, CLASS_64_BIT }
 32 or 64 bit
 
enum  elf_data { DATA_LITTLE_ENDIAN = 1, DATA_BIG_ENDIAN }
 little or big endian
 
enum  elf_type { TYPE_RELOCATABLE = 1, TYPE_EXECUTABLE, TYPE_SHARED, TYPE_CORE }
 object type
 
enum  elf_machine { MACHINE_X86 = 3 }
 targeted ISA, we are only interested in x86
 

Functions

static uint8_t elf_check (elf_t *elf)
 Checks whether a pointer points to a valid ELF file for this OS. More...
 
void * elf_load (elf_t *elf, page_directory_t *page_directory)
 Loads the segments of an ELF file into memory. More...
 
void elf_unload (elf_t *elf, page_directory_t *page_directory)
 Frees the segments of an ELF file in memory. More...
 
task_pid_t elf_create_task (elf_t *elf, size_t kernel_stack_len, size_t user_stack_len)
 Creates a user task running the code of an ELF file. More...
 
void elf_destroy_task (task_pid_t pid)
 Destroys a user task running the code of an ELF file. More...