changeset 19:06d03083acd4

added ELF file structs & defines
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Wed, 27 Apr 2011 10:45:13 -0400
parents f219716c6b54
children 175279b7d3d7
files include/elf.h
diffstat 1 files changed, 88 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/elf.h	Wed Apr 27 10:45:13 2011 -0400
@@ -0,0 +1,88 @@
+#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