# elf.h File Reference

`#include <ubixos/types.h>`
`#include <ubixos/sched.h>`

Include dependency graph for elf.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

struct | Elf_Auxargs
struct | elfDynamic
struct | elfDynSym
struct | elfHeader
struct | elfPltInfo
struct | elfProgramHeader
struct | elfSectionHeader

## Defines

#define | ELF32_R_INFO(s, t) ((s)<<8+(unsigned char)(t))
#define | ELF32_R_SYM(i) ((i)>>8)
#define | ELF32_R_TYPE(i) ((unsigned char)(i))
#define | elfExecutable 0x002
#define | elfLibrary 0x003
#define | EM_386 3
#define | EM_68K 4
#define | EM_860 7
#define | EM_88K 5
#define | EM_M32 1
#define | EM_MIPS 8
#define | EM_NONE 0
#define | EM_SPARC 2
#define | ET_CORE 4
#define | ET_DYN 3
#define | ET_EXEC 2
#define | ET_HIPROC 0xffff
#define | ET_LOPROC 0xff00
#define | ET_NONE 0
#define | ET_REL 1
#define | EV_CURRENT 1
#define | EV_NONE 0
#define | PT_DYNAMIC 2
#define | PT_GNU_EH_FRAME 0x6474e550
#define | PT_GNU_RELRO (PT_LOOS + 0x474e552)
#define | PT_GNU_STACK (PT_LOOS + 0x474e551)
#define | PT_HIOS 0x6fffffff
#define | PT_HIPROC 0x7fffffff
#define | PT_INTERP 3
#define | PT_LOAD 1
#define | PT_LOOS 0x60000000
#define | PT_LOPROC 0x70000000
#define | PT_NOTE 4
#define | PT_NULL 0
#define | PT_PAX_FLAGS (PT_LOOS + 0x5041580)
#define | PT_PHDR 6
#define | PT_SHLIB 5
#define | R_386_32 1
#define | R_386_COPY 5
#define | R_386_GLOB_DAT 6
#define | R_386_GOT32 3
#define | R_386_GOTOFF 9
#define | R_386_GOTPC 10
#define | R_386_JMP_SLOT 7
#define | R_386_NONE 0
#define | R_386_PC32 2
#define | R_386_PLT32 4
#define | R_386_RELATIVE 8

## Functions

int | elf_loadfile (kTask_t *p, const char *file, u_int32_t *addr, u_int32_t *entry)
char * | elfGetPhType (int)
char * | elfGetRelType (int)
char * | elfGetShType (int)

## Define Documentation

#define ELF32_R_INFO | ( | s,
|  | t |  | ) | ((s)<<8+(unsigned char)(t))

Definition at line 174 of file elf.h.

#define ELF32_R_SYM | ( | i |  | ) | ((i)>>8)

Definition at line 172 of file elf.h.

Referenced by kmod_load(), and ldEnable().

#define ELF32_R_TYPE | ( | i |  | ) | ((unsigned char)(i))

Definition at line 173 of file elf.h.

Referenced by kmod_load(), and ldEnable().

#define elfExecutable 0x002

Definition at line 36 of file elf.h.

#define elfLibrary 0x003

Definition at line 37 of file elf.h.

#define EM_386 3

Definition at line 66 of file elf.h.

#define EM_68K 4

Definition at line 67 of file elf.h.

#define EM_860 7

Definition at line 69 of file elf.h.

#define EM_88K 5

Definition at line 68 of file elf.h.

#define EM_M32 1

Definition at line 64 of file elf.h.

#define EM_MIPS 8

Definition at line 70 of file elf.h.

#define EM_NONE 0

Definition at line 63 of file elf.h.

#define EM_SPARC 2

Definition at line 65 of file elf.h.

#define ET_CORE 4

Definition at line 57 of file elf.h.

#define ET_DYN 3

Definition at line 56 of file elf.h.

Referenced by elf_loadfile().

#define ET_EXEC 2

Definition at line 55 of file elf.h.

Referenced by elf_loadfile(), and sys_exec().

#define ET_HIPROC 0xffff

Definition at line 59 of file elf.h.

#define ET_LOPROC 0xff00

Definition at line 58 of file elf.h.

#define ET_NONE 0

Definition at line 53 of file elf.h.

#define ET_REL 1

Definition at line 54 of file elf.h.

#define EV_CURRENT 1

Definition at line 75 of file elf.h.

#define EV_NONE 0

Definition at line 74 of file elf.h.

#define PT_DYNAMIC 2

Definition at line 81 of file elf.h.

Referenced by kmod_load(), ldEnable(), and sysExec().

#define PT_GNU_EH_FRAME 0x6474e550

Definition at line 90 of file elf.h.

#define PT_GNU_RELRO (PT_LOOS + 0x474e552)

Definition at line 92 of file elf.h.

#define PT_GNU_STACK (PT_LOOS + 0x474e551)

Definition at line 91 of file elf.h.

Referenced by kmod_load(), and ldEnable().

#define PT_HIOS 0x6fffffff

Definition at line 87 of file elf.h.

#define PT_HIPROC 0x7fffffff

Definition at line 89 of file elf.h.

#define PT_INTERP 3

Definition at line 82 of file elf.h.

Referenced by sys_exec(), and sysExec().

#define PT_LOAD 1

Definition at line 80 of file elf.h.

Referenced by elf_loadfile(), kmod_load(), ldEnable(), sys_exec(), and sysExec().

#define PT_LOOS 0x60000000

Definition at line 86 of file elf.h.

#define PT_LOPROC 0x70000000

Definition at line 88 of file elf.h.

#define PT_NOTE 4

Definition at line 83 of file elf.h.

#define PT_NULL 0

Definition at line 79 of file elf.h.

#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)

Definition at line 93 of file elf.h.

Referenced by kmod_load(), and ldEnable().

#define PT_PHDR 6

Definition at line 85 of file elf.h.

Referenced by sys_exec().

#define PT_SHLIB 5

Definition at line 84 of file elf.h.

#define R_386_32 1

Definition at line 40 of file elf.h.

Referenced by kmod_load(), and ldEnable().

#define R_386_COPY 5

Definition at line 44 of file elf.h.

#define R_386_GLOB_DAT 6

Definition at line 45 of file elf.h.

#define R_386_GOT32 3

Definition at line 42 of file elf.h.

#define R_386_GOTOFF 9

Definition at line 48 of file elf.h.

#define R_386_GOTPC 10

Definition at line 49 of file elf.h.

#define R_386_JMP_SLOT 7

Definition at line 46 of file elf.h.

#define R_386_NONE 0

Definition at line 39 of file elf.h.

#define R_386_PC32 2

Definition at line 41 of file elf.h.

Referenced by kmod_load(), and ldEnable().

#define R_386_PLT32 4

Definition at line 43 of file elf.h.

#define R_386_RELATIVE 8

Definition at line 47 of file elf.h.

Referenced by kmod_load(), and ldEnable().

## Function Documentation

int elf_loadfile | ( | kTask_t * | p,
|  | const char * | file,
|  | u_int32_t * | addr,
|  | u_int32_t * | entry |
| ) |  |  |

Definition at line 111 of file elf.c.

References _current, elfHeader::eEntry, elfHeader::eIdent, elfHeader::ePhnum, elfHeader::ePhoff, ET_DYN, ET_EXEC, elfHeader::eType, fclose(), fopen(), fread(), fseek(), taskStruct::id, K_PANIC, kfree(), kmalloc(), kprintf(), memset(), PAGE_DEFAULT, PAGE_PRESENT, PAGE_USER, elfProgramHeader::phMemsz, elfProgramHeader::phVaddr, PT_LOAD, vmm_remapPage(), vmm_setPageAttributes(), vmmFindFreePage(), and x1000.

Here is the call graph for this function:

char* elfGetPhType | ( | int |  | ) |

Definition at line 103 of file elf.c.

References elfPhType, and phTypeName.

char* elfGetRelType | ( | int |  | ) |

Definition at line 107 of file elf.c.

References elfRelType, and relTypeName.

Referenced by kmod_load(), and ldEnable().

char* elfGetShType | ( | int |  | ) |

Definition at line 99 of file elf.c.

References elfShType, and shTypeName.