Index: /trunk/include/iprt/formats/elf-amd64.h
===================================================================
--- /trunk/include/iprt/formats/elf-amd64.h	(revision 58636)
+++ /trunk/include/iprt/formats/elf-amd64.h	(revision 58636)
@@ -0,0 +1,128 @@
+/*-
+ * Copyright (c) 1996-1997 John D. Polstra.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef ___iprt_formats_elf_amd64_h
+#define	___iprt_formats_elf_amd64_h
+
+/*
+ * ELF definitions for the AMD64 architecture.
+ */
+
+#if 0 /* later */
+/*
+ * Auxiliary vector entries for passing information to the interpreter.
+ *
+ * The i386 supplement to the SVR4 ABI specification names this "auxv_t",
+ * but POSIX lays claim to all symbols ending with "_t".
+ */
+typedef struct {	/* Auxiliary vector entry on initial stack */
+	int	a_type;			/* Entry type. */
+	union {
+		int	a_val;		/* Integer value. */
+	} a_un;
+} Elf32_Auxinfo;
+
+
+typedef struct {	/* Auxiliary vector entry on initial stack */
+	long	a_type;			/* Entry type. */
+	union {
+		long	a_val;		/* Integer value. */
+		void	*a_ptr;		/* Address. */
+		void	(*a_fcn)(void);	/* Function pointer (not used). */
+	} a_un;
+} Elf64_Auxinfo;
+
+__ElfType(Auxinfo);
+
+/* Values for a_type. */
+#define	AT_NULL		0	/* Terminates the vector. */
+#define	AT_IGNORE	1	/* Ignored entry. */
+#define	AT_EXECFD	2	/* File descriptor of program to load. */
+#define	AT_PHDR		3	/* Program header of program already loaded. */
+#define	AT_PHENT	4	/* Size of each program header entry. */
+#define	AT_PHNUM	5	/* Number of program header entries. */
+#define	AT_PAGESZ	6	/* Page size in bytes. */
+#define	AT_BASE		7	/* Interpreter's base address. */
+#define	AT_FLAGS	8	/* Flags (unused for i386). */
+#define	AT_ENTRY	9	/* Where interpreter should transfer control. */
+
+/*
+ * The following non-standard values are used for passing information
+ * from John Polstra's testbed program to the dynamic linker.  These
+ * are expected to go away soon.
+ *
+ * Unfortunately, these overlap the Linux non-standard values, so they
+ * must not be used in the same context.
+ */
+#define	AT_BRK		10	/* Starting point for sbrk and brk. */
+#define	AT_DEBUG	11	/* Debugging level. */
+
+/*
+ * The following non-standard values are used in Linux ELF binaries.
+ */
+#define	AT_NOTELF	10	/* Program is not ELF ?? */
+#define	AT_UID		11	/* Real uid. */
+#define	AT_EUID		12	/* Effective uid. */
+#define	AT_GID		13	/* Real gid. */
+#define	AT_EGID		14	/* Effective gid. */
+
+#define	AT_COUNT	15	/* Count of defined aux entry types. */
+
+#endif /* later */
+
+/*
+ * Relocation types.
+ */
+
+#define	R_X86_64_NONE	0	/* No relocation. */
+#define	R_X86_64_64	1	/* Add 64 bit symbol value. */
+#define	R_X86_64_PC32	2	/* PC-relative 32 bit signed sym value. */
+#define	R_X86_64_GOT32	3	/* PC-relative 32 bit GOT offset. */
+#define	R_X86_64_PLT32	4	/* PC-relative 32 bit PLT offset. */
+#define	R_X86_64_COPY	5	/* Copy data from shared object. */
+#define	R_X86_64_GLOB_DAT 6	/* Set GOT entry to data address. */
+#define	R_X86_64_JMP_SLOT 7	/* Set GOT entry to code address. */
+#define	R_X86_64_RELATIVE 8	/* Add load address of shared object. */
+#define	R_X86_64_GOTPCREL 9	/* Add 32 bit signed pcrel offset to GOT. */
+#define	R_X86_64_32	10	/* Add 32 bit zero extended symbol value */
+#define	R_X86_64_32S	11	/* Add 32 bit sign extended symbol value */
+#define	R_X86_64_16	12	/* Add 16 bit zero extended symbol value */
+#define	R_X86_64_PC16	13	/* Add 16 bit signed extended pc relative symbol value */
+#define	R_X86_64_8	14	/* Add 8 bit zero extended symbol value */
+#define	R_X86_64_PC8	15	/* Add 8 bit signed extended pc relative symbol value */
+#define	R_X86_64_DTPMOD64 16	/* ID of module containing symbol */
+#define	R_X86_64_DTPOFF64 17	/* Offset in TLS block */
+#define	R_X86_64_TPOFF64 18	/* Offset in static TLS block */
+#define	R_X86_64_TLSGD	19	/* PC relative offset to GD GOT entry */
+#define	R_X86_64_TLSLD	20	/* PC relative offset to LD GOT entry */
+#define	R_X86_64_DTPOFF32 21	/* Offset in TLS block */
+#define	R_X86_64_GOTTPOFF 22	/* PC relative offset to IE GOT entry */
+#define	R_X86_64_TPOFF32 23	/* Offset in static TLS block */
+
+#define	R_X86_64_COUNT	24	/* Count of defined relocation types. */
+
+#endif
+
Index: /trunk/include/iprt/formats/elf-common.h
===================================================================
--- /trunk/include/iprt/formats/elf-common.h	(revision 58636)
+++ /trunk/include/iprt/formats/elf-common.h	(revision 58636)
@@ -0,0 +1,337 @@
+/*-
+ * Copyright (c) 1998 John D. Polstra.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef ___iprt_formats_elf_common_h
+#define ___iprt_formats_elf_common_h
+
+#include <iprt/stdint.h>
+
+/*
+ * ELF definitions that are independent of architecture or word size.
+ */
+
+/*
+ * Note header.  The ".note" section contains an array of notes.  Each
+ * begins with this header, aligned to a word boundary.  Immediately
+ * following the note header is n_namesz bytes of name, padded to the
+ * next word boundary.  Then comes n_descsz bytes of descriptor, again
+ * padded to a word boundary.  The values of n_namesz and n_descsz do
+ * not include the padding.
+ */
+
+typedef struct {
+	uint32_t	n_namesz;	/* Length of name. */
+	uint32_t	n_descsz;	/* Length of descriptor. */
+	uint32_t	n_type;		/* Type of this note. */
+} Elf_Note;
+
+/* Indexes into the e_ident array.  Keep synced with
+   http://www.sco.com/developer/gabi/ch4.eheader.html */
+#define EI_MAG0		0	/* Magic number, byte 0. */
+#define EI_MAG1		1	/* Magic number, byte 1. */
+#define EI_MAG2		2	/* Magic number, byte 2. */
+#define EI_MAG3		3	/* Magic number, byte 3. */
+#define EI_CLASS	4	/* Class of machine. */
+#define EI_DATA		5	/* Data format. */
+#define EI_VERSION	6	/* ELF format version. */
+#define EI_OSABI	7	/* Operating system / ABI identification */
+#define EI_ABIVERSION	8	/* ABI version */
+#define OLD_EI_BRAND	8	/* Start of architecture identification. */
+#define EI_PAD		9	/* Start of padding (per SVR4 ABI). */
+#define EI_NIDENT	16	/* Size of e_ident array. */
+
+/* Values for the magic number bytes. */
+#define ELFMAG0		0x7f
+#define ELFMAG1		'E'
+#define ELFMAG2		'L'
+#define ELFMAG3		'F'
+#define ELFMAG		"\177ELF"	/* magic string */
+#define SELFMAG		4		/* magic string size */
+
+/* Values for e_ident[EI_VERSION] and e_version. */
+#define EV_NONE		0
+#define EV_CURRENT	1
+
+/* Values for e_ident[EI_CLASS]. */
+#define ELFCLASSNONE	0	/* Unknown class. */
+#define ELFCLASS32	1	/* 32-bit architecture. */
+#define ELFCLASS64	2	/* 64-bit architecture. */
+
+/* Values for e_ident[EI_DATA]. */
+#define ELFDATANONE	0	/* Unknown data format. */
+#define ELFDATA2LSB	1	/* 2's complement little-endian. */
+#define ELFDATA2MSB	2	/* 2's complement big-endian. */
+
+/* Values for e_ident[EI_OSABI]. */
+#define ELFOSABI_SYSV		0	/* UNIX System V ABI */
+#define ELFOSABI_NONE		ELFOSABI_SYSV	/* symbol used in old spec */
+#define ELFOSABI_HPUX		1	/* HP-UX operating system */
+#define ELFOSABI_NETBSD		2	/* NetBSD */
+#define ELFOSABI_LINUX		3	/* GNU/Linux */
+#define ELFOSABI_HURD		4	/* GNU/Hurd */
+#define ELFOSABI_86OPEN		5	/* 86Open common IA32 ABI */
+#define ELFOSABI_SOLARIS	6	/* Solaris */
+#define ELFOSABI_MONTEREY	7	/* Monterey */
+#define ELFOSABI_IRIX		8	/* IRIX */
+#define ELFOSABI_FREEBSD	9	/* FreeBSD */
+#define ELFOSABI_TRU64		10	/* TRU64 UNIX */
+#define ELFOSABI_MODESTO	11	/* Novell Modesto */
+#define ELFOSABI_OPENBSD	12	/* OpenBSD */
+#define ELFOSABI_ARM		97	/* ARM */
+#define ELFOSABI_STANDALONE	255	/* Standalone (embedded) application */
+
+/* e_ident */
+#define IS_ELF(ehdr)	((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
+			 (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
+			 (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
+			 (ehdr).e_ident[EI_MAG3] == ELFMAG3)
+
+/* Values for e_type. */
+#define ET_NONE		0	/* Unknown type. */
+#define ET_REL		1	/* Relocatable. */
+#define ET_EXEC		2	/* Executable. */
+#define ET_DYN		3	/* Shared object. */
+#define ET_CORE		4	/* Core file. */
+
+/* Values for e_machine. */
+#define EM_NONE		0	/* Unknown machine. */
+#define EM_M32		1	/* AT&T WE32100. */
+#define EM_SPARC	2	/* Sun SPARC. */
+#define EM_386		3	/* Intel i386. */
+#define EM_68K		4	/* Motorola 68000. */
+#define EM_88K		5	/* Motorola 88000. */
+#define EM_486		6	/* Intel i486. */
+#define EM_860		7	/* Intel i860. */
+#define EM_MIPS		8	/* MIPS R3000 Big-Endian only */
+
+/* Extensions.  This list is not complete. */
+#define EM_S370		9	/* IBM System/370 */
+#define EM_MIPS_RS4_BE	10	/* MIPS R4000 Big-Endian */ /* Depreciated */
+#define EM_PARISC	15	/* HPPA */
+#define EM_SPARC32PLUS	18	/* SPARC v8plus */
+#define EM_PPC		20	/* PowerPC 32-bit */
+#define EM_PPC64	21	/* PowerPC 64-bit */
+#define EM_ARM		40	/* ARM */
+#define EM_SPARCV9	43	/* SPARC v9 64-bit */
+#define EM_IA_64	50	/* Intel IA-64 Processor */
+#define EM_X86_64	62	/* Advanced Micro Devices x86-64 */
+#define EM_AMD64    EM_X86_64   /* SunOS compatibility (added by Ramshankar) */
+#define EM_ALPHA	0x9026	/* Alpha (written in the absence of an ABI */
+
+/* Special section indexes. */
+#define SHN_UNDEF	     0		/* Undefined, missing, irrelevant. */
+#define SHN_LORESERVE	0xff00		/* First of reserved range. */
+#define SHN_LOPROC	0xff00		/* First processor-specific. */
+#define SHN_HIPROC	0xff1f		/* Last processor-specific. */
+#define SHN_ABS		0xfff1		/* Absolute values. */
+#define SHN_COMMON	0xfff2		/* Common data. */
+#define SHN_HIRESERVE	0xffff		/* Last of reserved range. */
+
+/* sh_type */
+#define SHT_NULL	0		/* inactive */
+#define SHT_PROGBITS	1		/* program defined information */
+#define SHT_SYMTAB	2		/* symbol table section */
+#define SHT_STRTAB	3		/* string table section */
+#define SHT_RELA	4		/* relocation section with addends */
+#define SHT_HASH	5		/* symbol hash table section */
+#define SHT_DYNAMIC	6		/* dynamic section */
+#define SHT_NOTE	7		/* note section */
+#define SHT_NOBITS	8		/* no space section */
+#define SHT_REL		9		/* relocation section - no addends */
+#define SHT_SHLIB	10		/* reserved - purpose unknown */
+#define SHT_DYNSYM	11		/* dynamic symbol table section */
+#define SHT_NUM		12		/* number of section types */
+#define SHT_LOOS	0x60000000	/* First of OS specific semantics */
+#define SHT_HIOS	0x6fffffff	/* Last of OS specific semantics */
+#define SHT_LOPROC	0x70000000	/* reserved range for processor */
+#define SHT_HIPROC	0x7fffffff	/* specific section header types */
+#define SHT_LOUSER	0x80000000	/* reserved range for application */
+#define SHT_HIUSER	0xffffffff	/* specific indexes */
+
+/* Flags for sh_flags. */
+#define SHF_WRITE	0x1		/* Section contains writable data. */
+#define SHF_ALLOC	0x2		/* Section occupies memory. */
+#define SHF_EXECINSTR	0x4		/* Section contains instructions. */
+#define SHF_TLS		0x400		/* Section contains TLS data. */
+#define SHF_MASKPROC	0xf0000000	/* Reserved for processor-specific. */
+
+/* Values for p_type. */
+#define PT_NULL		0	/* Unused entry. */
+#define PT_LOAD		1	/* Loadable segment. */
+#define PT_DYNAMIC	2	/* Dynamic linking information segment. */
+#define PT_INTERP	3	/* Pathname of interpreter. */
+#define PT_NOTE		4	/* Auxiliary information. */
+#define PT_SHLIB	5	/* Reserved (not used). */
+#define PT_PHDR		6	/* Location of program header itself. */
+#define	PT_TLS		7	/* Thread local storage segment */
+
+#define PT_COUNT	8	/* Number of defined p_type values. */
+
+#define	PT_LOOS		0x60000000	/* OS-specific */
+#define	PT_HIOS		0x6fffffff	/* OS-specific */
+#define PT_LOPROC	0x70000000	/* First processor-specific type. */
+#define PT_HIPROC	0x7fffffff	/* Last processor-specific type. */
+
+/* Values for p_flags. */
+#define PF_X		0x1	/* Executable. */
+#define PF_W		0x2	/* Writable. */
+#define PF_R		0x4	/* Readable. */
+
+/* Values for d_tag. */
+#define DT_NULL		0	/* Terminating entry. */
+#define DT_NEEDED	1	/* String table offset of a needed shared
+				   library. */
+#define DT_PLTRELSZ	2	/* Total size in bytes of PLT relocations. */
+#define DT_PLTGOT	3	/* Processor-dependent address. */
+#define DT_HASH		4	/* Address of symbol hash table. */
+#define DT_STRTAB	5	/* Address of string table. */
+#define DT_SYMTAB	6	/* Address of symbol table. */
+#define DT_RELA		7	/* Address of ElfNN_Rela relocations. */
+#define DT_RELASZ	8	/* Total size of ElfNN_Rela relocations. */
+#define DT_RELAENT	9	/* Size of each ElfNN_Rela relocation entry. */
+#define DT_STRSZ	10	/* Size of string table. */
+#define DT_SYMENT	11	/* Size of each symbol table entry. */
+#define DT_INIT		12	/* Address of initialization function. */
+#define DT_FINI		13	/* Address of finalization function. */
+#define DT_SONAME	14	/* String table offset of shared object
+				   name. */
+#define DT_RPATH	15	/* String table offset of library path. [sup] */
+#define DT_SYMBOLIC	16	/* Indicates "symbolic" linking. [sup] */
+#define DT_REL		17	/* Address of ElfNN_Rel relocations. */
+#define DT_RELSZ	18	/* Total size of ElfNN_Rel relocations. */
+#define DT_RELENT	19	/* Size of each ElfNN_Rel relocation. */
+#define DT_PLTREL	20	/* Type of relocation used for PLT. */
+#define DT_DEBUG	21	/* Reserved (not used). */
+#define DT_TEXTREL	22	/* Indicates there may be relocations in
+				   non-writable segments. [sup] */
+#define DT_JMPREL	23	/* Address of PLT relocations. */
+#define	DT_BIND_NOW	24	/* [sup] */
+#define	DT_INIT_ARRAY	25	/* Address of the array of pointers to
+				   initialization functions */
+#define	DT_FINI_ARRAY	26	/* Address of the array of pointers to
+				   termination functions */
+#define	DT_INIT_ARRAYSZ	27	/* Size in bytes of the array of
+				   initialization functions. */
+#define	DT_FINI_ARRAYSZ	28	/* Size in bytes of the array of
+				   terminationfunctions. */
+#define	DT_RUNPATH	29	/* String table offset of a null-terminated
+				   library search path string. */
+#define	DT_FLAGS	30	/* Object specific flag values. */
+#define	DT_ENCODING	32	/* Values greater than or equal to DT_ENCODING
+				   and less than DT_LOOS follow the rules for
+				   the interpretation of the d_un union
+				   as follows: even == 'd_ptr', even == 'd_val'
+				   or none */
+#define	DT_PREINIT_ARRAY 32	/* Address of the array of pointers to
+				   pre-initialization functions. */
+#define	DT_PREINIT_ARRAYSZ 33	/* Size in bytes of the array of
+				   pre-initialization functions. */
+
+#define	DT_COUNT	33	/* Number of defined d_tag values. */
+
+#define	DT_LOOS		0x6000000d	/* First OS-specific */
+#define	DT_HIOS		0x6fff0000	/* Last OS-specific */
+#define	DT_LOPROC	0x70000000	/* First processor-specific type. */
+#define	DT_HIPROC	0x7fffffff	/* Last processor-specific type. */
+
+/* Values for DT_FLAGS */
+#define	DF_ORIGIN	0x0001	/* Indicates that the object being loaded may
+				   make reference to the $ORIGIN substitution
+				   string */
+#define	DF_SYMBOLIC	0x0002	/* Indicates "symbolic" linking. */
+#define	DF_TEXTREL	0x0004	/* Indicates there may be relocations in
+				   non-writable segments. */
+#define	DF_BIND_NOW	0x0008	/* Indicates that the dynamic linker should
+				   process all relocations for the object
+				   containing this entry before transferring
+				   control to the program. */
+#define	DF_STATIC_TLS	0x0010	/* Indicates that the shared object or
+				   executable contains code using a static
+				   thread-local storage scheme. */
+
+/* Values for n_type.  Used in core files. */
+#if defined(RT_OS_FREEBSD)
+# define NT_PRSTATUS	1	/* Process status. */
+# define NT_FPREGSET	2	/* Floating point registers. */
+# define NT_PRPSINFO	3	/* Process state info. */
+#elif defined(RT_OS_SOLARIS)
+# define NT_PRSTATUS	1	/* prstatus_t <sys/old_procfs.h>	*/
+# define NT_PRFPREG	2	/* prfpregset_t	<sys/old_procfs.h>	*/
+# define NT_PRPSINFO	3	/* prpsinfo_t <sys/old_procfs.h>	*/
+# define NT_PRXREG	4	/* prxregset_t <sys/procfs.h> */
+# define NT_PLATFORM	5	/* string from sysinfo(SI_PLATFORM)	*/
+# define NT_AUXV	6	/* auxv_t array	<sys/auxv.h> */
+# define NT_LDT		9	/* ssd array <sys/sysi86.h> IA32 only */
+# define NT_PSTATUS	10	/* pstatus_t <sys/procfs.h> */
+# define NT_PSINFO	13	/* psinfo_t	<sys/procfs.h> */
+# define NT_PRCRED	14	/* prcred_t	<sys/procfs.h> */
+# define NT_UTSNAME	15	/* struct utsname <sys/utsname.h> */
+# define NT_LWPSTATUS	16	/* lwpstatus_t	<sys/procfs.h> */
+# define NT_LWPSINFO	17	/* lwpsinfo_t <sys/procfs.h> */
+# define NT_PRPRIV	18	/* prpriv_t	<sys/procfs.h>	*/
+# define NT_PRPRIVINFO	19	/* priv_impl_info_t <sys/priv.h> */
+# define NT_CONTENT	20	/* core_content_t <sys/corectl.h> */
+# define NT_ZONENAME	21	/* string from getzonenamebyid(3C) */
+# define PF_SUNW_FAILURE	0x00100000	/* mapping absent due to failure */
+# define PN_XNUM		0xffff	/* extended program header index */
+#elif defined(RT_OS_LINUX)
+# define NT_PRSTATUS     1   /* Process status. */
+# define NT_PRFPREG      2   /* Floating point registers. */
+# define NT_PRPSINFO     3   /* Process state info. */
+# define NT_TASKSTRUCT   4   /* Task info. */
+# define NT_AUXV         6   /* Process auxiliary vectors. */
+# define NT_PRXFPREG     0x46e62b7f /* from gdb5.1/include/elf/common.h */
+#endif
+
+/* VirtualBox specific NOTE sections (added by Ramshankar) */
+#ifdef VBOX
+# define NT_VBOXCORE 0xb00
+# define NT_VBOXCPU  0xb01
+#endif
+
+/* Symbol Binding - ELFNN_ST_BIND - st_info */
+#define STB_LOCAL	0	/* Local symbol */
+#define STB_GLOBAL	1	/* Global symbol */
+#define STB_WEAK	2	/* like global - lower precedence */
+#define STB_LOPROC	13	/* reserved range for processor */
+#define STB_HIPROC	15	/*  specific symbol bindings */
+
+/* Symbol type - ELFNN_ST_TYPE - st_info */
+#define STT_NOTYPE	0	/* Unspecified type. */
+#define STT_OBJECT	1	/* Data object. */
+#define STT_FUNC	2	/* Function. */
+#define STT_SECTION	3	/* Section. */
+#define STT_FILE	4	/* Source file. */
+#define STT_TLS		6	/* TLS object. */
+#define STT_NUM		7	/* Number of generic symbol types. */
+#define STT_LOPROC	13	/* reserved range for processor */
+#define STT_HIPROC	15	/*  specific symbol types */
+
+/* Special symbol table indexes. */
+#define STN_UNDEF	0	/* Undefined symbol index. */
+
+#endif
+
Index: /trunk/include/iprt/formats/elf-i386.h
===================================================================
--- /trunk/include/iprt/formats/elf-i386.h	(revision 58636)
+++ /trunk/include/iprt/formats/elf-i386.h	(revision 58636)
@@ -0,0 +1,131 @@
+/*-
+ * Copyright (c) 1996-1997 John D. Polstra.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef ___iprt_formats_elf_i386_h
+#define ___iprt_formats_elf_i386_h
+
+#if 0  /* later */
+
+/*
+ * Auxiliary vector entries for passing information to the interpreter.
+ *
+ * The i386 supplement to the SVR4 ABI specification names this "auxv_t",
+ * but POSIX lays claim to all symbols ending with "_t".
+ */
+
+typedef struct {	/* Auxiliary vector entry on initial stack */
+	int	a_type;			/* Entry type. */
+	union {
+		long	a_val;		/* Integer value. */
+		void	*a_ptr;		/* Address. */
+		void	(*a_fcn)(void);	/* Function pointer (not used). */
+	} a_un;
+} Elf32_Auxinfo;
+
+#if __ELF_WORD_SIZE == 64
+/* Fake for amd64 loader support */
+typedef struct {
+	int fake;
+} Elf64_Auxinfo;
+#endif
+
+/* Values for a_type. */
+#define	AT_NULL		0	/* Terminates the vector. */
+#define	AT_IGNORE	1	/* Ignored entry. */
+#define	AT_EXECFD	2	/* File descriptor of program to load. */
+#define	AT_PHDR		3	/* Program header of program already loaded. */
+#define	AT_PHENT	4	/* Size of each program header entry. */
+#define	AT_PHNUM	5	/* Number of program header entries. */
+#define	AT_PAGESZ	6	/* Page size in bytes. */
+#define	AT_BASE		7	/* Interpreter's base address. */
+#define	AT_FLAGS	8	/* Flags (unused for i386). */
+#define	AT_ENTRY	9	/* Where interpreter should transfer control. */
+
+/*
+ * The following non-standard values are used for passing information
+ * from John Polstra's testbed program to the dynamic linker.  These
+ * are expected to go away soon.
+ *
+ * Unfortunately, these overlap the Linux non-standard values, so they
+ * must not be used in the same context.
+ */
+#define	AT_BRK		10	/* Starting point for sbrk and brk. */
+#define	AT_DEBUG	11	/* Debugging level. */
+
+/*
+ * The following non-standard values are used in Linux ELF binaries.
+ */
+#define	AT_NOTELF	10	/* Program is not ELF ?? */
+#define	AT_UID		11	/* Real uid. */
+#define	AT_EUID		12	/* Effective uid. */
+#define	AT_GID		13	/* Real gid. */
+#define	AT_EGID		14	/* Effective gid. */
+
+#define	AT_COUNT	15	/* Count of defined aux entry types. */
+
+#endif /* later */
+
+
+/*
+ * Relocation types.
+ */
+
+#define	R_386_NONE	0	/* No relocation. */
+#define	R_386_32	1	/* Add symbol value. */
+#define	R_386_PC32	2	/* Add PC-relative symbol value. */
+#define	R_386_GOT32	3	/* Add PC-relative GOT offset. */
+#define	R_386_PLT32	4	/* Add PC-relative PLT offset. */
+#define	R_386_COPY	5	/* Copy data from shared object. */
+#define	R_386_GLOB_DAT	6	/* Set GOT entry to data address. */
+#define	R_386_JMP_SLOT	7	/* Set GOT entry to code address. */
+#define	R_386_RELATIVE	8	/* Add load address of shared object. */
+#define	R_386_GOTOFF	9	/* Add GOT-relative symbol address. */
+#define	R_386_GOTPC	10	/* Add PC-relative GOT table address. */
+#define	R_386_TLS_TPOFF	14	/* Negative offset in static TLS block */
+#define	R_386_TLS_IE	15	/* Absolute address of GOT for -ve static TLS */
+#define	R_386_TLS_GOTIE	16	/* GOT entry for negative static TLS block */
+#define	R_386_TLS_LE	17	/* Negative offset relative to static TLS */
+#define	R_386_TLS_GD	18	/* 32 bit offset to GOT (index,off) pair */
+#define	R_386_TLS_LDM	19	/* 32 bit offset to GOT (index,zero) pair */
+#define	R_386_TLS_GD_32	24	/* 32 bit offset to GOT (index,off) pair */
+#define	R_386_TLS_GD_PUSH 25	/* pushl instruction for Sun ABI GD sequence */
+#define	R_386_TLS_GD_CALL 26	/* call instruction for Sun ABI GD sequence */
+#define	R_386_TLS_GD_POP 27	/* popl instruction for Sun ABI GD sequence */
+#define	R_386_TLS_LDM_32 28	/* 32 bit offset to GOT (index,zero) pair */
+#define	R_386_TLS_LDM_PUSH 29	/* pushl instruction for Sun ABI LD sequence */
+#define	R_386_TLS_LDM_CALL 30	/* call instruction for Sun ABI LD sequence */
+#define	R_386_TLS_LDM_POP 31	/* popl instruction for Sun ABI LD sequence */
+#define	R_386_TLS_LDO_32 32	/* 32 bit offset from start of TLS block */
+#define	R_386_TLS_IE_32	33	/* 32 bit offset to GOT static TLS offset entry */
+#define	R_386_TLS_LE_32	34	/* 32 bit offset within static TLS block */
+#define	R_386_TLS_DTPMOD32 35	/* GOT entry containing TLS index */
+#define	R_386_TLS_DTPOFF32 36	/* GOT entry containing TLS offset */
+#define	R_386_TLS_TPOFF32 37	/* GOT entry of -ve static TLS offset */
+
+#define	R_386_COUNT	38	/* Count of defined relocation types. */
+
+#endif
+
Index: /trunk/include/iprt/formats/elf.h
===================================================================
--- /trunk/include/iprt/formats/elf.h	(revision 58636)
+++ /trunk/include/iprt/formats/elf.h	(revision 58636)
@@ -0,0 +1,86 @@
+/* $Id$ */
+/** @file
+ * ELF types, current architecture.
+ */
+
+/*
+ * Copyright (C) 2010-2015 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+#ifndef ___iprt_formats_elf_h
+#define ___iprt_formats_elf_h
+
+#if defined(RT_ARCH_AMD64)
+# include "elf64.h"
+typedef Elf64_Addr          Elf_Addr;
+typedef Elf64_Half          Elf_Half;
+typedef Elf64_Off           Elf_Off;
+typedef Elf64_Sword         Elf_Sword;
+typedef Elf64_Word          Elf_Word;
+typedef Elf64_Size          Elf_Size;
+typedef Elf64_Hashelt       Elf_Hashelt;
+typedef	Elf64_Ehdr          Elf_Ehdr;
+typedef	Elf64_Shdr          Elf_Shdr;
+typedef	Elf64_Phdr          Elf_Phdr;
+typedef	Elf64_Nhdr          Elf_Nhdr;
+typedef	Elf64_Dyn           Elf_Dyn;
+typedef	Elf64_Rel           Elf_Rel;
+typedef	Elf64_Rela          Elf_Rela;
+typedef	Elf64_Sym           Elf_Sym;
+
+#define ELF_R_SYM           ELF64_R_SYM
+#define ELF_R_TYPE          ELF64_R_TYPE
+#define ELF_R_INFO          ELF64_R_INFO
+#define ELF_ST_BIND         ELF64_ST_BIND
+#define ELF_ST_TYPE         ELF64_ST_TYPE
+#define ELF_ST_INFO         ELF64_ST_INFO
+
+#elif defined(RT_ARCH_X86)
+# include "elf32.h"
+typedef Elf32_Addr          Elf_Addr;
+typedef Elf32_Half          Elf_Half;
+typedef Elf32_Off           Elf_Off;
+typedef Elf32_Sword         Elf_Sword;
+typedef Elf32_Word          Elf_Word;
+typedef Elf32_Size          Elf_Size;
+typedef Elf32_Hashelt       Elf_Hashelt;
+typedef	Elf32_Ehdr          Elf_Ehdr;
+typedef	Elf32_Shdr          Elf_Shdr;
+typedef	Elf32_Phdr          Elf_Phdr;
+typedef	Elf32_Nhdr          Elf_Nhdr;
+typedef	Elf32_Dyn           Elf_Dyn;
+typedef	Elf32_Rel           Elf_Rel;
+typedef	Elf32_Rela          Elf_Rela;
+typedef	Elf32_Sym           Elf_Sym;
+
+#define ELF_R_SYM           ELF32_R_SYM
+#define ELF_R_TYPE          ELF32_R_TYPE
+#define ELF_R_INFO          ELF32_R_INFO
+#define ELF_ST_BIND         ELF32_ST_BIND
+#define ELF_ST_TYPE         ELF32_ST_TYPE
+#define ELF_ST_INFO         ELF32_ST_INFO
+
+#else
+# error Unknown arch!
+#endif
+
+#endif
+
Index: /trunk/include/iprt/formats/elf32.h
===================================================================
--- /trunk/include/iprt/formats/elf32.h	(revision 58636)
+++ /trunk/include/iprt/formats/elf32.h	(revision 58636)
@@ -0,0 +1,188 @@
+/* $Id$ */
+/** @file
+ * IPRT - ELF 32-bit header.
+ */
+
+/*
+ * Copyright (C) 2010-2015 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#ifndef ___iprt_formats_elf32_h
+#define ___iprt_formats_elf32_h
+
+#include <iprt/assert.h>
+
+#include "elf-common.h"
+
+/*
+ * ELF 32 standard types.
+ */
+typedef uint32_t        Elf32_Addr;
+typedef uint16_t        Elf32_Half;
+typedef uint32_t        Elf32_Off;
+typedef int32_t         Elf32_Sword;
+typedef uint32_t        Elf32_Word;
+
+/*
+ * Ensure type size correctness in accordance to                                                             .
+ * Portable Format Specification (for ELF), Version 1.1, fig 1-2.                                            .
+ */
+AssertCompileSize(Elf32_Addr,   4);
+AssertCompileSize(Elf32_Half,   2);
+AssertCompileSize(Elf32_Off,    4);
+AssertCompileSize(Elf32_Sword,  4);
+AssertCompileSize(Elf32_Word,   4);
+
+/*
+ * ELF 32 non-standard types for convenience.
+ */
+typedef Elf32_Word      Elf32_Size;
+typedef Elf32_Word      Elf32_Hashelt;
+
+/*
+ * ELF header.
+ */
+typedef struct
+{
+    unsigned char e_ident[16];      /* ELF identification. */
+    Elf32_Half    e_type;           /* Object file type. */
+    Elf32_Half    e_machine;        /* Machine type. */
+    Elf32_Word    e_version;        /* Object file version. */
+    Elf32_Addr    e_entry;          /* Entry point address. */
+    Elf32_Off     e_phoff;          /* Program header offset. */
+    Elf32_Off     e_shoff;          /* Section header offset. */
+    Elf32_Word    e_flags;          /* Processor-specific flags. */
+    Elf32_Half    e_ehsize;         /* ELF header size. */
+    Elf32_Half    e_phentsize;      /* Size of program header entries. */
+    Elf32_Half    e_phnum;          /* Number of program headers. */
+    Elf32_Half    e_shentsize;      /* Size of section header entries. */
+    Elf32_Half    e_shnum;          /* Number of section headers. */
+    Elf32_Half    e_shstrndx;       /* Section name string table index. */
+} Elf32_Ehdr;
+
+/*
+ * Section header.
+ */
+typedef struct
+{
+    Elf32_Word    sh_name;          /* Section name. */
+    Elf32_Word    sh_type;          /* Section type. */
+    Elf32_Word    sh_flags;         /* Section attributes. */
+    Elf32_Addr    sh_addr;          /* Virtual address in memory. */
+    Elf32_Off     sh_offset;        /* Offset in file. */
+    Elf32_Word    sh_size;          /* Size of section. */
+    Elf32_Word    sh_link;          /* Link to other section. */
+    Elf32_Word    sh_info;          /* Miscellaneous information. */
+    Elf32_Word    sh_addralign;     /* Address alignment boundary. */
+    Elf32_Word    sh_entsize;       /* Size of entries, if section has table. */
+} Elf32_Shdr;
+
+
+/*
+ * Program header.
+ */
+typedef struct
+{
+    Elf32_Word    p_type;           /* Type of segment. */
+    Elf32_Off     p_offset;         /* Offset in file. */
+    Elf32_Addr    p_vaddr;          /* Virtual address in memory. */
+    Elf32_Addr    p_paddr;          /* Physical address (reserved). */
+    Elf32_Word    p_filesz;         /* Size of segment in file. */
+    Elf32_Word    p_memsz;          /* Size of segment in memory. */
+    Elf32_Word    p_flags;          /* Segment attributes. */
+    Elf32_Word    p_align;          /* Alignment of segment. */
+} Elf32_Phdr;
+
+
+/*
+ * Note header.
+ */
+typedef struct
+{
+    Elf32_Word    n_namesz;         /* Length of note's name. */
+    Elf32_Word    n_descsz;         /* Length of note's description. */
+    Elf32_Word    n_type;           /* Type of note. */
+} Elf32_Nhdr;
+
+
+/*
+ * Symbol table entry.
+ */
+typedef struct
+{
+    Elf32_Word    st_name;          /* Symbol name. */
+    Elf32_Addr    st_value;         /* Symbol value. */
+    Elf32_Word    st_size;          /* Size associated with symbol. */
+    unsigned char st_info;          /* Type and binding attributes. */
+    unsigned char st_other;         /* Reserved. */
+    Elf32_Half    st_shndx;         /* Section header table index. */
+} Elf32_Sym;
+
+
+/*
+ * Relocations.
+ */
+typedef struct
+{
+    Elf32_Addr    r_offset;         /* Location to be relocated. */
+    Elf32_Word    r_info;           /* Symbol index and type of relocation. */
+} Elf32_Rel;
+
+typedef struct
+{
+    Elf32_Addr    r_offset;         /* Location to be relocated. */
+    Elf32_Word    r_info;           /* Symbol index and type of relocation. */
+    Elf32_Sword   r_addend;         /* Constant part of expression. */
+} Elf32_Rela;
+
+/*
+ * Dynamic section entry.
+ * ".dynamic" section contains an array of this.
+ */
+typedef struct
+{
+    Elf32_Sword   d_tag;            /* Type of entry. */
+    union
+    {
+        Elf32_Word    d_val;        /* Integer value. */
+        Elf32_Addr    d_ptr;        /* Virtual address value. */
+    } d_un;
+} Elf32_Dyn;
+
+/*
+ * Helper macros.
+ */
+/** The symbol's type. */
+#define ELF32_ST_TYPE(info)         ((info) & 0xF)
+/** The symbol's binding. */
+#define ELF32_ST_BIND(info)         ((info) >> 4)
+/** Make st_info. given binding and type. */
+#define ELF32_ST_INFO(bind, type)   (((bind) << 4) + ((type) & 0xf))
+
+/** Relocation type. */
+#define ELF32_R_TYPE(info)          ((unsigned char)(info))
+/** Relocation symbol index. */
+#define ELF32_R_SYM(info)           ((info) >> 8)
+/** Make r_info given the symbol index and type.  */
+#define ELF32_R_INFO(sym, type)     (((sym) << 8) + (unsigned char)(type))
+
+
+#endif
+
Index: /trunk/include/iprt/formats/elf64.h
===================================================================
--- /trunk/include/iprt/formats/elf64.h	(revision 58636)
+++ /trunk/include/iprt/formats/elf64.h	(revision 58636)
@@ -0,0 +1,187 @@
+/* $Id$ */
+/** @file
+ * IPRT - ELF 64-bit header.
+ */
+
+/*
+ * Copyright (C) 2010-2015 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#ifndef ___iprt_formats_elf64_h
+#define ___iprt_formats_elf64_h
+
+#include <iprt/assert.h>
+
+#include "elf-common.h"
+
+/*
+ * ELF 64 standard types.
+ */
+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;
+
+/*
+ * Ensure type size correctness in accordance to ELF-64 Object File Format, Version 1.5 Draft 2, p2.
+ */
+AssertCompileSize(Elf64_Addr,    8);
+AssertCompileSize(Elf64_Off,     8);
+AssertCompileSize(Elf64_Half,    2);
+AssertCompileSize(Elf64_Word,    4);
+AssertCompileSize(Elf64_Sword,   4);
+AssertCompileSize(Elf64_Xword,   8);
+AssertCompileSize(Elf64_Sxword,  8);
+
+/*
+ * ELF 64 non-standard types for convenience.
+ */
+typedef Elf64_Xword     Elf64_Size;
+typedef Elf64_Word      Elf64_Hashelt;
+
+/*
+ * ELF Header.
+ */
+typedef struct
+{
+    unsigned char e_ident[16];      /* 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 entry. */
+    Elf64_Half    e_shnum;          /* Number of section header entries. */
+    Elf64_Half    e_shstrndx;       /* Section name string table index. */
+} Elf64_Ehdr;
+
+/*
+ * Section header.
+ */
+typedef struct
+{
+    Elf64_Word    sh_name;          /* Section name. */
+    Elf64_Word    sh_type;          /* Section type. */
+    Elf64_Xword   sh_flags;         /* Section attributes. */
+    Elf64_Addr    sh_addr;          /* Virtual address in memory. */
+    Elf64_Off     sh_offset;        /* Offset in file. */
+    Elf64_Xword   sh_size;          /* Size of section. */
+    Elf64_Word    sh_link;          /* Link to other section. */
+    Elf64_Word    sh_info;          /* Miscellaneous information. */
+    Elf64_Xword   sh_addralign;     /* Address alignment boundary. */
+    Elf64_Xword   sh_entsize;       /* Size of entries, if section has table. */
+} Elf64_Shdr;
+
+/*
+ * Program header.
+ */
+typedef struct
+{
+    Elf64_Word    p_type;           /* Type of segment. */
+    Elf64_Word    p_flags;          /* Segment attributes. */
+    Elf64_Off     p_offset;         /* Offset in file. */
+    Elf64_Addr    p_vaddr;          /* Virtual address in memory. */
+    Elf64_Addr    p_paddr;          /* Physical address (reserved). */
+    Elf64_Xword   p_filesz;         /* Size of segment in file. */
+    Elf64_Xword   p_memsz;          /* Size of segment in memory. */
+    Elf64_Xword   p_align;          /* Alignment of segment. */
+} Elf64_Phdr;
+
+/*
+ * Note header.
+ */
+typedef struct
+{
+    Elf64_Word    n_namesz;         /* Length of note's name. */
+    Elf64_Word    n_descsz;         /* Length of note's description. */
+    Elf64_Word    n_type;           /* Type of note. */
+} Elf64_Nhdr;
+
+/*
+ * Symbol table entry.
+ */
+typedef struct
+{
+    Elf64_Word    st_name;          /* Symbol name. */
+    unsigned char st_info;          /* Type and binding attributes. */
+    unsigned char st_other;         /* Reserved. */
+    Elf64_Half    st_shndx;         /* Section header table index. */
+    Elf64_Addr    st_value;         /* Symbol value. */
+    Elf64_Xword   st_size;          /* Size associated with symbol. */
+} Elf64_Sym;
+
+/*
+ * Relocations.
+ */
+typedef struct
+{
+    Elf64_Addr    r_offset;         /* Location to be relocated. */
+    Elf64_Xword   r_info;           /* Symbol index and type of relocation. */
+} Elf64_Rel;
+
+typedef struct
+{
+    Elf64_Addr    r_offset;         /* Location to be relocated. */
+    Elf64_Xword   r_info;           /* Symbol index and type of relocation. */
+    Elf64_Sxword  r_addend;         /* Constant part of expression. */
+} Elf64_Rela;
+
+/*
+ * Dynamic section entry.
+ * ".dynamic" section contains an array of this.
+ */
+typedef struct
+{
+    Elf64_Sxword  d_tag;            /* Type of entry. */
+    union
+    {
+        Elf64_Xword   d_val;        /* Integer value. */
+        Elf64_Addr    d_ptr;        /* Virtual address value. */
+    } d_un;
+} Elf64_Dyn;
+
+/*
+ * Helper macros.
+ */
+/** The symbol's type. */
+#define ELF64_ST_TYPE(info)         ((info) & 0xF)
+/** The symbol's binding. */
+#define ELF64_ST_BIND(info)         ((info) >> 4)
+/** Make st_info. given binding and type. */
+#define ELF64_ST_INFO(bind, type)   (((bind) << 4) + ((type) & 0xf))
+
+/** Relocation type. */
+#define ELF64_R_TYPE(info)          ((unsigned char)(info))
+/** Relocation symbol index. */
+#define ELF64_R_SYM(info)           ((info) >> 32)
+/** Make r_info given the symbol index and type.  */
+#define ELF64_R_INFO(sym, type)     (((sym) << 32) + (unsigned char)(type))
+
+
+#endif
+
