Initial commit

This commit is contained in:
bdbrd 2025-10-22 15:51:24 +02:00
commit cbc51f523e
125 changed files with 34817 additions and 0 deletions

43
src/elf/elf.h Normal file
View file

@ -0,0 +1,43 @@
#include <stdint.h>
typedef uint64_t elf64_addr;
typedef uint64_t elf64_off;
typedef uint16_t elf64_half;
typedef uint32_t elf64_word;
typedef int32_t elf64_sword;
typedef uint64_t elf64_xword;
typedef int64_t elf64_sxword;
# define ELFMAG0 0x7F // e_ident[EI_MAG0]
# define ELFMAG1 'E' // e_ident[EI_MAG1]
# define ELFMAG2 'L' // e_ident[EI_MAG2]
# define ELFMAG3 'F' // e_ident[EI_MAG3]
typedef struct elf64_ehdr {
uint8_t e_ident[16];
elf64_half e_type;
elf64_half e_machine;
elf64_word e_version;
elf64_addr e_entry;
elf64_off e_phoff;
elf64_off e_shoff;
elf64_word e_flags;
elf64_half e_ehsize;
elf64_half e_phentsize;
elf64_half e_phnum;
elf64_half e_shentsize;
elf64_half e_shnum;
elf64_half e_shstrndx;
}__attribute((packed))elf64_ehdr;
enum e_ident{
EI_MAG0 = 0, // 0x7F
EI_MAG1 = 1, // 'E'
EI_MAG2 = 2, // 'L'
EI_MAG3 = 3, // 'F'
EI_CLASS = 4, // Architecture (32/64)
EI_DATA = 5, // Byte Order
EI_VERSION = 6, // ELF Version
EI_OSABI = 7, // OS Specific
EI_ABIVERSION = 8, // OS Specific
EI_PAD = 9 // Padding
};