shithub: elf-loader

ref: e5e12f806ecf322946c093fe59d909beb9160d0c
dir: /sys/include/elf.h/

View raw version
typedef struct Elfhdr	Elfhdr;
typedef struct Elfphdr	Elfphdr;

#define ELF_MAGIC	0x7f454c46

enum {
	EI_NIDENT	= 16,

	EM_X86_64	= 62,
	EM_AARCH64	= 183,
};

struct Elfhdr {
	uchar	ident[16];
	u16int	type;
	u16int	machine;
	u32int	version;
	usize	entry;
	usize	phoff;
	usize	shoff;
	u32int	flags;
	u16int	ehsize;
	u16int	phentsize;
	u16int	phnum;
	u16int	shentsize;
	u16int	shnum;
	u16int	shstrndx;
};

struct Elfphdr {
	u32int	type;
	u32int	flags;
	usize	off;
	usize	vaddr;
	usize	paddr;
	usize	filesz;
	usize	memsz;
	usize	align;
};

enum {
	PT_LOAD	= 1,

	PF_X	= 1<<0,
	PF_W	= 1<<1,
	PF_R	= 1<<2,
};