|
Voxia OS v0.0.1
Hobby Project Operating System Targeting x86-64
|
#include "hal/cpu/paging.h"#include "libk/math.h"#include "libk/serial.h"#include "libk/symbols.h"#include "memory/memory_utils.h"#include "memory/phys_base_allocator.h"#include "memory/vm_manager.h"#include <libk/executable/elf.h>#include <str.h>#include <type.h>#include <vector.h>Go to the source code of this file.
Variables | |
| boolean_t | elf_has_running = 0 |
| uintptr_t | rip_before_run_elf = 0 |
| void elf_call_init_array | ( | elf_section_map * | map, |
| uintptr_t | base ) |
Definition at line 680 of file elf.c.
References base, count, LOG2_DEBUG, LOG2_INFO, map, Elf64_Shdr::sh_addr, and Elf64_Shdr::sh_size.
Referenced by proccess_elf().
| void elf_call_init_array_with_table | ( | elf_section_map * | map, |
| struct elf_load_mmap_table * | table, | ||
| int | table_count ) |
Definition at line 699 of file elf.c.
References count, elf_roffset_to_kernel_ptr(), map, serial2_printf(), and table.
Definition at line 629 of file elf.c.
References ALIGN_UP, ASSUME_ALIGNED, BLOCK_SIZE, data, Elf64_Ehdr::e_phentsize, Elf64_Ehdr::e_phnum, Elf64_Ehdr::e_phoff, Elf64_Ehdr::e_version, ELF_PTR, LOG2_INFO, max(), Elf64_Phdr::p_memsz, Elf64_Phdr::p_type, Elf64_Phdr::p_vaddr, and PT_LOAD.
Referenced by execve(), and proccess_elf().
| void elf_dyn_map_all | ( | Elf64_Dyn * | dyn, |
| uint8_t * | data, | ||
| elf_dynamic_map * | map ) |
Definition at line 60 of file elf.c.
References ASSUME_ALIGNED, Elf64_Dyn::d_ptr, Elf64_Dyn::d_tag, Elf64_Dyn::d_un, Elf64_Dyn::d_val, data, DT_HASH, DT_JMPREL, DT_NEEDED, DT_NULL, DT_PLTGOT, DT_PLTRELSZ, DT_RELA, DT_RELAENT, DT_RELASZ, DT_STRTAB, DT_SYMTAB, Elf64_Ehdr::e_phnum, Elf64_Ehdr::e_phoff, ELF_PTR, hash, LOG2_INFO, map, offset, Elf64_Phdr::p_memsz, Elf64_Phdr::p_offset, Elf64_Phdr::p_vaddr, PTR_ADD, vaddr_to_file_offset(), vector_init, and vector_push_back.
Referenced by execve(), and proccess_elf().
Definition at line 17 of file elf.c.
References ASSUME_ALIGNED, data, Elf64_Ehdr::e_phentsize, Elf64_Ehdr::e_phnum, Elf64_Ehdr::e_phoff, Elf64_Phdr::p_offset, Elf64_Phdr::p_type, Elf64_Phdr::p_vaddr, PT_LOAD, and PTR_ADD.
| uintptr_t elf_find_symbol | ( | const char * | name, |
| GnuHashHeader * | gnuhash, | ||
| uintptr_t | base, | ||
| elf_section_map * | map, | ||
| uint8_t * | data ) |
Definition at line 730 of file elf.c.
References base, data, elf_gnu_lookup(), LOG2_INFO, LOG2_WARN, map, name, name_len, Elf64_Sym::st_name, Elf64_Sym::st_value, strlen(), and strncmp().
Referenced by proccess_elf().
Definition at line 255 of file elf.c.
References ASSUME_ALIGNED, base, data, and Elf64_Ehdr::e_entry.
Definition at line 45 of file elf.c.
References ASSUME_ALIGNED, data, Elf64_Ehdr::e_phentsize, Elf64_Ehdr::e_phnum, Elf64_Ehdr::e_phoff, NULL, Elf64_Phdr::p_offset, Elf64_Phdr::p_type, PT_DYNAMIC, and PTR_ADD.
Referenced by execve(), and proccess_elf().
| void elf_get_symbol | ( | const char * | sym_name, |
| uintptr_t | base, | ||
| elf_section_map * | map, | ||
| uint8_t * | data, | ||
| symbols_ptr_vector_t * | syms, | ||
| boolean_t | skip_empty_val ) |
Definition at line 653 of file elf.c.
References base, data, symbols::items, kalloc(), map, symbols::name, symbols_item::name, Elf64_Sym::st_name, Elf64_Sym::st_value, symbols_item::value, vector_init, and vector_push_back.
|
static |
| void elf_gnu_hash_parse | ( | GnuHashHeader * | gnu_hash, |
| Elf64_Shdr * | gnu_hash_sym, | ||
| uint8_t * | data ) |
Definition at line 604 of file elf.c.
References ASSUME_ALIGNED, GnuHashHeader::bloom, GnuHashHeader::bloom_shift, GnuHashHeader::bloom_size, GnuHashHeader::buckets, GnuHashHeader::chains, data, memcopy(), memset(), GnuHashHeader::nbuckets, ptr, Elf64_Shdr::sh_offset, and GnuHashHeader::symoffset.
Referenced by execve(), and proccess_elf().
| Elf64_Sym * elf_gnu_lookup | ( | const char * | name, |
| GnuHashHeader * | gh, | ||
| Elf64_Sym * | symtab, | ||
| const char * | strtab ) |
Definition at line 578 of file elf.c.
References GnuHashHeader::buckets, GnuHashHeader::chains, elf_gnu_hash(), elf_gnu_maybe_present(), hash, idx, name, name_len, GnuHashHeader::nbuckets, NULL, Elf64_Sym::st_name, strlen(), strncmp(), and GnuHashHeader::symoffset.
Referenced by elf_find_symbol(), and elf_relocate_rel().
|
static |
Definition at line 571 of file elf.c.
References GnuHashHeader::bloom, GnuHashHeader::bloom_shift, GnuHashHeader::bloom_size, and hash.
Referenced by elf_gnu_lookup().
| size_t elf_load | ( | volatile uintptr_t * | page, |
| uint8_t * | data, | ||
| uintptr_t | temporary_base, | ||
| uintptr_t | base, | ||
| struct elf_load_mmap_table * | table ) |
Definition at line 261 of file elf.c.
References ALIGN_DOWN, ASSUME_ALIGNED, base, BLOCK_SIZE, data, Elf64_Ehdr::e_entry, Elf64_Ehdr::e_phentsize, Elf64_Ehdr::e_phnum, Elf64_Ehdr::e_phoff, Elf64_Ehdr::e_version, elf_pflags_to_page_flags(), ELF_PTR, get_kernel_vmm_page(), LOG2_INFO, max(), memcopy(), memset(), Elf64_Phdr::p_filesz, Elf64_Phdr::p_flags, Elf64_Phdr::p_memsz, Elf64_Phdr::p_offset, Elf64_Phdr::p_type, Elf64_Phdr::p_vaddr, page, paging_get_highest_page_map(), phys_base_alloc(), PT_LOAD, table, vma_lookup_free_vaddr(), VMA_REGION_B, and vxMultipleMmap().
Referenced by execve(), and proccess_elf().
| void elf_mmap_got | ( | volatile uintptr_t * | page, |
| elf_section_map * | map, | ||
| uintptr_t | base ) |
Definition at line 231 of file elf.c.
References ALIGN_DOWN, ALIGN_UP, base, LOG2_INFO, map, page, PAGE_NO_EXECUTE, PAGE_PRESENT, PAGE_SIZE, PAGE_USER, PAGE_WRITABLE, phys_addr, phys_base_alloc(), and vxMultipleMmap().
Definition at line 216 of file elf.c.
References flags, PAGE_NO_EXECUTE, PAGE_PRESENT, PAGE_USER, PAGE_WRITABLE, PF_R, PF_W, and PF_X.
Referenced by elf_load().
| void elf_relocate_dyn | ( | elf_dynamic_map * | map, |
| uintptr_t | kernel_base, | ||
| uintptr_t | user_base, | ||
| GnuHashHeader * | gnu_hash, | ||
| symbols_ptr_vector_t * | external_syms, | ||
| struct elf_load_mmap_table * | table, | ||
| int | table_count ) |
Definition at line 534 of file elf.c.
References count, elf_relocate_rel(), LOG2_INFO, map, serial2_printf(), and table.
Referenced by execve(), and proccess_elf().
|
static |
Definition at line 373 of file elf.c.
References ELF64_R_SYM, ELF64_R_TYPE, elf_gnu_lookup(), elf_resolve_external_symbol(), elf_roffset_to_kernel_ptr(), LOG2_DEBUG, LOG2_WARN, memcopy(), name, Elf64_Rela::r_addend, Elf64_Rela::r_offset, R_X86_64_32, R_X86_64_32S, R_X86_64_64, R_X86_64_COPY, R_X86_64_DTPMOD64, R_X86_64_DTPOFF32, R_X86_64_DTPOFF64, R_X86_64_GLOB_DAT, R_X86_64_GOTTPOFF, R_X86_64_IRELATIVE, R_X86_64_JUMP_SLOT, R_X86_64_PC32, R_X86_64_RELATIVE, R_X86_64_TLSGD, R_X86_64_TLSLD, R_X86_64_TPOFF32, R_X86_64_TPOFF64, Elf64_Sym::st_name, Elf64_Sym::st_size, Elf64_Sym::st_value, table, type, and value.
Referenced by elf_relocate_dyn().
|
static |
Definition at line 332 of file elf.c.
References vector_symbols_ptr::data, symbols::items, name, name_len, vector_symbols_ptr::size, strlen(), strncmp(), and vector.
Referenced by elf_relocate_rel().
|
static |
Definition at line 349 of file elf.c.
References BLOCK_SIZE, and table.
Referenced by elf_call_init_array_with_table(), and elf_relocate_rel().
| void elf_section_map_all | ( | uint8_t * | data, |
| elf_section_map * | map ) |
Definition at line 160 of file elf.c.
References ASSUME_ALIGNED, data, Elf64_Ehdr::e_shnum, Elf64_Ehdr::e_shoff, Elf64_Ehdr::e_shstrndx, LOG2_INFO, map, Elf64_Shdr::sh_addr, Elf64_Shdr::sh_name, Elf64_Shdr::sh_offset, Elf64_Shdr::sh_size, Elf64_Shdr::sh_type, SHT_FINI_ARRAY, SHT_GNU_HASH, SHT_INIT_ARRAY, SHT_PROGBITS, SHT_RELA, SHT_STRTAB, SHT_SYMTAB, and strncmp().
Referenced by execve(), INIT(), and proccess_elf().
|
static |
Definition at line 32 of file elf.c.
References Elf64_Ehdr::e_phnum, LOG2_WARN, Elf64_Phdr::p_filesz, Elf64_Phdr::p_offset, Elf64_Phdr::p_type, Elf64_Phdr::p_vaddr, and PT_LOAD.
Referenced by elf_dyn_map_all().
| boolean_t elf_has_running = 0 |
Definition at line 14 of file elf.c.
Referenced by virtio_irq().
| uintptr_t rip_before_run_elf = 0 |
Definition at line 15 of file elf.c.
Referenced by virtio_irq().