view include/elf.h @ 99:2a0aa3efc228

The shell script will now theroretically load the program into memory, will not run it. The shell script loads a program into memory and displays the address but as of now does not jump to it (though it does display the address it would jump to) Added a memset function Added a python script (credit for its writing to Jeff) that sets up a filesystem
author Jonathan Pevarnek <pevarnj@gmail.com>
date Sat, 14 May 2011 19:40:18 -0400
parents 06d03083acd4
children
line wrap: on
line source

#ifndef __ELF_H
#define __ELF_H

#define EI_MAG0		0
#define EI_MAG1		1
#define EI_MAG2		2
#define EI_MAG3		3
#define EI_CLASS	4
#define EI_DATA		5
#define EI_VERSION	6
#define EI_OSABI	7
#define EI_ABIVERSION	8
#define EI_PAD		9
#define EI_NIDENT	16

#define ELFMAG0		0x7f
#define ELFMAG1		'E'
#define ELFMAG2		'L'
#define ELFMAG3		'F'

#define ELFCLASS64	2

#define ELFDATA2MSB	2

#define EV_CURRENT	1

#define ELFOSABI_NONE	0

#define ET_EXEC		2

#define EM_S390		22

#define PT_NULL		0
#define PT_LOAD		1
#define PT_DYNAMIC	2
#define PT_INTERP	3
#define PT_NOTE		4
#define PT_SHLIB	5
#define PT_PHDR		6
#define PT_TLS		7

#define PF_X		0x1
#define PF_W		0x2
#define PF_R		0x4

typedef u64 Elf64_Addr;
typedef u64 Elf64_Off;
typedef u16 Elf64_Half;
typedef u32 Elf64_Word;
typedef s32 Elf64_Sword;
typedef u64 Elf64_Xword;
typedef s64 Elf64_Sxword;

/*
 * ELF file header
 */
typedef struct {
	unsigned char   e_ident[EI_NIDENT];	/* ELF identification */
	Elf64_Half      e_type;			/* Object file type */
	Elf64_Half      e_machine;		/* Machine type */
	Elf64_Word      e_version;		/* Object file version */
	Elf64_Addr      e_entry;		/* Entry point address */
	Elf64_Off       e_phoff;		/* Program header offset */
	Elf64_Off       e_shoff;		/* Section header offset */
	Elf64_Word      e_flags;		/* Processor-specific flags */
	Elf64_Half      e_ehsize;		/* ELF header size */
	Elf64_Half      e_phentsize;		/* Size of program header entry */
	Elf64_Half      e_phnum;		/* Number of program header entries */
	Elf64_Half      e_shentsize;		/* Size of section header entries */
	Elf64_Half      e_shnum;		/* Number of section header entries */
	Elf64_Half      e_shstrndx;		/* Section name string table index */
} Elf64_Ehdr;

/*
 * ELF program header
 */
typedef struct {
	Elf64_Word	p_type;			/* Segment type */
	Elf64_Word	p_flags;		/* Segment file offset */
	Elf64_Off	p_offset;		/* Segment virt. addr */
	Elf64_Addr	p_vaddr;		/* <undefined> */
	Elf64_Addr	p_paddr;		/* Segment size in file */
	Elf64_Xword	p_filesz;		/* Segment size in mem */
	Elf64_Xword	p_memsz;		/* Segment flags */
	Elf64_Xword	p_align;		/* Segment alignment */
} Elf64_Phdr;

#endif