Index: trunk/kernel/libk/elf.h
===================================================================
--- trunk/kernel/libk/elf.h	(revision 204)
+++ trunk/kernel/libk/elf.h	(revision 227)
@@ -28,38 +28,30 @@
  */
 
-/* Type for a 16-bit quantity. */
+#define EI_NIDENT (16)
+
+/* 32bit version */
 typedef uint16_t Elf32_Half;
-
-/* Types for signed and unsigned 32-bit quantities. */
 typedef uint32_t Elf32_Word;
-typedef	int32_t  Elf32_Sword;
-
-/* Type of addresses. */
+typedef int32_t  Elf32_Sword;
 typedef uint32_t Elf32_Addr;
-
-/* Type of file offsets. */
 typedef uint32_t Elf32_Off;
 
-/* Type for section indices, which are 16-bit quantities. */
-typedef uint16_t Elf32_Section;
-
-/* Type for version symbol information. */
-typedef Elf32_Half Elf32_Versym;
-
-/*************************************************************************************
- * This structure defines the ELF file header (first bytes in the file)
- *************************************************************************************/
-
-#define EI_NIDENT (16)
-
-typedef struct
-{
-	unsigned char	e_ident[EI_NIDENT];	/* Magic number and other info */
+/* 64bit version */
+typedef uint16_t Elf64_Half;
+typedef uint32_t Elf64_Word;
+typedef int32_t	 Elf64_Sword;
+typedef uint64_t Elf64_Addr;
+typedef uint64_t Elf64_Off;
+
+/* ELF header - 32bit version. */
+typedef struct
+{
+	unsigned char   e_ident[EI_NIDENT]; /* Magic number and other info */
 	Elf32_Half      e_type;             /* Object file type */
 	Elf32_Half      e_machine;          /* Architecture */
 	Elf32_Word      e_version;          /* Object file version */
-	Elf32_Addr	    e_entry;            /* Entry point virtual address */
-	Elf32_Off	    e_phoff;            /* Program header table file offset */
-	Elf32_Off	    e_shoff;            /* Section header table file offset */
+	Elf32_Addr      e_entry;            /* Entry point virtual address */
+	Elf32_Off       e_phoff;            /* Program header table file offset */
+	Elf32_Off       e_shoff;            /* Section header table file offset */
 	Elf32_Word      e_flags;            /* Processor-specific flags */
 	Elf32_Half      e_ehsize;           /* ELF header size in bytes */
@@ -71,4 +63,24 @@
 }
 Elf32_Ehdr;
+
+/* ELF header - 64bit version. */
+typedef struct
+{
+	unsigned char   e_ident[EI_NIDENT]; /* Magic number and other info */
+	Elf64_Half      e_type;	            /* Object file type */
+	Elf64_Half      e_machine;          /* Architecture */
+	Elf64_Word      e_version;          /* Object file version */
+	Elf64_Addr      e_entry;            /* Entry point virtual address */
+	Elf64_Off       e_phoff;            /* Program header table file offset */
+	Elf64_Off       e_shoff;            /* Section header table file offset */
+	Elf64_Word      e_flags;            /* Processor-specific flags */
+	Elf64_Half      e_ehsize;           /* ELF header size in bytes */
+	Elf64_Half      e_phentsize;        /* Program header table entry size */
+	Elf64_Half      e_phnum;            /* Program header table entry count */
+	Elf64_Half      e_shentsize;        /* Section header table entry size */
+	Elf64_Half      e_shnum;            /* Section header table entry count */
+	Elf64_Half      e_shstrndx;	        /* Section header string table index */
+}
+Elf64_Ehdr;
 
 /*
@@ -132,18 +144,31 @@
 #define EV_NUM		2
 
-/* Program segment header.  */
-
-typedef struct
-{
-	Elf32_Word	p_type;		/* Segment type */
-	Elf32_Off	p_offset;	/* Segment file offset */
-	Elf32_Addr	p_vaddr;	/* Segment virtual address */
-	Elf32_Addr	p_paddr;	/* Segment physical address */
-	Elf32_Word	p_filesz;	/* Segment size in file */
-	Elf32_Word	p_memsz;	/* Segment size in memory */
-	Elf32_Word	p_flags;	/* Segment flags */
-	Elf32_Word	p_align;    /* Segment alignment */
+/* Program segment header - 32bit version. */
+typedef struct
+{
+	Elf32_Word  p_type;     /* Segment type */
+	Elf32_Off   p_offset;   /* Segment file offset */
+	Elf32_Addr  p_vaddr;    /* Segment virtual address */
+	Elf32_Addr  p_paddr;    /* Segment physical address */
+	Elf32_Word  p_filesz;   /* Segment size in file */
+	Elf32_Word  p_memsz;    /* Segment size in memory */
+	Elf32_Word  p_flags;    /* Segment flags */
+	Elf32_Word  p_align;    /* Segment alignment */
 }
 Elf32_Phdr;
+
+/* Program segment header - 64bit version. */
+typedef struct
+{
+	Elf64_Word  p_type;     /* Segment type */
+	Elf64_Word  p_flags;    /* Segment flags */
+	Elf64_Off   p_offset;   /* Segment file offset */
+	Elf64_Addr  p_vaddr;    /* Segment virtual address */
+	Elf64_Addr  p_paddr;    /* Segment physical address */
+	Elf64_Word  p_filesz;   /* Segment size in file */
+	Elf64_Word  p_memsz;    /* Segment size in memory */
+	Elf64_Word  p_align;    /* Segment alignment */
+}
+Elf64_Phdr;
 
 /* Legal values for p_type (segment type).  */
@@ -176,4 +201,23 @@
 #define PF_MASKPROC	0xf0000000	/* Processor-specific */
 
+#if defined(HAL_32BIT)
+#define Elf_Half  Elf32_Half
+#define Elf_Word  Elf32_Word
+#define Elf_Sword Elf32_Sword
+#define Elf_Addr  Elf32_Addr
+#define Elf_Off   Elf32_Off
+#define Elf_Ehdr  Elf32_Ehdr
+#define Elf_Phdr  Elf32_Phdr
+#elif defined (HAL_64BIT)
+#define Elf_Half  Elf64_Half
+#define Elf_Word  Elf64_Word
+#define Elf_Sword Elf64_Sword
+#define Elf_Addr  Elf64_Addr
+#define Elf_Off   Elf64_Off
+#define Elf_Ehdr  Elf64_Ehdr
+#define Elf_Phdr  Elf64_Phdr
+#else
+#error "Must define HAL_64BIT/HAL_32BIT"
+#endif
 
 /****************************************************************************************
