KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
elf.h File Reference

ELF binary loading support. More...

#include <kos/cdefs.h>
#include <stdint.h>
#include <sys/queue.h>
#include <kos/regfield.h>

Go to the source code of this file.

Data Structures

struct  elf_hdr_t
 ELF file header. More...
 
struct  elf_shdr_t
 ELF Section header. More...
 
struct  elf_sym_t
 Symbol table entry. More...
 
struct  elf_rela_t
 ELF Relocation entry (with explicit addend). More...
 
struct  elf_rel_t
 ELF Relocation entry (without explicit addend). More...
 
struct  elf_prog_t
 Kernel-specific definition of a loaded ELF binary. More...
 

Macros

#define EI_MAG0   0
 File identification: 0x7f.
 
#define EI_MAG1   1
 File identification: 'E'.
 
#define EI_MAG2   2
 File identification: 'L'.
 
#define EI_MAG3   3
 File identification: 'F'.
 
#define EI_CLASS   4
 File class (32/64-bit)
 
#define EI_DATA   5
 Data encoding (LSB/MSB)
 
#define EI_VERSION   6
 File version (must be 1)
 
#define EI_OSABI   7
 Operating System/ABI identification.
 
#define EI_ABIVERSION   8
 ABI version.
 
#define EI_PAD   9
 Start of padding bytes.
 
#define EI_NIDENT   16
 Size of elf_hdr::ident.
 
#define ELFCLASSNONE   0
 Invalid class.
 
#define ELFCLASS32   1
 32-bit objects
 
#define ELFCLASS64   2
 64-bit objects
 
#define ELFDATANONE   0
 Invalid encoding.
 
#define ELFDATA2LSB   1
 2's complement, little endian
 
#define ELFDATA2MSB   2
 2's complement, big Endian
 
#define EV_NONE   0
 Invalid version.
 
#define EV_CURRENT   1
 Current version.
 
#define EM_386   3
 x86 (IA32)
 
#define EM_PPC   20
 PowerPC.
 
#define EM_ARM   40
 ARM.
 
#define EM_SH   42
 SuperH.
 
#define SHT_NULL   0
 Inactive section.
 
#define SHT_PROGBITS   1
 Program code/data.
 
#define SHT_SYMTAB   2
 Full symbol table.
 
#define SHT_STRTAB   3
 String table.
 
#define SHT_RELA   4
 Relocation table, with addends.
 
#define SHT_HASH   5
 Symbol hash table.
 
#define SHT_DYNAMIC   6
 Dynamic linking info.
 
#define SHT_NOTE   7
 Notes section.
 
#define SHT_NOBITS   8
 A section that occupies no space in the file.
 
#define SHT_REL   9
 Relocation table, no addends.
 
#define SHT_SHLIB   10
 Reserved.
 
#define SHT_DYNSYM   11
 Dynamic linker symbol table.
 
#define SHT_INIT_ARRAY   14
 Array of constructors.
 
#define SHT_FINI_ARRAY   15
 Array of destructors.
 
#define SHT_PREINIT_ARRAY   16
 Array of pre-constructors.
 
#define SHT_GROUP   17
 Section group.
 
#define SHT_SYMTAB_SHNDX   18
 Extended section indices.
 
#define SHT_NUM   19
 Number of defined types.
 
#define SHT_LOPROC   0x70000000
 Start of processor specific types.
 
#define SHT_HIPROC   0x7fffffff
 End of processor specific types.
 
#define SHT_LOUSER   0x80000000
 Start of program specific types.
 
#define SHT_HIUSER   0xffffffff
 End of program specific types.
 
#define SHF_WRITE   BIT(0)
 Writable data.
 
#define SHF_ALLOC   BIT(1)
 Resident.
 
#define SHF_EXECINSTR   BIT(2)
 Executable instructions.
 
#define SHF_MERGE   BIT(4)
 Might be merged.
 
#define SHF_STRINGS   BIT(5)
 Contains nul-terminated strings.
 
#define SHF_INFO_LINK   BIT(6)
 ‘sh_info’ contains SHT index
 
#define SHF_LINK_ORDER   BIT(7)
 Preserve order after combining.
 
#define SHF_GROUP   BIT(9)
 Section is member of a group.
 
#define SHF_TLS   BIT(10)
 Section hold thread-local data.
 
#define SHF_MASKPROC   0xf0000000
 Processor specific mask.
 
#define SHN_UNDEF   0
 Undefined, missing, irrelevant.
 
#define SHN_ABS   0xfff1
 Absolute values.
 
#define STB_LOCAL   0
 Local (non-exported) symbol.
 
#define STB_GLOBAL   1
 Global (exported) symbol.
 
#define STB_WEAK   2
 Weak-linked symbol.
 
#define STT_NOTYPE   0
 Symbol has no type.
 
#define STT_OBJECT   1
 Symbol is an object.
 
#define STT_FUNC   2
 Symbol is a function.
 
#define STT_SECTION   3
 Symbol is a section.
 
#define STT_FILE   4
 Symbol is a file name.
 
#define ELF32_ST_BIND(info)
 Retrieve the binding type for a symbol.
 
#define ELF32_ST_TYPE(info)
 Retrieve the symbol type for a symbol.
 
#define R_SH_DIR32   1
 SuperH: Rel = Symbol + Addend.
 
#define R_386_32   1
 x86: Rel = Symbol + Addend
 
#define R_386_PC32   2
 x86: Rel = Symbol + Addend - Value
 
#define ELF32_R_SYM(i)
 Retrieve the symbol index from a relocation entry.
 
#define ELF32_R_TYPE(i)
 Retrieve the relocation type from a relocation entry.
 

Functions

int elf_load (const char *fn, struct klibrary *shell, elf_prog_t *out)
 Load an ELF binary.
 
void elf_free (elf_prog_t *prog)
 Free a loaded ELF program.
 

Detailed Description

ELF binary loading support.

This file contains the support functionality for loading ELF binaries in KOS. This includes the various header structures and whatnot that are used in ELF files to store code/data/relocations/etc. This isn't necessarily meant for running multiple processes, but more for loadable library support within KOS.

Author
Megan Potter