UbixOS V2 2.0

Functions | Variables
elf.c File Reference
`#include <sys/elf.h>`
`#include <ubixos/sched.h>`
`#include <ubixos/kpanic.h>`
`#include <lib/kmalloc.h>`
`#include <vmm/vmm.h>`
`#include <lib/kprintf.h>`
`#include <string.h>`
Include dependency graph for elf.c:

Go to the source code of this file.

## Functions
int | elf_load_file (kTask_t *p, const char *file, uint32_t *addr, uint32_t *entry)
char * | elfGetPhType (int phType)
char * | elfGetRelType (int relType)
char * | elfGetShType (int shType)

## Variables
struct {
uInt32 id
char * phTypeName
} | elfPhType [] = { { "PT_NULL", 0 }, { "PT_LOAD", 1 }, { "PT_DYNAMIC", 2 }, { "PT_INTERP", 3 }, { "PT_NOTE", 4 }, { "PT_SHLIB", 5 }, { "PT_PHDR", 6 }, { "PT_LOPROC", 0x70000000 }, { "PT_HIPROC", 0x7fffffff }, }
struct {
uInt32 id
char * relTypeName
} | elfRelType [] = { { "R_386_NONE", 0 }, { "R_386_32", 1 }, { "R_386_PC32", 2 }, { "R_386_GOT32", 3 }, { "R_386_PLT32", 4 }, { "R_386_COPY", 5 }, { "R_386_GLOB_DAT", 6 }, { "R_386_JMP_SLOT", 7 }, { "R_386_RELATIVE", 8 }, { "R_386_GOTOFF", 9 }, { "R_386_GOTPC", 10 }, }
struct {
uInt32 id
char * shTypeName
} | elfShType [] = { { "SHT_NULL", 0 }, { "SHT_PROGBITS", 1 }, { "SHT_SYMTAB", 2 }, { "SHT_STRTAB", 3 }, { "SHT_RELA", 4 }, { "SHT_HASH", 5 }, { "SHT_DYNAMIC", 6 }, { "SHT_NOTE", 7 }, { "SHT_NOBITS", 8 }, { "SHT_REL", 9 }, { "SHT_SHLIB", 10 }, { "SHT_DYNSYM", 11 }, }
struct {
char * elfTypeName
uInt32 id
} | elfType [] = { { "ET_NONE", 0 }, { "ET_REL", 1 }, { "ET_EXEC", 2 }, { "ET_DYN", 3 }, { "ET_CORE", 4 }, { "ET_LOPROC", 0xff00 }, { "ET_HIPROC", 0xffff }, }

## Function Documentation

## ◆ elf_load_file()

int elf_load_file | ( | kTask_t * | p,
|  | const char * | file,
|  | uint32_t * | addr,
|  | uint32_t * | entry
| ) |  |

Definition at line 37 of file elf.c.

References _current, Elf32_Ehdr::e_entry, Elf32_Ehdr::e_ident, Elf32_Ehdr::e_phnum, Elf32_Ehdr::e_phoff, Elf32_Ehdr::e_type, ET_DYN, ET_EXEC, fclose(), fopen(), fread(), fseek(), taskStruct::id, K_PANIC, kfree(), kmalloc(), memset(), Elf32_Phdr::p_memsz, Elf32_Phdr::p_vaddr, PAGE_DEFAULT, PAGE_PRESENT, PAGE_USER, PT_LOAD, vmm_findFreePage(), vmm_remapPage(), and vmm_setPageAttributes().

Here is the call graph for this function:

## ◆ elfGetPhType()

char* elfGetPhType | ( | int | phType | ) |

Definition at line 163 of file elf.c.

References elfPhType, and phTypeName.

## ◆ elfGetRelType()

char* elfGetRelType | ( | int | relType | ) |

Definition at line 167 of file elf.c.

References elfRelType, and relTypeName.

Referenced by kmod_load(), and ldEnable().

## ◆ elfGetShType()

char* elfGetShType | ( | int | shType | ) |

Definition at line 159 of file elf.c.

References elfShType, and shTypeName.

## Variable Documentation

## ◆ elfPhType

const { ... } elfPhType[]

Referenced by elfGetPhType().

## ◆ elfRelType

const { ... } elfRelType[]

Referenced by elfGetRelType().

## ◆ elfShType

const { ... } elfShType[]

Referenced by elfGetShType().

## ◆ elfType

const { ... } elfType[]

## ◆ elfTypeName

char* elfTypeName

Definition at line 140 of file elf.c.

## ◆ id

uInt32 id

Definition at line 141 of file elf.c.

## ◆ phTypeName

char* phTypeName

Definition at line 145 of file elf.c.

Referenced by elfGetPhType().

## ◆ relTypeName

char* relTypeName

Definition at line 155 of file elf.c.

Referenced by elfGetRelType().

## ◆ shTypeName

char* shTypeName

Definition at line 150 of file elf.c.

Referenced by elfGetShType().