Index: /trunk/kStuff/include/k/kLdrFmts/elf-amd64.h
===================================================================
--- /trunk/kStuff/include/k/kLdrFmts/elf-amd64.h	(revision 3568)
+++ /trunk/kStuff/include/k/kLdrFmts/elf-amd64.h	(revision 3568)
@@ -0,0 +1,130 @@
+/*-
+ * 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.
+ *
+ * $FreeBSD: src/sys/amd64/include/elf.h,v 1.18 2004/08/03 08:21:48 dfr Exp $
+ */
+
+#ifndef ___k_kLdrFmts_elf_amd64_h___
+#define	___k_kLdrFmts_elf_amd64_h___
+
+/*
+ * ELF definitions for the AMD64 architecture.
+ */
+
+#if 0 /** @todo Auxiliary vector entries. */
+/*
+ * 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 /* [todo] */
+
+/*
+ * 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/kStuff/include/k/kLdrFmts/elf-i386.h
===================================================================
--- /trunk/kStuff/include/k/kLdrFmts/elf-i386.h	(revision 3568)
+++ /trunk/kStuff/include/k/kLdrFmts/elf-i386.h	(revision 3568)
@@ -0,0 +1,133 @@
+/*-
+ * 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.
+ *
+ * $FreeBSD: src/sys/i386/include/elf.h,v 1.16 2004/08/02 19:12:17 dfr Exp $
+ */
+
+#ifndef ___k_kLdrFmts_elf_i386_h___
+#define ___k_kLdrFmts_elf_i386_h___
+
+#if 0 /** @todo Auxiliary vector entries. */
+
+/*
+ * 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 /* [todo] */
+
+
+/*
+ * 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/kStuff/include/k/kLdrFmts/elf32.h
===================================================================
--- /trunk/kStuff/include/k/kLdrFmts/elf32.h	(revision 3568)
+++ /trunk/kStuff/include/k/kLdrFmts/elf32.h	(revision 3568)
@@ -0,0 +1,159 @@
+/*-
+ * Copyright (c) 1996-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.
+ *
+ * $FreeBSD: src/sys/sys/elf32.h,v 1.8 2002/05/30 08:32:18 dfr Exp $
+ */
+
+#ifndef ___k_kLdrFmts_elf32_h___
+#define ___k_kLdrFmts_elf32_h___
+
+#include <k/kDefs.h>
+#include <k/kTypes.h>
+#include <k/kLdrFmts/elf_common.h>
+
+/*
+ * ELF definitions common to all 32-bit architectures.
+ */
+
+typedef KU32	Elf32_Addr;
+typedef KU16	Elf32_Half;
+typedef KU32	Elf32_Off;
+typedef KI32		Elf32_Sword;
+typedef KU32	Elf32_Word;
+typedef KU32	Elf32_Size;
+typedef Elf32_Off	Elf32_Hashelt;
+
+/*
+ * ELF header.
+ */
+
+typedef struct Elf32_Ehdr {
+	unsigned char	e_ident[EI_NIDENT];	/* File identification. */
+	Elf32_Half	e_type;		/* File type. */
+	Elf32_Half	e_machine;	/* Machine architecture. */
+	Elf32_Word	e_version;	/* ELF format version. */
+	Elf32_Addr	e_entry;	/* Entry point. */
+	Elf32_Off	e_phoff;	/* Program header file offset. */
+	Elf32_Off	e_shoff;	/* Section header file offset. */
+	Elf32_Word	e_flags;	/* Architecture-specific flags. */
+	Elf32_Half	e_ehsize;	/* Size of ELF header in bytes. */
+	Elf32_Half	e_phentsize;	/* Size of program header entry. */
+	Elf32_Half	e_phnum;	/* Number of program header entries. */
+	Elf32_Half	e_shentsize;	/* Size of section header entry. */
+	Elf32_Half	e_shnum;	/* Number of section header entries. */
+	Elf32_Half	e_shstrndx;	/* Section name strings section. */
+} Elf32_Ehdr;
+
+/*
+ * Section header.
+ */
+
+typedef struct {
+	Elf32_Word	sh_name;	/* Section name (index into the
+					   section header string table). */
+	Elf32_Word	sh_type;	/* Section type. */
+	Elf32_Word	sh_flags;	/* Section flags. */
+	Elf32_Addr	sh_addr;	/* Address in memory image. */
+	Elf32_Off	sh_offset;	/* Offset in file. */
+	Elf32_Size	sh_size;	/* Size in bytes. */
+	Elf32_Word	sh_link;	/* Index of a related section. */
+	Elf32_Word	sh_info;	/* Depends on section type. */
+	Elf32_Size	sh_addralign;	/* Alignment in bytes. */
+	Elf32_Size	sh_entsize;	/* Size of each entry in section. */
+} Elf32_Shdr;
+
+/*
+ * Program header.
+ */
+
+typedef struct {
+	Elf32_Word	p_type;		/* Entry type. */
+	Elf32_Off	p_offset;	/* File offset of contents. */
+	Elf32_Addr	p_vaddr;	/* Virtual address in memory image. */
+	Elf32_Addr	p_paddr;	/* Physical address (not used). */
+	Elf32_Size	p_filesz;	/* Size of contents in file. */
+	Elf32_Size	p_memsz;	/* Size of contents in memory. */
+	Elf32_Word	p_flags;	/* Access permission flags. */
+	Elf32_Size	p_align;	/* Alignment in memory and file. */
+} Elf32_Phdr;
+
+/*
+ * Dynamic structure.  The ".dynamic" section contains an array of them.
+ */
+
+typedef struct {
+	Elf32_Sword	d_tag;		/* Entry type. */
+	union {
+		Elf32_Size	d_val;	/* Integer value. */
+		Elf32_Addr	d_ptr;	/* Address value. */
+	} d_un;
+} Elf32_Dyn;
+
+/*
+ * Relocation entries.
+ */
+
+/* Relocations that don't need an addend field. */
+typedef struct {
+	Elf32_Addr	r_offset;	/* Location to be relocated. */
+	Elf32_Word	r_info;		/* Relocation type and symbol index. */
+} Elf32_Rel;
+
+/* Relocations that need an addend field. */
+typedef struct {
+	Elf32_Addr	r_offset;	/* Location to be relocated. */
+	Elf32_Word	r_info;		/* Relocation type and symbol index. */
+	Elf32_Sword	r_addend;	/* Addend. */
+} Elf32_Rela;
+
+/* Macros for accessing the fields of r_info. */
+#define ELF32_R_SYM(info)	((info) >> 8)
+#define ELF32_R_TYPE(info)	((unsigned char)(info))
+
+/* Macro for constructing r_info from field values. */
+#define ELF32_R_INFO(sym, type)	(((sym) << 8) + (unsigned char)(type))
+
+/*
+ * Symbol table entries.
+ */
+
+typedef struct {
+	Elf32_Word	st_name;	/* String table index of name. */
+	Elf32_Addr	st_value;	/* Symbol value. */
+	Elf32_Size	st_size;	/* Size of associated object. */
+	unsigned char	st_info;	/* Type and binding information. */
+	unsigned char	st_other;	/* Reserved (not used). */
+	Elf32_Half	st_shndx;	/* Section index of symbol. */
+} Elf32_Sym;
+
+/* Macros for accessing the fields of st_info. */
+#define ELF32_ST_BIND(info)		((info) >> 4)
+#define ELF32_ST_TYPE(info)		((info) & 0xf)
+
+/* Macro for constructing st_info from field values. */
+#define ELF32_ST_INFO(bind, type)	(((bind) << 4) + ((type) & 0xf))
+
+#endif
+
Index: /trunk/kStuff/include/k/kLdrFmts/elf64.h
===================================================================
--- /trunk/kStuff/include/k/kLdrFmts/elf64.h	(revision 3568)
+++ /trunk/kStuff/include/k/kLdrFmts/elf64.h	(revision 3568)
@@ -0,0 +1,172 @@
+/*-
+ * Copyright (c) 1996-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.
+ *
+ * $FreeBSD: src/sys/sys/elf64.h,v 1.10 2002/05/30 08:32:18 dfr Exp $
+ */
+
+#ifndef ___k_kLdrFmts_elf64_h___
+#define ___k_kLdrFmts_elf64_h___
+
+#include <k/kDefs.h>
+#include <k/kTypes.h>
+#include <k/kLdrFmts/elf_common.h>
+
+/*
+ * ELF definitions common to all 64-bit architectures.
+ */
+
+typedef KU64    Elf64_Addr;
+typedef KU32    Elf64_Half;
+typedef KU64    Elf64_Off;
+typedef KI64    Elf64_Sword;
+typedef KU64    Elf64_Word;
+typedef KU64    Elf64_Size;
+typedef KU16    Elf64_Quarter;
+
+/*
+ * Types of dynamic symbol hash table bucket and chain elements.
+ *
+ * This is inconsistent among 64 bit architectures, so a machine dependent
+ * typedef is required.
+ */
+
+#ifdef __alpha__
+typedef Elf64_Off	Elf64_Hashelt;
+#else
+typedef Elf64_Half	Elf64_Hashelt;
+#endif
+
+/*
+ * ELF header.
+ */
+
+typedef struct {
+	unsigned char	e_ident[EI_NIDENT];	/* File identification. */
+	Elf64_Quarter	e_type;		/* File type. */
+	Elf64_Quarter	e_machine;	/* Machine architecture. */
+	Elf64_Half	e_version;	/* ELF format version. */
+	Elf64_Addr	e_entry;	/* Entry point. */
+	Elf64_Off	e_phoff;	/* Program header file offset. */
+	Elf64_Off	e_shoff;	/* Section header file offset. */
+	Elf64_Half	e_flags;	/* Architecture-specific flags. */
+	Elf64_Quarter	e_ehsize;	/* Size of ELF header in bytes. */
+	Elf64_Quarter	e_phentsize;	/* Size of program header entry. */
+	Elf64_Quarter	e_phnum;	/* Number of program header entries. */
+	Elf64_Quarter	e_shentsize;	/* Size of section header entry. */
+	Elf64_Quarter	e_shnum;	/* Number of section header entries. */
+	Elf64_Quarter	e_shstrndx;	/* Section name strings section. */
+} Elf64_Ehdr;
+
+/*
+ * Section header.
+ */
+
+typedef struct {
+	Elf64_Half	sh_name;	/* Section name (index into the
+					   section header string table). */
+	Elf64_Half	sh_type;	/* Section type. */
+	Elf64_Size	sh_flags;	/* Section flags. */
+	Elf64_Addr	sh_addr;	/* Address in memory image. */
+	Elf64_Off	sh_offset;	/* Offset in file. */
+	Elf64_Size	sh_size;	/* Size in bytes. */
+	Elf64_Half	sh_link;	/* Index of a related section. */
+	Elf64_Half	sh_info;	/* Depends on section type. */
+	Elf64_Size	sh_addralign;	/* Alignment in bytes. */
+	Elf64_Size	sh_entsize;	/* Size of each entry in section. */
+} Elf64_Shdr;
+
+/*
+ * Program header.
+ */
+
+typedef struct {
+	Elf64_Half	p_type;		/* Entry type. */
+	Elf64_Half	p_flags;	/* Access permission flags. */
+	Elf64_Off	p_offset;	/* File offset of contents. */
+	Elf64_Addr	p_vaddr;	/* Virtual address in memory image. */
+	Elf64_Addr	p_paddr;	/* Physical address (not used). */
+	Elf64_Size	p_filesz;	/* Size of contents in file. */
+	Elf64_Size	p_memsz;	/* Size of contents in memory. */
+	Elf64_Size	p_align;	/* Alignment in memory and file. */
+} Elf64_Phdr;
+
+/*
+ * Dynamic structure.  The ".dynamic" section contains an array of them.
+ */
+
+typedef struct {
+	Elf64_Size	d_tag;		/* Entry type. */
+	union {
+		Elf64_Size	d_val;	/* Integer value. */
+		Elf64_Addr	d_ptr;	/* Address value. */
+	} d_un;
+} Elf64_Dyn;
+
+/*
+ * Relocation entries.
+ */
+
+/* Relocations that don't need an addend field. */
+typedef struct {
+	Elf64_Addr	r_offset;	/* Location to be relocated. */
+	Elf64_Size	r_info;		/* Relocation type and symbol index. */
+} Elf64_Rel;
+
+/* Relocations that need an addend field. */
+typedef struct {
+	Elf64_Addr	r_offset;	/* Location to be relocated. */
+	Elf64_Size	r_info;		/* Relocation type and symbol index. */
+	Elf64_Off	r_addend;	/* Addend. */
+} Elf64_Rela;
+
+/* Macros for accessing the fields of r_info. */
+#define ELF64_R_SYM(info)	((info) >> 32)
+#define ELF64_R_TYPE(info)	((unsigned char)(info))
+
+/* Macro for constructing r_info from field values. */
+#define ELF64_R_INFO(sym, type)	(((sym) << 32) + (unsigned char)(type))
+
+/*
+ * Symbol table entries.
+ */
+
+typedef struct {
+	Elf64_Half	st_name;	/* String table index of name. */
+	unsigned char	st_info;	/* Type and binding information. */
+	unsigned char	st_other;	/* Reserved (not used). */
+	Elf64_Quarter	st_shndx;	/* Section index of symbol. */
+	Elf64_Addr	st_value;	/* Symbol value. */
+	Elf64_Size	st_size;	/* Size of associated object. */
+} Elf64_Sym;
+
+/* Macros for accessing the fields of st_info. */
+#define ELF64_ST_BIND(info)		((info) >> 4)
+#define ELF64_ST_TYPE(info)		((info) & 0xf)
+
+/* Macro for constructing st_info from field values. */
+#define ELF64_ST_INFO(bind, type)	(((bind) << 4) + ((type) & 0xf))
+
+#endif
+
Index: /trunk/kStuff/include/k/kLdrFmts/elf_common.h
===================================================================
--- /trunk/kStuff/include/k/kLdrFmts/elf_common.h	(revision 3568)
+++ /trunk/kStuff/include/k/kLdrFmts/elf_common.h	(revision 3568)
@@ -0,0 +1,300 @@
+/*-
+ * 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.
+ *
+ * $FreeBSD: src/sys/sys/elf_common.h,v 1.15 2004/05/05 02:38:54 marcel Exp $
+ */
+
+#ifndef ___k_kLdrFmts_elf_common_h___
+#define ___k_kLdrFmts_elf_common_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 {
+	KU32	n_namesz;	/* Length of name. */
+	KU32	n_descsz;	/* Length of descriptor. */
+	KU32	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_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. */
+#define NT_PRSTATUS	1	/* Process status. */
+#define NT_FPREGSET	2	/* Floating point registers. */
+#define NT_PRPSINFO	3	/* Process state info. */
+
+/* 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_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/kStuff/include/k/kLdrFmts/lx.h
===================================================================
--- /trunk/kStuff/include/k/kLdrFmts/lx.h	(revision 3568)
+++ /trunk/kStuff/include/k/kLdrFmts/lx.h	(revision 3568)
@@ -0,0 +1,460 @@
+/* $Id $ */
+/** @file
+ * LX structures, types and defines.
+ */
+
+#ifndef ___k_kLdrFmts_lx_h___
+#define ___k_kLdrFmts_lx_h___
+
+#include <k/kDefs.h>
+#include <k/kTypes.h>
+
+
+#ifndef IMAGE_OS2_SIGNATURE_LX
+/** LX signature ("LX") */
+# define IMAGE_LX_SIGNATURE  KLDR_LE2H_U16('L' | ('X' << 8))
+#endif
+
+#pragma pack(1)
+
+/**
+ * Linear eXecutable header.
+ * This structure is exactly 196 bytes long.
+ */
+struct e32_exe
+{
+    KU8                 e32_magic[2];
+    KU8                 e32_border;
+    KU8                 e32_worder;
+    KU32                e32_level;
+    KU16                e32_cpu;
+    KU16                e32_os;
+    KU32                e32_ver;
+    KU32                e32_mflags;
+    KU32                e32_mpages;
+    KU32                e32_startobj;
+    KU32                e32_eip;
+    KU32                e32_stackobj;
+    KU32                e32_esp;
+    KU32                e32_pagesize;
+    KU32                e32_pageshift;
+    /** The size of the fixup section.
+     * The fixup section consists of the fixup page table, the fixup record table,
+     * the import module table, and the import procedure name table.
+     */
+    KU32                e32_fixupsize;
+    KU32                e32_fixupsum;
+    /** The size of the resident loader section.
+     * This includes the object table, the object page map table, the resource table, the resident name table,
+     * the entry table, the module format directives table, and the page checksum table (?). */
+    KU32                e32_ldrsize;
+    /** The checksum of the loader section. 0 if not calculated. */
+    KU32                e32_ldrsum;
+    /** The offset of the object table relative to this structure. */
+    KU32                e32_objtab;
+    /** Count of objects. */
+    KU32                e32_objcnt;
+    /** The offset of the object page map table relative to this structure. */
+    KU32                e32_objmap;
+    /** The offset of the object iterated pages (whatever this is used for) relative to the start of the file. */
+    KU32                e32_itermap;
+    /** The offset of the resource table relative to this structure. */
+    KU32                e32_rsrctab;
+    /** The number of entries in the resource table. */
+    KU32                e32_rsrccnt;
+    /** The offset of the resident name table relative to this structure. */
+    KU32                e32_restab;
+    /** The offset of the entry (export) table relative to this structure. */
+    KU32                e32_enttab;
+    /** The offset of the module format directives table relative to this structure. */
+    KU32                e32_dirtab;
+    /** The number of entries in the module format directives table. */
+    KU32                e32_dircnt;
+    /** The offset of the fixup page table relative to this structure. */
+    KU32                e32_fpagetab;
+    /** The offset of the fixup record table relative to this structure. */
+    KU32                e32_frectab;
+    /** The offset of the import module name table relative to this structure. */
+    KU32                e32_impmod;
+    /** The number of entries in the import module name table. */
+    KU32                e32_impmodcnt;
+    /** The offset of the import procedure name table relative to this structure. */
+    KU32                e32_impproc;
+    /** The offset of the page checksum table relative to this structure. */
+    KU32                e32_pagesum;
+    /** The offset of the data pages relative to the start of the file. */
+    KU32                e32_datapage;
+    /** The number of preload pages (ignored). */
+    KU32                e32_preload;
+    /** The offset of the non-resident name table relative to the start of the file. */
+    KU32                e32_nrestab;
+    /** The size of the non-resident name table. */
+    KU32                e32_cbnrestab;
+    KU32                e32_nressum;
+    KU32                e32_autodata;
+    KU32                e32_debuginfo;
+    KU32                e32_debuglen;
+    KU32                e32_instpreload;
+    KU32                e32_instdemand;
+    KU32                e32_heapsize;
+    KU32                e32_stacksize;
+    KU8                 e32_res3[20];
+};
+
+/** e32_magic[0] */
+#define E32MAGIC1       'L'
+/** e32_magic[1] */
+#define E32MAGIC2       'X'
+/** MAKEWORD(e32_magic[0], e32_magic[1]) */
+#define E32MAGIC        0x584c
+/** e32_border - little endian */
+#define E32LEBO         0
+/** e32_border - big endian */
+#define E32BEBO         1
+/** e32_worder - little endian */
+#define E32LEWO         0
+/** e32_worder - big endian */
+#define E32BEWO         1
+/** e32_level */
+#define E32LEVEL        KU32_C(0)
+/** e32_cpu - 80286 */
+#define E32CPU286       1
+/** e32_cpu - 80386 */
+#define E32CPU386       2
+/** e32_cpu - 80486 */
+#define E32CPU486       3
+/** e32_pagesize */
+#define OBJPAGELEN      KU32_C(0x1000)
+
+
+/** @name e32_mflags
+ * @{ */
+/** App Type: Fullscreen only. */
+#define E32NOPMW         KU32_C(0x00000100)
+/** App Type: PM API. */
+#define E32PMAPI         KU32_C(0x00000300)
+/** App Type: PM VIO compatible. */
+#define E32PMW           KU32_C(0x00000200)
+/** Application type mask. */
+#define E32APPMASK       KU32_C(0x00000300)
+/** Executable module. */
+#define E32MODEXE        KU32_C(0x00000000)
+/** Dynamic link library (DLL / library) module. */
+#define E32MODDLL        KU32_C(0x00008000)
+/** Protected memory DLL. */
+#define E32PROTDLL       KU32_C(0x00010000)
+/** Physical Device Driver. */
+#define E32MODPDEV       KU32_C(0x00020000)
+/** Virtual Device Driver. */
+#define E32MODVDEV       KU32_C(0x00028000)
+/** Device driver */
+#define E32DEVICE        E32MODPDEV
+/** Dynamic link library (DLL / library) module. */
+#define E32NOTP          E32MODDLL
+/** Protected memory DLL. */
+#define E32MODPROTDLL    (E32MODDLL | E32PROTDLL)
+/** Module Type mask. */
+#define E32MODMASK       KU32_C(0x00038000)
+/** Not loadable (linker error). */
+#define E32NOLOAD        KU32_C(0x00002000)
+/** No internal fixups. */
+#define E32NOINTFIX      KU32_C(0x00000010)
+/** No external fixups (i.e. imports). */
+#define E32NOEXTFIX      KU32_C(0x00000020)
+/** System DLL, no internal fixups. */
+#define E32SYSDLL        KU32_C(0x00000008)
+/** Global (set) or per instance (cleared) library initialization. */
+#define E32LIBINIT       KU32_C(0x00000004)
+/** Global (set) or per instance (cleared) library termination. */
+#define E32LIBTERM       KU32_C(0x40000000)
+/** Indicates when set in an executable that the process isn't SMP safe. */
+#define E32NOTMPSAFE     KU32_C(0x00080000)
+/** @} */
+
+/** @name Relocations (aka Fixups).
+ * @{ */
+typedef union _offset
+{
+    KU16                offset16;
+    KU32                offset32;
+} offset;
+
+/** A relocation.
+ * @remark this structure isn't very usable since LX relocations comes in too many size variations.
+ */
+struct r32_rlc
+{
+    KU8                 nr_stype;
+    KU8                 nr_flags;
+    KI16                r32_soff;
+    KU16                r32_objmod;
+
+    union targetid
+    {
+        offset          intref;
+        union extfixup
+        {
+            offset      proc;
+            KU32        ord;
+        } extref;
+        struct addfixup
+        {
+            KU16        entry;
+            offset      addval;
+        } addfix;
+    } r32_target;
+    KU16                r32_srccount;
+    KU16                r32_chain;
+};
+
+/** @name Some attempt at size constanstants.
+ * @{
+ */
+#define RINTSIZE16      8
+#define RINTSIZE32      10
+#define RORDSIZE        8
+#define RNAMSIZE16      8
+#define RNAMSIZE32      10
+#define RADDSIZE16      10
+#define RADDSIZE32      12
+/** @} */
+
+/** @name nr_stype (source flags)
+ * @{ */
+#define NRSBYT          0x00
+#define NRSSEG          0x02
+#define NRSPTR          0x03
+#define NRSOFF          0x05
+#define NRPTR48         0x06
+#define NROFF32         0x07
+#define NRSOFF32        0x08
+#define NRSTYP          0x0f
+#define NRSRCMASK       0x0f
+#define NRALIAS         0x10
+#define NRCHAIN         0x20
+/** @} */
+
+/** @name nr_flags (target flags)
+ * @{ */
+#define NRRINT          0x00
+#define NRRORD          0x01
+#define NRRNAM          0x02
+#define NRRENT          0x03
+#define NRRTYP          0x03
+#define NRADD           0x04
+#define NRICHAIN        0x08
+#define NR32BITOFF      0x10
+#define NR32BITADD      0x20
+#define NR16OBJMOD      0x40
+#define NR8BITORD       0x80
+/** @} */
+
+/** @} */
+
+
+/** @name The Object Table (aka segment table)
+ * @{ */
+
+/** The Object Table Entry. */
+struct o32_obj
+{
+    /** The size of the object. */
+    KU32                o32_size;
+    /** The base address of the object. */
+    KU32                o32_base;
+    /** Object flags. */
+    KU32                o32_flags;
+    /** Page map index. */
+    KU32                o32_pagemap;
+    /** Page map size. (doesn't need to be o32_size >> page shift). */
+    KU32                o32_mapsize;
+    /** Reserved */
+    KU32                o32_reserved;
+};
+
+/** @name o32_flags
+ * @{ */
+/** Read access. */
+#define OBJREAD         KU32_C(0x00000001)
+/** Write access. */
+#define OBJWRITE        KU32_C(0x00000002)
+/** Execute access. */
+#define OBJEXEC         KU32_C(0x00000004)
+/** Resource object. */
+#define OBJRSRC         KU32_C(0x00000008)
+/** The object is discarable (i.e. don't swap, just load in pages from the executable).
+ * This overlaps a bit with object type. */
+#define OBJDISCARD      KU32_C(0x00000010)
+/** The object is shared. */
+#define OBJSHARED       KU32_C(0x00000020)
+/** The object has preload pages. */
+#define OBJPRELOAD      KU32_C(0x00000040)
+/** The object has invalid pages. */
+#define OBJINVALID      KU32_C(0x00000080)
+/** Non-permanent, link386 bug. */
+#define LNKNONPERM      KU32_C(0x00000600)
+/** Non-permanent, correct 'value'. */
+#define OBJNONPERM      KU32_C(0x00000000)
+/** Obj Type: The object is permanent and swappable. */
+#define OBJPERM         KU32_C(0x00000100)
+/** Obj Type: The object is permanent and resident (i.e. not swappable). */
+#define OBJRESIDENT     KU32_C(0x00000200)
+/** Obj Type: The object is resident and contigious. */
+#define OBJCONTIG       KU32_C(0x00000300)
+/** Obj Type: The object is permanent and long locable. */
+#define OBJDYNAMIC      KU32_C(0x00000400)
+/** Object type mask. */
+#define OBJTYPEMASK     KU32_C(0x00000700)
+/** x86: The object require an 16:16 alias. */
+#define OBJALIAS16      KU32_C(0x00001000)
+/** x86: Big/Default selector setting, i.e. toggle 32-bit or 16-bit. */
+#define OBJBIGDEF       KU32_C(0x00002000)
+/** x86: conforming selector setting (weird stuff). */
+#define OBJCONFORM      KU32_C(0x00004000)
+/** x86: IOPL. */
+#define OBJIOPL         KU32_C(0x00008000)
+/** @} */
+
+/** A Object Page Map Entry. */
+struct o32_map
+{
+    /** The file offset of the page. */
+    KU32                o32_pagedataoffset;
+    /** The number of bytes of raw page data. */
+    KU16                o32_pagesize;
+    /** Per page flags describing how the page is encoded in the file. */
+    KU16                o32_pageflags;
+};
+
+/** @name o32 o32_pageflags
+ * @{
+ */
+/** Raw page (uncompressed) in the file. */
+#define VALID           KU16_C(0x0000)
+/** RLE encoded page in file. */
+#define ITERDATA        KU16_C(0x0001)
+/** Invalid page, nothing in the file. */
+#define INVALID         KU16_C(0x0002)
+/** Zero page, nothing in file. */
+#define ZEROED          KU16_C(0x0003)
+/** range of pages (what is this?) */
+#define RANGE           KU16_C(0x0004)
+/** Compressed page in file. */
+#define ITERDATA2       KU16_C(0x0005)
+/** @} */
+
+
+/** Iteration Record format (RLE compressed page). */
+struct LX_Iter
+{
+    /** Number of iterations. */
+    KU16                LX_nIter;
+    /** The number of bytes that's being iterated. */
+    KU16                LX_nBytes;
+    /** The bytes. */
+    KU8                 LX_Iterdata;
+};
+
+/** @} */
+
+
+/** A Resource Table Entry */
+struct rsrc32
+{
+    /** Resource Type. */
+    KU16                type;
+    /** Resource ID. */
+    KU16                name;
+    /** Resource size in bytes. */
+    KU32                cb;
+    /** The index of the object containing the resource. */
+    KU16                obj;
+    /** Offset of the resource that within the object. */
+    KU32                offset;
+};
+
+
+/** @name The Entry Table (aka Export Table)
+ * @{ */
+
+/** Entry bundle.
+ * Header descripting up to 255 entries that follows immediatly after this structure. */
+struct b32_bundle
+{
+    /** The number of entries. */
+    KU8                 b32_cnt;
+    /** The type of bundle. */
+    KU8                 b32_type;
+    /** The index of the object containing these entry points. */
+    KU16                b32_obj;
+};
+
+/** @name b32_type
+ * @{ */
+/** Empty bundle, filling up unused ranges of ordinals. */
+#define EMPTY           0x00
+/** 16-bit offset entry point. */
+#define ENTRY16         0x01
+/** 16-bit callgate entry point. */
+#define GATE16          0x02
+/** 32-bit offset entry point. */
+#define ENTRY32         0x03
+/** Forwarder entry point. */
+#define ENTRYFWD        0x04
+/** Typing information present indicator. */
+#define TYPEINFO        0x80
+/** @} */
+
+
+/** Entry point. */
+struct e32_entry
+{
+    /** Entry point flags */
+    KU8                 e32_flags;      /* Entry point flags */
+    union entrykind
+    {
+        /** ENTRY16 or ENTRY32. */
+        offset          e32_offset;
+        /** GATE16 */
+        struct callgate
+        {
+            /** Offset into segment. */
+            KU16        offset;
+            /** The callgate selector */
+            KU16        callgate;
+        } e32_callgate;
+        /** ENTRYFWD */
+        struct fwd
+        {
+            /** Module ordinal number (i.e. into the import module table). */
+            KU16        modord;
+            /** Procedure name or ordinal number. */
+            KU32        value;
+        } e32_fwd;
+    } e32_variant;
+};
+
+/** @name e32_flags
+ * @{ */
+/** Exported entry (set) or private entry (clear). */
+#define E32EXPORT       0x01
+/** Uses shared data. */
+#define E32SHARED       0x02
+/** Parameter word count mask. */
+#define E32PARAMS       0xf8
+/** ENTRYFWD: Imported by ordinal (set) or by name (clear). */
+#define FWD_ORDINAL     0x01
+/** @} */
+
+/** @name dunno
+ * @{ */
+#define FIXENT16        3
+#define FIXENT32        5
+#define GATEENT16       5
+#define FWDENT          7
+/** @} */
+
+#pragma pack()
+
+#endif
+
Index: /trunk/kStuff/include/k/kLdrFmts/mach-o.h
===================================================================
--- /trunk/kStuff/include/k/kLdrFmts/mach-o.h	(revision 3568)
+++ /trunk/kStuff/include/k/kLdrFmts/mach-o.h	(revision 3568)
@@ -0,0 +1,902 @@
+/* $Id $ */
+/** @file
+ * Mach-0 structures, types and defines.
+ */
+
+#ifndef ___k_kLdrFmts_mach_o_h___
+#define ___k_kLdrFmts_mach_o_h___
+
+#include <k/kDefs.h>
+#include <k/kTypes.h>
+
+
+/** @defgroup grp_mach_o    The Mach-O Structures, Types, and Defines.
+ * @{
+ */
+
+
+#ifndef IMAGE_FAT_SIGNATURE
+/** The FAT signature (universal binaries). */
+# define IMAGE_FAT_SIGNATURE            KU32_C(0xcafebabe)
+#endif
+#ifndef IMAGE_FAT_SIGNATURE_OE
+/** The FAT signature (universal binaries), other endian. */
+# define IMAGE_FAT_SIGNATURE_OE         KU32_C(0xbebafeca)
+#endif
+
+/**
+ * The fat header found at the start of universal binaries.
+ * It is followed by \a nfat_arch numbers of \a fat_arch structures.
+ */
+typedef struct fat_header
+{
+    KU32            magic;
+    KU32            nfat_arch;
+} fat_header_t;
+
+/**
+ * Description of fat file item.
+ */
+typedef struct fat_arch
+{
+    KI32            cputype;
+    KI32            cpusubtype;
+    KU32            offset;
+    KU32            size;
+    KU32            align;          /**< Power of 2. */
+} fat_arch_t;
+
+
+
+#ifndef IMAGE_MACHO32_SIGNATURE
+/** The 32-bit Mach-O signature. */
+# define IMAGE_MACHO32_SIGNATURE        KU32_C(0xfeedface)
+#endif
+#ifndef IMAGE_MACHO32_SIGNATURE_OE
+/** The 32-bit Mach-O signature, other endian. */
+# define IMAGE_MACHO32_SIGNATURE_OE     KU32_C(0xcefaedfe)
+#endif
+#define MH_MAGIC    IMAGE_MACHO32_SIGNATURE
+#define MH_CIGAM    IMAGE_MACHO32_SIGNATURE_OE
+
+/**
+ * 32-bit Mach-O header.
+ * This is followed by \a ncmds number of load commands.
+ * @see mach_header_64
+ */
+typedef struct mach_header_32
+{
+    KU32            magic;
+    KI32            cputype;
+    KI32            cpusubtype;
+    KU32            filetype;
+    KU32            ncmds;
+    KU32            sizeofcmds;
+    KU32            flags;
+} mach_header_32_t;
+
+
+
+#ifndef IMAGE_MACHO64_SIGNATURE
+/** The 64-bit Mach-O signature. */
+# define IMAGE_MACHO64_SIGNATURE        KU32_C(0xfeedfacf)
+#endif
+#ifndef IMAGE_MACHO64_SIGNATURE_OE
+/** The 64-bit Mach-O signature, other endian. */
+# define IMAGE_MACHO64_SIGNATURE_OE     KU32_C(0xfefaedfe)
+#endif
+#define MH_MAGIC_64 IMAGE_MACHO64_SIGNATURE
+#define MH_CIGAM_64 IMAGE_MACHO64_SIGNATURE_OE
+
+/**
+ * 64-bit Mach-O header.
+ * This is followed by \a ncmds number of load commands.
+ * @see mach_header
+ */
+typedef struct mach_header_64
+{
+    KU32            magic;
+    KI32            cputype;
+    KI32            cpusubtype;
+    KU32            filetype;
+    KU32            ncmds;
+    KU32            sizeofcmds;
+    KU32            flags;
+    KU32            reserved;       /**< (for proper struct and command alignment I guess) */
+} mach_header_64_t;
+
+
+/** @name File types (mach_header_64::filetype, mach_header_32::filetype)
+ * @{
+ */
+#define MH_OBJECT           KU32_C(1) /**< Object (relocatable). */
+#define MH_EXECUTE          KU32_C(2) /**< Executable (demand paged). */
+#define MH_FVMLIB           KU32_C(3) /**< Fixed VM shared library. */
+#define MH_CORE             KU32_C(4) /**< Core file. */
+#define MH_PRELOAD          KU32_C(5) /**< Preloaded executable. */
+#define MH_DYLIB            KU32_C(6) /**< Dynamically bound shared library. */
+#define MH_DYLINKER         KU32_C(7) /**< Dynamic linker. */
+#define MH_BUNDLE           KU32_C(8) /**< Dymamically bound bundle. */
+#define MH_DYLIB_STUB       KU32_C(9) /**< Shared library stub for static linking. */
+#define MH_DSYM             KU32_C(10)/**< Debug symbols. */
+
+/** @} */
+
+
+/** @name Mach-O Header flags (mach_header_64::flags, mach_header_32::flags)
+ * @{
+ */
+#define MH_NOUNDEFS                 KU32_C(0x00000001) /**< No undefined symbols. */
+#define MH_INCRLINK                 KU32_C(0x00000002) /**< Partial increment link output. */
+#define MH_DYLDLINK                 KU32_C(0x00000004) /**< Food for the dynamic linker, not for ld. */
+#define MH_BINDATLOAD               KU32_C(0x00000008) /**< Bind all undefined symbols at load time. */
+#define MH_PREBOUND                 KU32_C(0x00000010) /**< Contains prebound undefined symbols. */
+#define MH_SPLIT_SEGS               KU32_C(0x00000020) /**< Read-only and read-write segments are split. */
+#define MH_LAZY_INIT                KU32_C(0x00000040) /**< Obsolete flag for doing lazy init when data is written. */
+#define MH_TWOLEVEL                 KU32_C(0x00000080) /**< Uses two-level name space bindings. */
+#define MH_FORCE_FLAT               KU32_C(0x00000100) /**< Task: The executable forces all images to use flat name space bindings. */
+#define MH_NOMULTIDEFS              KU32_C(0x00000200) /**< No multiple symbol definitions, safe to use two-level namespace hints. */
+#define MH_NOFIXPREBINDING          KU32_C(0x00000400) /**< The dynamic linker should not notify the prebinding agent about this executable. */
+#define MH_PREBINDABLE              KU32_C(0x00000800) /**< Not prebound, but it can be. Invalid if MH_PREBOUND is set. */
+#define MH_ALLMODSBOUND             KU32_C(0x00001000) /**< Binds to all two-level namespace modules of preqs. Requires MH_PREBINDABLE and MH_TWOLEVEL to be set. */
+#define MH_SUBSECTIONS_VIA_SYMBOLS  KU32_C(0x00002000) /**< Safe to divide sections into sub-sections via symbols for dead code stripping. */
+#define MH_CANONICAL                KU32_C(0x00004000) /**< Canonicalized via unprebind. */
+#define MH_WEAK_DEFINES             KU32_C(0x00008000) /**< The (finally) linked image has weak symbols. */
+#define MH_BINDS_TO_WEAK            KU32_C(0x00010000) /**< The (finally) linked image uses weak symbols. */
+#define MH_ALLOW_STACK_EXECUTION    KU32_C(0x00020000) /**< Task: allow stack execution. (MH_EXECUTE only) */
+#define MH_VALID_FLAGS              KU32_C(0x0003ffff) /**< Mask containing the defined flags. */
+/** @} */
+
+
+/** @name CPU types / bits (mach_header_64::cputype, mach_header_32::cputype, fat_arch::cputype)
+ * @{
+ */
+#define CPU_ARCH_MASK               KI32_C(0xff000000)
+#define CPU_ARCH_ABI64              KI32_C(0x01000000)
+#define CPU_TYPE_ANY                KI32_C(-1)
+#define CPU_TYPE_VAX                KI32_C(1)
+#define CPU_TYPE_MC680x0            KI32_C(6)
+#define CPU_TYPE_X86                KI32_C(7)
+#define CPU_TYPE_I386               CPU_TYPE_X86
+#define CPU_TYPE_X86_64             (CPU_TYPE_X86 | CPU_ARCH_ABI64)
+#define CPU_TYPE_MC98000            KI32_C(10)
+#define CPU_TYPE_HPPA               KI32_C(11)
+#define CPU_TYPE_MC88000            KI32_C(13)
+#define CPU_TYPE_SPARC              KI32_C(14)
+#define CPU_TYPE_I860               KI32_C(15)
+#define CPU_TYPE_POWERPC            KI32_C(18)
+#define CPU_TYPE_POWERPC64          (CPU_TYPE_POWERPC | CPU_ARCH_ABI64)
+/** @} */
+
+
+/** @name CPU subtypes (mach_header_64::cpusubtype, mach_header_32::cpusubtype, fat_arch::cpusubtype)
+ * @{ */
+#define CPU_SUBTYPE_MULTIPLE        KI32_C(-1)
+#define CPU_SUBTYPE_LITTLE_ENDIAN   KI32_C(0)  /**< figure this one out. */
+#define CPU_SUBTYPE_BIG_ENDIAN      KI32_C(1)  /**< ditto */
+
+/* VAX */
+#define CPU_SUBTYPE_VAX_ALL         KI32_C(0)
+#define CPU_SUBTYPE_VAX780          KI32_C(1)
+#define CPU_SUBTYPE_VAX785          KI32_C(2)
+#define CPU_SUBTYPE_VAX750          KI32_C(3)
+#define CPU_SUBTYPE_VAX730          KI32_C(4)
+#define CPU_SUBTYPE_UVAXI           KI32_C(5)
+#define CPU_SUBTYPE_UVAXII          KI32_C(6)
+#define CPU_SUBTYPE_VAX8200         KI32_C(7)
+#define CPU_SUBTYPE_VAX8500         KI32_C(8)
+#define CPU_SUBTYPE_VAX8600         KI32_C(9)
+#define CPU_SUBTYPE_VAX8650         KI32_C(10)
+#define CPU_SUBTYPE_VAX8800         KI32_C(11)
+#define CPU_SUBTYPE_UVAXIII         KI32_C(12)
+
+/* MC680xx */
+#define CPU_SUBTYPE_MC680x0_ALL     KI32_C(1)
+#define CPU_SUBTYPE_MC68030         KI32_C(1)
+#define CPU_SUBTYPE_MC68040         KI32_C(2)
+#define CPU_SUBTYPE_MC68030_ONLY    KI32_C(3)
+
+/* I386 */
+#define CPU_SUBTYPE_INTEL(fam, model)       ( (KI32)(((model) << 4) | (fam)) )
+#define CPU_SUBTYPE_INTEL_FAMILY(subtype)   ( (subtype) & 0xf )
+#define CPU_SUBTYPE_INTEL_MODEL(subtype)    ( (subtype) >> 4 )
+#define CPU_SUBTYPE_INTEL_FAMILY_MAX        0xf
+#define CPU_SUBTYPE_INTEL_MODEL_ALL         0
+
+#define CPU_SUBTYPE_I386_ALL        CPU_SUBTYPE_INTEL(3, 0)
+#define CPU_SUBTYPE_386             CPU_SUBTYPE_INTEL(3, 0)
+#define CPU_SUBTYPE_486             CPU_SUBTYPE_INTEL(4, 0)
+#define CPU_SUBTYPE_486SX           CPU_SUBTYPE_INTEL(4, 8)
+#define CPU_SUBTYPE_586             CPU_SUBTYPE_INTEL(5, 0)
+#define CPU_SUBTYPE_PENT            CPU_SUBTYPE_INTEL(5, 0)
+#define CPU_SUBTYPE_PENTPRO         CPU_SUBTYPE_INTEL(6, 1)
+#define CPU_SUBTYPE_PENTII_M3       CPU_SUBTYPE_INTEL(6, 3)
+#define CPU_SUBTYPE_PENTII_M5       CPU_SUBTYPE_INTEL(6, 5)
+#define CPU_SUBTYPE_CELERON         CPU_SUBTYPE_INTEL(7, 6)
+#define CPU_SUBTYPE_CELERON_MOBILE  CPU_SUBTYPE_INTEL(7, 7)
+#define CPU_SUBTYPE_PENTIUM_3       CPU_SUBTYPE_INTEL(8, 0)
+#define CPU_SUBTYPE_PENTIUM_3_M     CPU_SUBTYPE_INTEL(8, 1)
+#define CPU_SUBTYPE_PENTIUM_3_XEON  CPU_SUBTYPE_INTEL(8, 2)
+#define CPU_SUBTYPE_PENTIUM_M       CPU_SUBTYPE_INTEL(9, 0)
+#define CPU_SUBTYPE_PENTIUM_4       CPU_SUBTYPE_INTEL(10, 0)
+#define CPU_SUBTYPE_PENTIUM_4_M     CPU_SUBTYPE_INTEL(10, 1)
+#define CPU_SUBTYPE_ITANIUM         CPU_SUBTYPE_INTEL(11, 0)
+#define CPU_SUBTYPE_ITANIUM_2       CPU_SUBTYPE_INTEL(11, 1)
+#define CPU_SUBTYPE_XEON            CPU_SUBTYPE_INTEL(12, 0)
+#define CPU_SUBTYPE_XEON_MP         CPU_SUBTYPE_INTEL(12, 1)
+
+/* X86 */
+#define CPU_SUBTYPE_X86_ALL         KI32_C(3) /* CPU_SUBTYPE_I386_ALL */
+#define CPU_SUBTYPE_X86_64_ALL      KI32_C(3) /* CPU_SUBTYPE_I386_ALL */
+#define CPU_SUBTYPE_X86_ARCH1       KI32_C(4) /* CPU_SUBTYPE_I486_ALL */
+
+/* MIPS */
+#define CPU_SUBTYPE_MIPS_ALL        KI32_C(0)
+#define CPU_SUBTYPE_MIPS_R2300      KI32_C(1)
+#define CPU_SUBTYPE_MIPS_R2600      KI32_C(2)
+#define CPU_SUBTYPE_MIPS_R2800      KI32_C(3)
+#define CPU_SUBTYPE_MIPS_R2000a     KI32_C(4)
+#define CPU_SUBTYPE_MIPS_R2000      KI32_C(5)
+#define CPU_SUBTYPE_MIPS_R3000a     KI32_C(6)
+#define CPU_SUBTYPE_MIPS_R3000      KI32_C(7)
+
+/* MC98000 (PowerPC) */
+#define CPU_SUBTYPE_MC98000_ALL     KI32_C(0)
+#define CPU_SUBTYPE_MC98601         KI32_C(1)
+
+/* HP-PA */
+#define CPU_SUBTYPE_HPPA_ALL        KI32_C(0)
+#define CPU_SUBTYPE_HPPA_7100       KI32_C(0)
+#define CPU_SUBTYPE_HPPA_7100LC     KI32_C(1)
+
+/* MC88000 */
+#define CPU_SUBTYPE_MC88000_ALL     KI32_C(0)
+#define CPU_SUBTYPE_MC88100         KI32_C(1)
+#define CPU_SUBTYPE_MC88110         KI32_C(2)
+
+/* SPARC */
+#define CPU_SUBTYPE_SPARC_ALL       KI32_C(0)
+
+/* I860 */
+#define CPU_SUBTYPE_I860_ALL        KI32_C(0)
+#define CPU_SUBTYPE_I860_860        KI32_C(1)
+
+/* PowerPC */
+#define CPU_SUBTYPE_POWERPC_ALL     KI32_C(0)
+#define CPU_SUBTYPE_POWERPC_601     KI32_C(1)
+#define CPU_SUBTYPE_POWERPC_602     KI32_C(2)
+#define CPU_SUBTYPE_POWERPC_603     KI32_C(3)
+#define CPU_SUBTYPE_POWERPC_603e    KI32_C(4)
+#define CPU_SUBTYPE_POWERPC_603ev   KI32_C(5)
+#define CPU_SUBTYPE_POWERPC_604     KI32_C(6)
+#define CPU_SUBTYPE_POWERPC_604e    KI32_C(7)
+#define CPU_SUBTYPE_POWERPC_620     KI32_C(8)
+#define CPU_SUBTYPE_POWERPC_750     KI32_C(9)
+#define CPU_SUBTYPE_POWERPC_7400    KI32_C(10)
+#define CPU_SUBTYPE_POWERPC_7450    KI32_C(11)
+#define CPU_SUBTYPE_POWERPC_Max     KI32_C(10)
+#define CPU_SUBTYPE_POWERPC_SCVger  KI32_C(11)
+#define CPU_SUBTYPE_POWERPC_970     KI32_C(100)
+
+/** @} */
+
+
+
+/** @defgroup grp_macho_o_lc        Load Commands
+ * @{ */
+
+/**
+ * The load command common core structure.
+ *
+ * After the Mach-O header follows an array of variable sized
+ * load command which all has this header in common.
+ */
+typedef struct load_command
+{
+    KU32            cmd;            /**< The load command id. */
+    KU32            cmdsize;        /**< The size of the command (including this header). */
+} load_command_t;
+
+/** @name Load Command IDs (load_command::cmd)
+ * @{
+ */
+/** Flag that when set requires the dynamic linker to fail if it doesn't
+ * grok the command. The dynamic linker will otherwise ignore commands it
+ * doesn't understand. Introduced with Mac OS X 10.1. */
+#define LC_REQ_DYLD         KU32_C(0x80000000)
+
+#define LC_SEGMENT_32       KU32_C(0x01)  /**< Segment to be mapped (32-bit). See segment_command_32. */
+#define LC_SYMTAB           KU32_C(0x02)  /**< 'stab' symbol table. See symtab_command. */
+#define LC_SYMSEG           KU32_C(0x03)  /**< Obsoleted gdb symbol table. */
+#define LC_THREAD           KU32_C(0x04)  /**< Thread. See thread_command. */
+#define LC_UNIXTHREAD       KU32_C(0x05)  /**< Unix thread (includes stack and stuff). See thread_command. */
+#define LC_LOADFVMLIB       KU32_C(0x06)  /**< Load a specified fixed VM shared library  (obsolete?). See fvmlib_command. */
+#define LC_IDFVMLIB         KU32_C(0x07)  /**< Fixed VM shared library id (obsolete?). See fvmlib_command. */
+#define LC_IDENT            KU32_C(0x08)  /**< Identification info (obsolete). See ident_command. */
+#define LC_FVMFILE          KU32_C(0x09)  /**< Fixed VM file inclusion (internal). See fvmfile_command. */
+#define LC_PREPAGE          KU32_C(0x0a)  /**< Prepage command (internal). See ?? */
+#define LC_DYSYMTAB         KU32_C(0x0b)  /**< Symbol table for dynamic linking. See dysymtab_command. */
+#define LC_LOAD_DYLIB       KU32_C(0x0c)  /**< Load a dynamically linked shared library. See dylib_command. */
+#define LC_ID_DYLIB         KU32_C(0x0d)  /**< Dynamically linked share library ident. See dylib_command. */
+#define LC_LOAD_DYLINKER    KU32_C(0x0e)  /**< Load a dynamical link editor. See dylinker_command. */
+#define LC_ID_DYLINKER      KU32_C(0x0f)  /**< Dynamic link editor ident. See dylinker_command. */
+#define LC_PREBOUND_DYLIB   KU32_C(0x10)  /**< Prebound modules for dynamically linking of a shared lib. See prebound_dylib_command. */
+#define LC_ROUTINES         KU32_C(0x11)  /**< Image routines. See routines_command_32. */
+#define LC_SUB_FRAMEWORK    KU32_C(0x12)  /**< Sub framework. See sub_framework_command. */
+#define LC_SUB_UMBRELLA     KU32_C(0x13)  /**< Sub umbrella. See sub_umbrella_command. */
+#define LC_SUB_CLIENT       KU32_C(0x14)  /**< Sub client. See sub_client_command. */
+#define LC_SUB_LIBRARY      KU32_C(0x15)  /**< Sub library. See sub_library_command. */
+#define LC_TWOLEVEL_HINTS   KU32_C(0x16)  /**< Two-level namespace lookup hints. See twolevel_hints_command. */
+#define LC_PREBIND_CKSUM    KU32_C(0x17)  /**< Prebind checksum. See prebind_cksum_command. */
+#define LC_LOAD_WEAK_DYLIB (KU32_C(0x18) | LC_REQ_DYLD) /**< Dylib that can be missing, all symbols weak. See dylib_command. */
+#define LC_SEGMENT_64       KU32_C(0x19)  /**< segment to be mapped (64-bit). See segment_command_32. */
+#define LC_ROUTINES_64      KU32_C(0x1a)  /**< Image routines (64-bit). See routines_command_32. */
+#define LC_UUID             KU32_C(0x1b)  /**< The UUID of the object module. See uuid_command.  */
+/** @} */
+
+
+/**
+ * Load Command String.
+ */
+typedef struct lc_str
+{
+    /** Offset of the string relative to the load_command structure.
+     * The string is zero-terminated. the size of the load command
+     * is zero padded up to a multiple of 4 bytes. */
+    KU32            offset;
+} lc_str_t;
+
+
+/**
+ * Segment load command (32-bit).
+ */
+typedef struct segment_command_32
+{
+    KU32            cmd;            /**< LC_SEGMENT */
+    KU32            cmdsize;        /**< sizeof(self) + sections. */
+    char            segname[16];    /**< The segment name. */
+    KU32            vmaddr;         /**< Memory address of this segment. */
+    KU32            vmsize;         /**< Size of this segment. */
+    KU32            fileoff;        /**< The file location of the segment. */
+    KU32            filesize;       /**< The file size of the segment. */
+    KU32            maxprot;        /**< Maximum VM protection. */
+    KU32            initprot;       /**< Initial VM protection. */
+    KU32            nsects;         /**< Number of section desciptors following this structure. */
+    KU32            flags;          /**< Flags (SG_*). */
+} segment_command_32_t;
+
+
+/**
+ * Segment load command (64-bit).
+ * Same as segment_command_32 except 4 members has been blown up to 64-bit.
+ */
+typedef struct segment_command_64
+{
+    KU32            cmd;            /**< LC_SEGMENT */
+    KU32            cmdsize;        /**< sizeof(self) + sections. */
+    char            segname[16];    /**< The segment name. */
+    KU64            vmaddr;         /**< Memory address of this segment. */
+    KU64            vmsize;         /**< Size of this segment. */
+    KU64            fileoff;        /**< The file location of the segment. */
+    KU64            filesize;       /**< The file size of the segment. */
+    KU32            maxprot;        /**< Maximum VM protection. */
+    KU32            initprot;       /**< Initial VM protection. */
+    KU32            nsects;         /**< Number of section desciptors following this structure. */
+    KU32            flags;          /**< Flags (SG_*). */
+} segment_command_64_t;
+
+/** @name Segment flags (segment_command_64::flags, segment_command_32::flags)
+ * @{ */
+/** Map the file bits in the top end of the memory area for the segment
+ * instead of the low end. Intended for stacks in core dumps.
+ * The part of the segment memory not covered by file bits will be zeroed. */
+#define SG_HIGHVM           KU32_C(0x00000001)
+/** This segment is the virtual memory allocated by a fixed VM library.
+ * (Used for overlap checking in the linker.) */
+#define SG_FVMLIB           KU32_C(0x00000002)
+/** No relocations for or symbols that's relocated to in this segment.
+ * The segment can therefore safely be replaced. */
+#define SG_NORELOC          KU32_C(0x00000004)
+/** The segment is protected.
+ * The first page isn't protected if it starts at file offset 0
+ * (so that the mach header and this load command can be easily mapped). */
+#define SG_PROTECTED_VERSION_1 KU32_C(0x00000008)
+/** @} */
+
+
+/**
+ * 32-bit section (part of a segment load command).
+ */
+typedef struct section_32
+{
+    char            sectname[16];   /**< The section name. */
+    char            segname[16];    /**< The name of the segment this section goes into. */
+    KU32            addr;           /**< The memory address of this section. */
+    KU32            size;           /**< The size of this section. */
+    KU32            offset;         /**< The file offset of this section. */
+    KU32            align;          /**< The section alignment (**2). */
+    KU32            reloff;         /**< The file offset of the relocations. */
+    KU32            nreloc;         /**< The number of relocations. */
+    KU32            flags;          /**< The section flags; section type and attribs */
+    KU32            reserved1;      /**< Reserved / offset / index. */
+    KU32            reserved2;      /**< Reserved / count / sizeof. */
+} section_32_t;
+
+/**
+ * 64-bit section (part of a segment load command).
+ */
+typedef struct section_64
+{
+    char            sectname[16];   /**< The section name. */
+    char            segname[16];    /**< The name of the segment this section goes into. */
+    KU64            addr;           /**< The memory address of this section. */
+    KU64            size;           /**< The size of this section. */
+    KU32            offset;         /**< The file offset of this section. */
+    KU32            align;          /**< The section alignment (**2). */
+    KU32            reloff;         /**< The file offset of the relocations. */
+    KU32            nreloc;         /**< The number of relocations. */
+    KU32            flags;          /**< The section flags; section type and attribs */
+    KU32            reserved1;      /**< Reserved / offset / index. */
+    KU32            reserved2;      /**< Reserved / count / sizeof. */
+    KU32            reserved3;      /**< (Just) Reserved. */
+} section_64_t;
+
+/** @name Section flags (section_64::flags, section_32::flags)
+ * @{
+ */
+/** Section type mask. */
+#define SECTION_TYPE                KU32_C(0x000000ff)
+/** Regular section. */
+#define S_REGULAR                   0x0
+/** Zero filled section. */
+#define S_ZEROFILL                  0x1
+/** C literals. */
+#define S_CSTRING_LITERALS          0x2
+/** 4 byte literals. */
+#define S_4BYTE_LITERALS            0x3
+/** 8 byte literals. */
+#define S_8BYTE_LITERALS            0x4
+/** Pointer to literals. */
+#define S_LITERAL_POINTERS          0x5
+/** Section containing non-lazy symbol pointers.
+ * Reserved1 == start index in the indirect symbol table. */
+#define S_NON_LAZY_SYMBOL_POINTERS  0x6
+/** Section containing lazy symbol pointers.
+ * Reserved1 == start index in the indirect symbol table. */
+#define S_LAZY_SYMBOL_POINTERS      0x7
+/** Section containing symbol stubs.
+ * Reserved2 == stub size. */
+#define S_SYMBOL_STUBS              0x8
+/** Section containing function pointers for module initialization. . */
+#define S_MOD_INIT_FUNC_POINTERS    0x9
+/** Section containing function pointers for module termination. . */
+#define S_MOD_TERM_FUNC_POINTERS    0xa
+/** Section containing symbols that are to be coalesced. */
+#define S_COALESCED                 0xb
+/** Zero filled section that be larger than 4GB. */
+#define S_GB_ZEROFILL               0xc
+/** Section containing pairs of function pointers for interposing. */
+#define S_INTERPOSING               0xd
+/** 16 byte literals. */
+#define S_16BYTE_LITERALS           0xe
+
+/** Section attribute mask. */
+#define SECTION_ATTRIBUTES          KU32_C(0xffffff00)
+
+/** User settable attribute mask. */
+#define SECTION_ATTRIBUTES_USR      KU32_C(0xff000000)
+/** Pure instruction (code). */
+#define S_ATTR_PURE_INSTRUCTIONS    KU32_C(0x80000000)
+/** ranlib, ignore my symbols... */
+#define S_ATTR_NO_TOC               KU32_C(0x40000000)
+/** May strip static symbols when linking int a MH_DYLDLINK file. */
+#define S_ATTR_STRIP_STATIC_SYMS    KU32_C(0x20000000)
+/** No dead stripping. */
+#define S_ATTR_NO_DEAD_STRIP        KU32_C(0x10000000)
+/** Live support. */
+#define S_ATTR_LIVE_SUPPORT         KU32_C(0x08000000)
+/** Contains self modifying code (generally i386 code stub for dyld). */
+#define S_ATTR_SELF_MODIFYING_CODE  KU32_C(0x04000000)
+/** Debug info (DWARF usually). */
+#define S_ATTR_DEBUG                KU32_C(0x02000000)
+
+/** System settable attribute mask. */
+#define SECTION_ATTRIBUTES_SYS      KU32_C(0x00ffff00)
+/** Contains some instructions (code). */
+#define S_ATTR_SOME_INSTRUCTIONS    KU32_C(0x00000400)
+/** Has external relocations. */
+#define S_ATTR_EXT_RELOC            KU32_C(0x00000200)
+/** Has internal (local) relocations. */
+#define S_ATTR_LOC_RELOC            KU32_C(0x00000100)
+/** @} */
+
+/** @name Known Segment and Section Names.
+ * Some of these implies special linker behaviour.
+ * @{
+ */
+/** Page zero - not-present page for catching invalid access. (MH_EXECUTE typically) */
+#define SEG_PAGEZERO        "__PAGEZERO"
+/** Traditional UNIX text segment.
+ * Defaults to R-X. */
+#define SEG_TEXT            "__TEXT"
+/** The text part of SEG_TEXT. */
+#define SECT_TEXT               "__text"
+/** The fvmlib initialization. */
+#define SECT_FVMLIB_INIT0       "__fvmlib_init0"
+/** The section following the fvmlib initialization. */
+#define SECT_FVMLIB_INIT1       "__fvmlib_init1"
+/** The traditional UNIX data segment. (DGROUP to DOS and OS/2 people.) */
+#define SEG_DATA            "__DATA"
+/** The initialized data section. */
+#define SECT_DATA               "__data"
+/** The uninitialized data section. */
+#define SECT_BSS                "__bss"
+/** The common symbol section. */
+#define SECT_COMMON             "__common"
+/** Objective-C runtime segment. */
+#define SEG_OBJC            "__OBJC"
+/** Objective-C symbol table section. */
+#define SECT_OBJC_SYMBOLS       "__symbol_table"
+/** Objective-C module information section. */
+#define SECT_OBJC_MODULES       "__module_info"
+/** Objective-C string table section. */
+#define SECT_OBJC_STRINGS       "__selector_strs"
+/** Objective-C string table section. */
+#define SECT_OBJC_REFS          "__selector_refs"
+/** Icon segment. */
+#define SEG_ICON            "__ICON"
+/** The icon headers. */
+#define SECT_ICON_HEADER        "__header"
+/** The icons in the TIFF format. */
+#define SECT_ICON_TIFF          "__tiff"
+/** ld -seglinkedit segment containing all the structs create and maintained
+ * by the linker. MH_EXECUTE and MH_FVMLIB only. */
+#define SEG_LINKEDIT        "__LINKEDIT"
+/** The unix stack segment. */
+#define SEG_UNIXSTACK       "__UNIXSTACK"
+/** The segment for the self modifying code for dynamic linking.
+ * Implies RWX permissions. */
+#define SEG_IMPORT          "__IMPORT"
+/** @} */
+
+
+/** @todo fvmlib */
+/** @todo fvmlib_command (LC_IDFVMLIB or LC_LOADFVMLIB) */
+/** @todo dylib */
+/** @todo dylib_command (LC_ID_DYLIB, LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB) */
+/** @todo sub_framework_command (LC_SUB_FRAMEWORK) */
+/** @todo sub_client_command (LC_SUB_CLIENT) */
+/** @todo sub_umbrella_command (LC_SUB_UMBRELLA) */
+/** @todo sub_library_command (LC_SUB_LIBRARY) */
+/** @todo prebound_dylib_command (LC_PREBOUND_DYLIB) */
+/** @todo dylinker_command (LC_ID_DYLINKER or LC_LOAD_DYLINKER) */
+
+
+/**
+ * Thread command.
+ *
+ * State description of a thread that is to be created. The description
+ * is made up of a number of state structures preceded by a 32-bit flavor
+ * and 32-bit count field stating the kind of stat structure and it's size
+ * in KU32 items respecitvly.
+ *
+ * LC_UNIXTHREAD differs from LC_THREAD in that it implies stack creation
+ * and that it's started with the typical main(int, char **, char **) frame
+ * on the stack.
+ */
+typedef struct thread_command
+{
+    KU32            cmd;        /**< LC_UNIXTHREAD or LC_THREAD. */
+    KU32            cmdsize;    /**< The size of the command (including this header). */
+} thread_command_t;
+
+
+/** @todo routines_command (LC_ROUTINES) */
+/** @todo routines_command_64 (LC_ROUTINES_64) */
+
+
+/**
+ * Symbol table command.
+ * Contains a.out style symbol table with some tricks.
+ */
+typedef struct symtab_command
+{
+    KU32            cmd;        /**< LC_SYMTAB */
+    KU32            cmdsize;    /** sizeof(symtab_command_t) */
+    KU32            symoff;     /** The file offset of the symbol table. */
+    KU32            nsyms;      /** The number of symbols in the symbol table. */
+    KU32            stroff;     /** The file offset of the string table. */
+    KU32            strsize;    /** The size of the string table. */
+} symtab_command_t;
+
+
+/** @todo dysymtab_command (LC_DYSYMTAB)  */
+/** @todo dylib_table_of_contents */
+/** @todo dylib_module_32 */
+/** @todo dylib_module_64 */
+/** @todo dylib_reference */
+/** @todo twolevel_hints_command (LC_TWOLEVEL_HINTS) */
+/** @todo twolevel_hint */
+/** @todo prebind_cksum_command (LC_PREBIND_CKSUM) */
+
+
+/**
+ * UUID generated by ld.
+ */
+typedef struct uuid_command
+{
+    KU32            cmd;        /**< LC_UUID */
+    KU32            cmdsize;    /**< sizeof(uuid_command_t) */
+    KU8             uuid[16];   /** The UUID bytes. */
+} uuid_command_t;
+
+
+/** @todo symseg_command (LC_SYMSEG) */
+/** @todo ident_command (LC_IDENT) */
+/** @todo fvmfile_command (LC_FVMFILE) */
+
+/** @} */
+
+
+
+/** @defgroup grp_macho_o_syms  Symbol Table
+ * @{ */
+
+/**
+ * The 32-bit Mach-O version of the nlist structure.
+ *
+ * This differs from the a.out nlist struct in that the unused n_other field
+ * was renamed to n_sect and used for keeping the relevant section number.
+ * @remark  This structure is not name mach_nlist_32 in the Apple headers, but nlist.
+ */
+typedef struct macho_nlist_32
+{
+    union
+    {
+        KI32    n_strx;         /**< Offset (index) into the string table. 0 means "". */
+    }           n_un;
+    KU8         n_type;         /**< Symbol type. */
+    KU8         n_sect;         /**< Section number of NO_SECT. */
+    KI16        n_desc;         /**< Type specific, debug info details mostly.*/
+    KU32        n_value;        /**< The symbol value or stab offset. */
+} macho_nlist_32_t;
+
+
+/**
+ * The 64-bit Mach-O version of the nlist structure.
+ * @see macho_nlist_32
+ */
+typedef struct macho_nlist_64
+{
+    union
+    {
+        KU32    n_strx;         /**< Offset (index) into the string table. 0 means "". */
+    }           n_un;
+    KU8         n_type;         /**< Symbol type. */
+    KU8         n_sect;         /**< Section number of NO_SECT. */
+    KI16        n_desc;         /**< Type specific, debug info details mostly.*/
+    KU64        n_value;        /**< The symbol value or stab offset. */
+} macho_nlist_64_t;
+
+
+/** @name Symbol Type Constants (macho_nlist_32_t::n_type, macho_nlist_64_t::n_type)
+ *
+ * In the Mach-O world n_type is somewhat similar to a.out, meaning N_EXT, N_UNDF, N_ABS
+ * and the debug symbols are essentially the same, but the remaining stuff is different.
+ * The main reason for this is that the encoding of section has been moved to n_sect
+ * to permit up to 255 sections instead of the fixed 3 a.out sections (not counting
+ * the abs symbols and set vectors).
+ *
+ * To avoid confusion with a.out the Mach-O constants has been fitted with a MACHO_
+ * prefix here.
+ *
+ * Common symbols (aka communal symbols and comdefs) are represented by
+ * n_type = MACHO_N_EXT | MACHO_N_UNDF, n_sect = NO_SECT and n_value giving
+ * the size.
+ *
+ *
+ * Symbol table entries can be inserted directly in the assembly code using
+ * this notation:
+ * @code
+ *      .stabs "n_name", n_type, n_sect, n_desc, n_value
+ * @endcode
+ *
+ * (1) The line number is optional, GCC doesn't set it.
+ * (2) The type is optional, GCC doesn't set it.
+ * (3) The binutil header is "skeptical" about the line. I'm skeptical about the whole thing... :-)
+ * (M) Mach-O specific?
+ * (S) Sun specific?
+ * @{
+ */
+
+/* Base masks. */
+#define MACHO_N_EXT     KU8_C(0x01)   /**< External symbol (when set) (N_EXT). */
+#define MACHO_N_TYPE    KU8_C(0x0e)   /**< Symbol type (N_TYPE without the 8th bit). */
+#define MACHO_N_PEXT    KU8_C(0x10)   /**< Private extern symbol (when set). (M) */
+#define MACHO_N_STAB    KU8_C(0xe0)   /**< Debug symbol mask (N_STAB). */
+
+/* MACHO_N_TYPE values. */
+#define MACHO_N_UNDF    KU8_C(0x00)   /**< MACHO_N_TYPE: Undefined symbol (N_UNDF). n_sect = NO_SECT. */
+#define MACHO_N_ABS     KU8_C(0x02)   /**< MACHO_N_TYPE: Absolute symbol (N_UNDF). n_sect = NO_SECT. */
+#define MACHO_N_INDR    KU8_C(0x0a)   /**< MACHO_N_TYPE: Indirect symbol, n_value is the index of the symbol. (M) */
+#define MACHO_N_PBUD    KU8_C(0x0c)   /**< MACHO_N_TYPE: Prebound undefined symbo (defined in a dylib). (M) */
+#define MACHO_N_SECT    KU8_C(0x0e)   /**< MACHO_N_TYPE: Defined in the section given by n_sects. (M) */
+
+/* Debug symbols. */
+#define MACHO_N_GSYM    KU8_C(0x20)   /**< Global variable.       "name",, NO_SECT, type, 0       (2) */
+#define MACHO_N_FNAME   KU8_C(0x22)   /**< Function name (F77).   "name",, NO_SECT, 0, 0 */
+#define MACHO_N_FUN     KU8_C(0x24)   /**< Function / text var.   "name",, section, line, address (1) */
+#define MACHO_N_STSYM   KU8_C(0x26)   /**< Static data symbol.    "name",, section, type, address (2) */
+#define MACHO_N_LCSYM   KU8_C(0x28)   /**< static bss symbol.     "name",, section, type, address (2) */
+    /* omits N_MAIN and N_ROSYM. */
+#define MACHO_N_BNSYM   KU8_C(0x2e)   /**< Begin nsect symbol.         0,, section, 0, address (M) */
+#define MACHO_N_PC      KU8_C(0x30)   /**< Global pascal symbol.  "name",, NO_SECT, subtype?, line (3) */
+    /* omits N_NSYMS, N_NOMAP and N_OBJ. */
+#define MACHO_N_OPT     KU8_C(0x3c)   /**< Options for the debugger related to the language of the
+                                             source file.           "options?",,,, */
+#define MACHO_N_RSYM    KU8_C(0x40)   /**< Register variable.     "name",, NO_SECT, type, register */
+    /* omits N_M2C */
+#define MACHO_N_SLINE   KU8_C(0x44)   /**< Source line.                0,, section, line, address */
+    /* omits N_DSLINE, N_BSLINE / N_BROWS, N_DEFD and N_FLINE. */
+#define MACHO_N_ENSYM   KU8_C(0x4e)   /**< End nsect symbol.           0,, section, 0, address (M) */
+    /* omits N_EHDECL / N_MOD2 and N_CATCH. */
+#define MACHO_N_SSYM    KU8_C(0x60)   /**< Struct/union element.  "name",, NO_SECT, type, offset */
+    /* omits N_ENDM */
+#define MACHO_N_SO      KU8_C(0x64)   /**< Source file name.      "fname",, section, 0, address */
+#define MACHO_N_OSO     KU8_C(0x66)   /**< Object file name.      "fname",, 0, 0, st_mtime (M?) */
+    /* omits N_ALIAS */
+#define MACHO_N_LSYM    KU8_C(0x80)   /**< Stack variable.        "name",, NO_SECT, type, frame_offset */
+#define MACHO_N_BINCL   KU8_C(0x82)   /**< Begin #include.        "fname",, NO_SECT, 0, sum? */
+#define MACHO_N_SOL     KU8_C(0x84)   /**< #included file.        "fname",, section, 0, start_address (S) */
+#define MACHO_N_PARAMS  KU8_C(0x86)   /**< Compiler params.       "params",, NO_SECT, 0, 0 */
+#define MACHO_N_VERSION KU8_C(0x88)   /**< Compiler version.      "version",, NO_SECT, 0, 0 */
+#define MACHO_N_OLEVEL  KU8_C(0x8A)   /**< Compiler -O level.     "level",, NO_SECT, 0, 0 */
+#define MACHO_N_PSYM    KU8_C(0xa0)   /**< Parameter variable.    "name",, NO_SECT, type, frame_offset */
+#define MACHO_N_EINCL   KU8_C(0xa2)   /**< End #include.          "fname",, NO_SECT, 0, 0 (S) */
+#define MACHO_N_ENTRY   KU8_C(0xa4)   /**< Alternate entry point. "name",, section, line, address */
+#define MACHO_N_LBRAC   KU8_C(0xc0)   /**< Left bracket.               0,, NO_SECT, nesting_level, address */
+#define MACHO_N_EXCL    KU8_C(0xc2)   /**< Deleted include file.  "fname",, NO_SECT, 0, sum?  (S) */
+    /* omits N_SCOPE */
+#define MACHO_N_RBRAC   KU8_C(0xe0)   /**< Right bracket.              0,, NO_SECT, nesting_level, address */
+#define MACHO_N_BCOMM   KU8_C(0xe2)   /**< Begin common.          "name",, NO_SECT?, 0, 0 */
+#define MACHO_N_ECOMM   KU8_C(0xe4)   /**< End common.            "name",, section, 0, 0 */
+#define MACHO_N_ECOML   KU8_C(0xe8)   /**< End local common.           0,, section, 0, address */
+#define MACHO_N_LENG    KU8_C(0xfe)   /**< Length-value of the preceding entry.
+                                                                    "name",, NO_SECT, 0, length */
+
+/** @} */
+
+/** @name Symbol Description Bits (macho_nlist_32_t::n_desc, macho_nlist_64_t::n_desc)
+ *
+ * Mach-O puts the n_desc field to a number of uses, like lazy binding , library
+ * ordinal numbers for -twolevel_namespace, stripping and weak symbol handling.
+ *
+ * @remark The REFERENCE_FLAGS_* are really not flags in the normal sense (bit),
+ *         they are more like enum values.
+ * @{
+ */
+
+#define REFERENCE_TYPE                  KU16_C(0x000f)    /**< The reference type mask. */
+#define REFERENCE_FLAG_UNDEFINED_NON_LAZY             0     /**< Normal undefined symbol. */
+#define REFERENCE_FLAG_UNDEFINED_LAZY                 1     /**< Lazy undefined symbol. */
+#define REFERENCE_FLAG_DEFINED                        2     /**< Defined symbol (dynamic linking). */
+#define REFERENCE_FLAG_PRIVATE_DEFINED                3     /**< Defined private symbol (dynamic linking). */
+#define REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY     4     /**< Normal undefined private symbol. */
+#define REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY         5     /**< Lazy undefined private symbol. */
+
+#define REFERENCED_DYNAMICALLY          KU16_C(0x0010)    /**< Don't strip. */
+
+
+/** Get the dynamic library ordinal. */
+#define GET_LIBRARY_ORDINAL(n_desc)     \
+    (((n_desc) >> 8) & 0xff)
+/** Set the dynamic library ordinal. */
+#define SET_LIBRARY_ORDINAL(n_desc, ordinal) \
+    (n_desc) = (((n_desc) & 0xff) | (((ordinal) & 0xff) << 8))
+#define SELF_LIBRARY_ORDINAL            0x00                /**< Special ordinal for refering to onself. */
+#define MAX_LIBRARY_ORDINAL             0xfd                /**< Maximum ordinal number. */
+#define DYNAMIC_LOOKUP_ORDINAL          0xfe                /**< Special ordinal number for dynamic lookup. (Mac OS X 10.3 and later) */
+#define EXECUTABLE_ORDINAL              0xff                /**< Special ordinal number for the executable.  */
+
+
+/** Only MH_OBJECT: Never dead strip me! */
+#define N_NO_DEAD_STRIP                 KU16_C(0x0020)
+/** Not MH_OBJECT: Discarded symbol. */
+#define N_DESC_DISCARDED                KU16_C(0x0020)
+/** Weak external symbol. Symbol can be missing, in which case it's will have the value 0. */
+#define N_WEAK_REF                      KU16_C(0x0040)
+/** Weak symbol definition. The symbol can be overridden by another weak
+ * symbol already present or by a non-weak (strong) symbol definition.
+ * Currently only supported for coalesed symbols.
+ * @remark This bit means something differently for undefined symbols, see N_REF_TO_WEAK.
+ */
+#define N_WEAK_DEF                      KU16_C(0x0080)
+/** Reference to a weak symbol, resolve using flat namespace searching.
+ * @remark This bit means something differently for defined symbols, see N_WEAK_DEF. */
+#define N_REF_TO_WEAK                   KU16_C(0x0080)
+
+/** @} */
+
+/** @} */
+
+
+/** @defgroup grp_macho_o_relocs    Relocations
+ * @{ */
+
+/**
+ * Relocation entry.
+ *
+ * Differs from a.out in the meaning of r_symbolnum when r_extern=0 and
+ * that r_pad is made into r_type.
+ *
+ * @remark  This structure and type has been prefixed with macho_ to avoid
+ *          confusion with the original a.out type.
+ */
+typedef struct macho_relocation_info
+{
+    KI32        r_address;          /**< Section relative address of the fixup.
+                                         The top bit (signed) indicates that this is a scattered
+                                         relocation if set, see scattered_relocation_info_t. */
+    KU32        r_symbolnum : 24,   /**< r_extern=1: Symbol table index, relocate with the address of this symbol.
+                                         r_extern=0: Section ordinal, relocate with the address of this section. */
+                r_pcrel : 1,        /**< PC (program counter) relative fixup; subtract the fixup address. */
+                r_length : 2,       /**< Fixup length: 0=KU8, 1=KU16, 2=KU32, 3=KU64. */
+                r_extern : 1,       /**< External or internal fixup, decides the r_symbolnum interpretation.. */
+                r_type : 4;         /**< Relocation type; 0 is standard, non-zero are machine specific. */
+} macho_relocation_info_t;
+
+/** Special section ordinal value for absolute relocations. */
+#define R_ABS           0
+
+/** Flag in r_address indicating that the relocation is of the
+ * scattered_relocation_info_t kind and not macho_relocation_info_t. */
+#define R_SCATTERED     KU32_C(0x80000000)
+
+/**
+ * Scattered relocation.
+ *
+ * This is a hack mainly for RISC machines which restricts section size
+ * to 16MB among other things.
+ *
+ * The reason for the big/little endian differences here is of course because
+ * of the R_SCATTERED mask and the way bitfields are implemented by the
+ * C/C++ compilers.
+ */
+typedef struct scattered_relocation_info
+{
+#ifdef KLDR_LITTLE_ENDIAN
+    KU32        r_address : 24,     /**< Section relative address of the fixup. (macho_relocation_info_t::r_address) */
+                r_type : 4,         /**< Relocation type; 0 is standard, non-zero are machine specific. (macho_relocation_info_t::r_type) */
+                r_length : 2,       /**< Fixup length: 0=KU8, 1=KU16, 2=KU32, 3=KU64. (macho_relocation_info_t::r_length) */
+                r_pcrel : 1,        /**< PC (program counter) relative fixup; subtract the fixup address. (macho_relocation_info_t::r_pcrel) */
+                r_scattered : 1;    /**< Set if scattered relocation, clear if normal relocation. */
+#elif defined(KLDR_BIG_ENDIAN)
+    KU32        r_scattered : 1,    /**< Set if scattered relocation, clear if normal relocation. */
+                r_pcrel : 1,        /**< PC (program counter) relative fixup; subtract the fixup address. (macho_relocation_info_t::r_pcrel) */
+                r_length : 2,       /**< Fixup length: 0=KU8, 1=KU16, 2=KU32, 3=KU64. (macho_relocation_info_t::r_length) */
+                r_type : 4,         /**< Relocation type; 0 is standard, non-zero are machine specific. (macho_relocation_info_t::r_type) */
+                r_address : 24;     /**< Section relative address of the fixup. (macho_relocation_info_t::r_address) */
+#else
+# error "Neither KLDR_LITTLE_ENDIAN nor KLDR_BIG_ENDIAN is defined!"
+#endif
+    KI32        r_value;            /**< The value the fixup is refering to (without offset added). */
+} scattered_relocation_info_t;
+
+/**
+ * Relocation type values for a generic implementation (for r_type).
+ */
+typedef enum reloc_type_generic
+{
+    GENERIC_RELOC_VANILLA = 0,      /**< Standard relocation. */
+    GENERIC_RELOC_PAIR,             /**< Follows GENERIC_RELOC_SECTDIFF. */
+    GENERIC_RELOC_SECTDIFF,         /**< ??? */
+    GENERIC_RELOC_PB_LA_PTR,        /**< Prebound lazy pointer whatever that. */
+    GENERIC_RELOC_LOCAL_SECTDIFF    /**< ??? */
+} reloc_type_generic_t;
+
+/** @} */
+
+
+/** @} */
+#endif
+
Index: /trunk/kStuff/include/k/kLdrFmts/mz.h
===================================================================
--- /trunk/kStuff/include/k/kLdrFmts/mz.h	(revision 3568)
+++ /trunk/kStuff/include/k/kLdrFmts/mz.h	(revision 3568)
@@ -0,0 +1,45 @@
+/* $Id$ */
+/** @file
+ * MZ structures, types and defines.
+ */
+
+#ifndef ___k_kLdrFmts_mz_h___
+#define ___k_kLdrFmts_mz_h___
+
+#include <k/kDefs.h>
+#include <k/kTypes.h>
+
+#pragma pack(1) /* not required */
+
+typedef struct _IMAGE_DOS_HEADER
+{
+    KU16       e_magic;
+    KU16       e_cblp;
+    KU16       e_cp;
+    KU16       e_crlc;
+    KU16       e_cparhdr;
+    KU16       e_minalloc;
+    KU16       e_maxalloc;
+    KU16       e_ss;
+    KU16       e_sp;
+    KU16       e_csum;
+    KU16       e_ip;
+    KU16       e_cs;
+    KU16       e_lfarlc;
+    KU16       e_ovno;
+    KU16       e_res[4];
+    KU16       e_oemid;
+    KU16       e_oeminfo;
+    KU16       e_res2[10];
+    KU32       e_lfanew;
+} IMAGE_DOS_HEADER;
+typedef IMAGE_DOS_HEADER *PIMAGE_DOS_HEADER;
+
+#ifndef IMAGE_DOS_SIGNATURE
+# define IMAGE_DOS_SIGNATURE KLDR_LE2H_U16('M' | ('Z' << 8))
+#endif
+
+#pragma pack()
+
+#endif
+
Index: /trunk/kStuff/include/k/kLdrFmts/pe.h
===================================================================
--- /trunk/kStuff/include/k/kLdrFmts/pe.h	(revision 3568)
+++ /trunk/kStuff/include/k/kLdrFmts/pe.h	(revision 3568)
@@ -0,0 +1,481 @@
+/* $Id$ */
+/** @file
+ * PE structures, types and defines.
+ */
+
+#ifndef ___k_kLdrFmts_pe_h___
+#define ___k_kLdrFmts_pe_h___
+
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <k/kTypes.h>
+#include <k/kDefs.h>
+
+
+/*******************************************************************************
+*   Defined Constants And Macros                                               *
+*******************************************************************************/
+#ifndef IMAGE_NT_SIGNATURE
+# define  IMAGE_NT_SIGNATURE KLDR_LE2H_U32('P' | ('E' << 8))
+#endif
+
+/* file header */
+#define  IMAGE_FILE_MACHINE_I386  0x014c
+#define  IMAGE_FILE_MACHINE_AMD64  0x8664
+
+#define  IMAGE_FILE_RELOCS_STRIPPED  0x0001
+#define  IMAGE_FILE_EXECUTABLE_IMAGE  0x0002
+#define  IMAGE_FILE_LINE_NUMS_STRIPPED  0x0004
+#define  IMAGE_FILE_LOCAL_SYMS_STRIPPED  0x0008
+#define  IMAGE_FILE_AGGRESIVE_WS_TRIM  0x0010
+#define  IMAGE_FILE_LARGE_ADDRESS_AWARE  0x0020
+#define  IMAGE_FILE_16BIT_MACHINE  0x0040
+#define  IMAGE_FILE_BYTES_REVERSED_LO  0x0080
+#define  IMAGE_FILE_32BIT_MACHINE  0x0100
+#define  IMAGE_FILE_DEBUG_STRIPPED  0x0200
+#define  IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP  0x0400
+#define  IMAGE_FILE_NET_RUN_FROM_SWAP  0x0800
+#define  IMAGE_FILE_SYSTEM  0x1000
+#define  IMAGE_FILE_DLL  0x2000
+#define  IMAGE_FILE_UP_SYSTEM_ONLY  0x4000
+#define  IMAGE_FILE_BYTES_REVERSED_HI  0x8000
+
+
+/* optional header */
+#define  IMAGE_NT_OPTIONAL_HDR32_MAGIC  0x10B
+#define  IMAGE_NT_OPTIONAL_HDR64_MAGIC  0x20B
+
+#define  IMAGE_SUBSYSTEM_UNKNOWN  0x0
+#define  IMAGE_SUBSYSTEM_NATIVE  0x1
+#define  IMAGE_SUBSYSTEM_WINDOWS_GUI  0x2
+#define  IMAGE_SUBSYSTEM_WINDOWS_CUI  0x3
+#define  IMAGE_SUBSYSTEM_OS2_GUI  0x4
+#define  IMAGE_SUBSYSTEM_OS2_CUI  0x5
+#define  IMAGE_SUBSYSTEM_POSIX_CUI  0x7
+
+#define  IMAGE_LIBRARY_PROCESS_INIT  0x0001
+#define  IMAGE_LIBRARY_PROCESS_TERM  0x0002
+#define  IMAGE_LIBRARY_THREAD_INIT  0x0004
+#define  IMAGE_LIBRARY_THREAD_TERM  0x0008
+#define  IMAGE_DLLCHARACTERISTICS_NO_ISOLATION  0x0200
+#define  IMAGE_DLLCHARACTERISTICS_NO_SEH  0x0400
+#define  IMAGE_DLLCHARACTERISTICS_NO_BIND  0x0800
+#define  IMAGE_DLLCHARACTERISTICS_WDM_DRIVER  0x2000
+#define  IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE  0x8000
+
+#define  IMAGE_NUMBEROF_DIRECTORY_ENTRIES  0x10
+
+#define  IMAGE_DIRECTORY_ENTRY_EXPORT  0x0
+#define  IMAGE_DIRECTORY_ENTRY_IMPORT  0x1
+#define  IMAGE_DIRECTORY_ENTRY_RESOURCE  0x2
+#define  IMAGE_DIRECTORY_ENTRY_EXCEPTION  0x3
+#define  IMAGE_DIRECTORY_ENTRY_SECURITY  0x4
+#define  IMAGE_DIRECTORY_ENTRY_BASERELOC  0x5
+#define  IMAGE_DIRECTORY_ENTRY_DEBUG  0x6
+#define  IMAGE_DIRECTORY_ENTRY_ARCHITECTURE  0x7
+#define  IMAGE_DIRECTORY_ENTRY_COPYRIGHT IMAGE_DIRECTORY_ENTRY_ARCHITECTURE
+#define  IMAGE_DIRECTORY_ENTRY_GLOBALPTR  0x8
+#define  IMAGE_DIRECTORY_ENTRY_TLS  0x9
+#define  IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG  0xa
+#define  IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT  0xb
+#define  IMAGE_DIRECTORY_ENTRY_IAT  0xc
+#define  IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT  0xd
+#define  IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR  0xe
+
+
+/* section header */
+#define  IMAGE_SIZEOF_SHORT_NAME  0x8
+
+#define  IMAGE_SCN_TYPE_REG  0x00000000
+#define  IMAGE_SCN_TYPE_DSECT  0x00000001
+#define  IMAGE_SCN_TYPE_NOLOAD  0x00000002
+#define  IMAGE_SCN_TYPE_GROUP  0x00000004
+#define  IMAGE_SCN_TYPE_NO_PAD  0x00000008
+#define  IMAGE_SCN_TYPE_COPY  0x00000010
+
+#define  IMAGE_SCN_CNT_CODE  0x00000020
+#define  IMAGE_SCN_CNT_INITIALIZED_DATA  0x00000040
+#define  IMAGE_SCN_CNT_UNINITIALIZED_DATA  0x00000080
+
+#define  IMAGE_SCN_LNK_OTHER  0x00000100
+#define  IMAGE_SCN_LNK_INFO  0x00000200
+#define  IMAGE_SCN_TYPE_OVER  0x00000400
+#define  IMAGE_SCN_LNK_REMOVE  0x00000800
+#define  IMAGE_SCN_LNK_COMDAT  0x00001000
+#define  IMAGE_SCN_MEM_PROTECTED  0x00004000
+#define  IMAGE_SCN_NO_DEFER_SPEC_EXC  0x00004000
+#define  IMAGE_SCN_GPREL  0x00008000
+#define  IMAGE_SCN_MEM_FARDATA  0x00008000
+#define  IMAGE_SCN_MEM_SYSHEAP  0x00010000
+#define  IMAGE_SCN_MEM_PURGEABLE  0x00020000
+#define  IMAGE_SCN_MEM_16BIT  0x00020000
+#define  IMAGE_SCN_MEM_LOCKED  0x00040000
+#define  IMAGE_SCN_MEM_PRELOAD  0x00080000
+
+#define  IMAGE_SCN_ALIGN_1BYTES  0x00100000
+#define  IMAGE_SCN_ALIGN_2BYTES  0x00200000
+#define  IMAGE_SCN_ALIGN_4BYTES  0x00300000
+#define  IMAGE_SCN_ALIGN_8BYTES  0x00400000
+#define  IMAGE_SCN_ALIGN_16BYTES  0x00500000
+#define  IMAGE_SCN_ALIGN_32BYTES  0x00600000
+#define  IMAGE_SCN_ALIGN_64BYTES  0x00700000
+#define  IMAGE_SCN_ALIGN_128BYTES  0x00800000
+#define  IMAGE_SCN_ALIGN_256BYTES  0x00900000
+#define  IMAGE_SCN_ALIGN_512BYTES  0x00A00000
+#define  IMAGE_SCN_ALIGN_1024BYTES  0x00B00000
+#define  IMAGE_SCN_ALIGN_2048BYTES  0x00C00000
+#define  IMAGE_SCN_ALIGN_4096BYTES  0x00D00000
+#define  IMAGE_SCN_ALIGN_8192BYTES  0x00E00000
+#define  IMAGE_SCN_ALIGN_MASK  0x00F00000
+
+#define  IMAGE_SCN_LNK_NRELOC_OVFL  0x01000000
+#define  IMAGE_SCN_MEM_DISCARDABLE  0x02000000
+#define  IMAGE_SCN_MEM_NOT_CACHED  0x04000000
+#define  IMAGE_SCN_MEM_NOT_PAGED  0x08000000
+#define  IMAGE_SCN_MEM_SHARED  0x10000000
+#define  IMAGE_SCN_MEM_EXECUTE  0x20000000
+#define  IMAGE_SCN_MEM_READ  0x40000000
+#define  IMAGE_SCN_MEM_WRITE  0x80000000
+
+
+/* relocations */
+#define  IMAGE_REL_BASED_ABSOLUTE  0x0
+#define  IMAGE_REL_BASED_HIGH  0x1
+#define  IMAGE_REL_BASED_LOW  0x2
+#define  IMAGE_REL_BASED_HIGHLOW  0x3
+#define  IMAGE_REL_BASED_HIGHADJ  0x4
+#define  IMAGE_REL_BASED_MIPS_JMPADDR  0x5
+#define  IMAGE_REL_BASED_SECTION  0x6
+#define  IMAGE_REL_BASED_REL32  0x7
+/*#define  IMAGE_REL_BASED_RESERVED1 0x8 */
+#define  IMAGE_REL_BASED_MIPS_JMPADDR16 0x9
+#define  IMAGE_REL_BASED_IA64_IMM64  0x9
+#define  IMAGE_REL_BASED_DIR64  0xa
+#define  IMAGE_REL_BASED_HIGH3ADJ 0xb
+
+/* imports */
+#define  IMAGE_ORDINAL_FLAG32  0x80000000
+#define  IMAGE_ORDINAL32(ord)  ((ord) &  0xffff)
+#define  IMAGE_SNAP_BY_ORDINAL32(ord)  (!!((ord) & IMAGE_ORDINAL_FLAG32))
+
+#define  IMAGE_ORDINAL_FLAG64  0x8000000000000000ULL
+#define  IMAGE_ORDINAL64(ord)  ((ord) &  0xffff)
+#define  IMAGE_SNAP_BY_ORDINAL64(ord)  (!!((ord) & IMAGE_ORDINAL_FLAG64))
+
+
+/* dll/tls entry points argument */
+#define DLL_PROCESS_DETACH      0
+#define DLL_PROCESS_ATTACH      1
+#define DLL_THREAD_ATTACH       2
+#define DLL_THREAD_DETACH       3
+
+
+/*******************************************************************************
+*   Structures and Typedefs                                                    *
+*******************************************************************************/
+#pragma pack(4)
+
+typedef struct _IMAGE_FILE_HEADER
+{
+    KU16      Machine;
+    KU16      NumberOfSections;
+    KU32      TimeDateStamp;
+    KU32      PointerToSymbolTable;
+    KU32      NumberOfSymbols;
+    KU16      SizeOfOptionalHeader;
+    KU16      Characteristics;
+} IMAGE_FILE_HEADER;
+typedef IMAGE_FILE_HEADER *PIMAGE_FILE_HEADER;
+
+
+typedef struct _IMAGE_DATA_DIRECTORY
+{
+    KU32      VirtualAddress;
+    KU32      Size;
+} IMAGE_DATA_DIRECTORY;
+typedef IMAGE_DATA_DIRECTORY *PIMAGE_DATA_DIRECTORY;
+
+
+typedef struct _IMAGE_OPTIONAL_HEADER32
+{
+    KU16    Magic;
+    KU8     MajorLinkerVersion;
+    KU8     MinorLinkerVersion;
+    KU32    SizeOfCode;
+    KU32    SizeOfInitializedData;
+    KU32    SizeOfUninitializedData;
+    KU32    AddressOfEntryPoint;
+    KU32    BaseOfCode;
+    KU32    BaseOfData;
+    KU32    ImageBase;
+    KU32    SectionAlignment;
+    KU32    FileAlignment;
+    KU16    MajorOperatingSystemVersion;
+    KU16    MinorOperatingSystemVersion;
+    KU16    MajorImageVersion;
+    KU16    MinorImageVersion;
+    KU16    MajorSubsystemVersion;
+    KU16    MinorSubsystemVersion;
+    KU32    Win32VersionValue;
+    KU32    SizeOfImage;
+    KU32    SizeOfHeaders;
+    KU32    CheckSum;
+    KU16    Subsystem;
+    KU16    DllCharacteristics;
+    KU32    SizeOfStackReserve;
+    KU32    SizeOfStackCommit;
+    KU32    SizeOfHeapReserve;
+    KU32    SizeOfHeapCommit;
+    KU32    LoaderFlags;
+    KU32    NumberOfRvaAndSizes;
+    IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
+} IMAGE_OPTIONAL_HEADER32;
+typedef IMAGE_OPTIONAL_HEADER32 *PIMAGE_OPTIONAL_HEADER32;
+
+typedef struct _IMAGE_OPTIONAL_HEADER64
+{
+    KU16    Magic;
+    KU8     MajorLinkerVersion;
+    KU8     MinorLinkerVersion;
+    KU32    SizeOfCode;
+    KU32    SizeOfInitializedData;
+    KU32    SizeOfUninitializedData;
+    KU32    AddressOfEntryPoint;
+    KU32    BaseOfCode;
+    KU64    ImageBase;
+    KU32    SectionAlignment;
+    KU32    FileAlignment;
+    KU16    MajorOperatingSystemVersion;
+    KU16    MinorOperatingSystemVersion;
+    KU16    MajorImageVersion;
+    KU16    MinorImageVersion;
+    KU16    MajorSubsystemVersion;
+    KU16    MinorSubsystemVersion;
+    KU32    Win32VersionValue;
+    KU32    SizeOfImage;
+    KU32    SizeOfHeaders;
+    KU32    CheckSum;
+    KU16    Subsystem;
+    KU16    DllCharacteristics;
+    KU64    SizeOfStackReserve;
+    KU64    SizeOfStackCommit;
+    KU64    SizeOfHeapReserve;
+    KU64    SizeOfHeapCommit;
+    KU32    LoaderFlags;
+    KU32    NumberOfRvaAndSizes;
+    IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
+} IMAGE_OPTIONAL_HEADER64;
+typedef IMAGE_OPTIONAL_HEADER64 *PIMAGE_OPTIONAL_HEADER64;
+
+
+typedef struct _IMAGE_NT_HEADERS
+{
+    KU32 Signature;
+    IMAGE_FILE_HEADER FileHeader;
+    IMAGE_OPTIONAL_HEADER32 OptionalHeader;
+} IMAGE_NT_HEADERS32;
+typedef IMAGE_NT_HEADERS32 *PIMAGE_NT_HEADERS32;
+
+typedef struct _IMAGE_NT_HEADERS64
+{
+    KU32 Signature;
+    IMAGE_FILE_HEADER FileHeader;
+    IMAGE_OPTIONAL_HEADER64 OptionalHeader;
+} IMAGE_NT_HEADERS64;
+typedef IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64;
+
+
+typedef struct _IMAGE_SECTION_HEADER
+{
+    KU8      Name[IMAGE_SIZEOF_SHORT_NAME];
+    union
+    {
+        KU32      PhysicalAddress;
+        KU32      VirtualSize;
+    } Misc;
+    KU32      VirtualAddress;
+    KU32      SizeOfRawData;
+    KU32      PointerToRawData;
+    KU32      PointerToRelocations;
+    KU32      PointerToLinenumbers;
+    KU16      NumberOfRelocations;
+    KU16      NumberOfLinenumbers;
+    KU32      Characteristics;
+} IMAGE_SECTION_HEADER;
+typedef IMAGE_SECTION_HEADER *PIMAGE_SECTION_HEADER;
+
+
+typedef struct _IMAGE_BASE_RELOCATION
+{
+    KU32      VirtualAddress;
+    KU32      SizeOfBlock;
+} IMAGE_BASE_RELOCATION;
+typedef IMAGE_BASE_RELOCATION *PIMAGE_BASE_RELOCATION;
+
+
+typedef struct _IMAGE_EXPORT_DIRECTORY
+{
+    KU32      Characteristics;
+    KU32      TimeDateStamp;
+    KU16      MajorVersion;
+    KU16      MinorVersion;
+    KU32      Name;
+    KU32      Base;
+    KU32      NumberOfFunctions;
+    KU32      NumberOfNames;
+    KU32      AddressOfFunctions;
+    KU32      AddressOfNames;
+    KU32      AddressOfNameOrdinals;
+} IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY;
+
+
+typedef struct _IMAGE_IMPORT_DESCRIPTOR
+{
+    union
+    {
+        KU32      Characteristics;
+        KU32      OriginalFirstThunk;
+    } u;
+    KU32      TimeDateStamp;
+    KU32      ForwarderChain;
+    KU32      Name;
+    KU32      FirstThunk;
+} IMAGE_IMPORT_DESCRIPTOR;
+typedef IMAGE_IMPORT_DESCRIPTOR *PIMAGE_IMPORT_DESCRIPTOR;
+
+
+typedef struct _IMAGE_IMPORT_BY_NAME
+{
+    KU16      Hint;
+    KU8      Name[1];
+} IMAGE_IMPORT_BY_NAME;
+typedef IMAGE_IMPORT_BY_NAME *PIMAGE_IMPORT_BY_NAME;
+
+
+/* The image_thunk_data32/64 structures are not very helpful except for getting RSI. keep them around till all the code has been converted. */
+typedef struct _IMAGE_THUNK_DATA64
+{
+    union
+    {
+        KU64      ForwarderString;
+        KU64      Function;
+        KU64      Ordinal;
+        KU64      AddressOfData;
+    } u1;
+} IMAGE_THUNK_DATA64;
+typedef IMAGE_THUNK_DATA64 *PIMAGE_THUNK_DATA64;
+
+typedef struct _IMAGE_THUNK_DATA32
+{
+    union
+    {
+        KU32      ForwarderString;
+        KU32      Function;
+        KU32      Ordinal;
+        KU32      AddressOfData;
+    } u1;
+} IMAGE_THUNK_DATA32;
+typedef IMAGE_THUNK_DATA32 *PIMAGE_THUNK_DATA32;
+
+
+typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32
+{
+    KU32      Size;
+    KU32      TimeDateStamp;
+    KU16      MajorVersion;
+    KU16      MinorVersion;
+    KU32      GlobalFlagsClear;
+    KU32      GlobalFlagsSet;
+    KU32      CriticalSectionDefaultTimeout;
+    KU32      DeCommitFreeBlockThreshold;
+    KU32      DeCommitTotalFreeThreshold;
+    KU32      LockPrefixTable;
+    KU32      MaximumAllocationSize;
+    KU32      VirtualMemoryThreshold;
+    KU32      ProcessHeapFlags;
+    KU32      ProcessAffinityMask;
+    KU16      CSDVersion;
+    KU16      Reserved1;
+    KU32      EditList;
+    KU32      SecurityCookie;
+    KU32      SEHandlerTable;
+    KU32      SEHandlerCount;
+} IMAGE_LOAD_CONFIG_DIRECTORY32;
+typedef IMAGE_LOAD_CONFIG_DIRECTORY32 PIMAGE_LOAD_CONFIG_DIRECTORY32;
+
+typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64
+{
+    KU32      Size;
+    KU32      TimeDateStamp;
+    KU16      MajorVersion;
+    KU16      MinorVersion;
+    KU32      GlobalFlagsClear;
+    KU32      GlobalFlagsSet;
+    KU32      CriticalSectionDefaultTimeout;
+    KU64      DeCommitFreeBlockThreshold;
+    KU64      DeCommitTotalFreeThreshold;
+    KU64      LockPrefixTable;
+    KU64      MaximumAllocationSize;
+    KU64      VirtualMemoryThreshold;
+    KU64      ProcessAffinityMask;
+    KU32      ProcessHeapFlags;
+    KU16      CSDVersion;
+    KU16      Reserved1;
+    KU64      EditList;
+    KU64      SecurityCookie;
+    KU64      SEHandlerTable;
+    KU64      SEHandlerCount;
+} IMAGE_LOAD_CONFIG_DIRECTORY64;
+typedef IMAGE_LOAD_CONFIG_DIRECTORY64 *PIMAGE_LOAD_CONFIG_DIRECTORY64;
+
+typedef struct _IMAGE_DEBUG_DIRECTORY
+{
+    KU32      Characteristics;
+	KU32  TimeDateStamp;
+    KU16      MajorVersion;
+    KU16      MinorVersion;
+    KU32      Type;
+    KU32      SizeOfData;
+    KU32      AddressOfRawData;
+    KU32      PointerToRawData;
+} IMAGE_DEBUG_DIRECTORY;
+typedef IMAGE_DEBUG_DIRECTORY *PIMAGE_DEBUG_DIRECTORY;
+
+#define IMAGE_DEBUG_TYPE_UNKNOWN  0
+#define IMAGE_DEBUG_TYPE_COFF 1
+#define IMAGE_DEBUG_TYPE_CODEVIEW 2 /* 4.0 */
+#define IMAGE_DEBUG_TYPE_FPO 3 /* FPO = frame pointer omission */
+#define IMAGE_DEBUG_TYPE_MISC 4
+#define IMAGE_DEBUG_TYPE_EXCEPTION 5
+#define IMAGE_DEBUG_TYPE_FIXUP 6
+#define IMAGE_DEBUG_TYPE_BORLAND 9
+
+typedef struct _IMAGE_TLS_DIRECTORY32
+{
+    KU32      StartAddressOfRawData;
+    KU32      EndAddressOfRawData;
+    KU32      AddressOfIndex;
+    KU32      AddressOfCallBacks;
+    KU32      SizeOfZeroFill;
+    KU32      Characteristics;
+} IMAGE_TLS_DIRECTORY32;
+typedef IMAGE_TLS_DIRECTORY32 *PIMAGE_TLS_DIRECTORY32;
+
+typedef struct _IMAGE_TLS_DIRECTORY64
+{
+    KU64      StartAddressOfRawData;
+    KU64      EndAddressOfRawData;
+    KU64      AddressOfIndex;
+    KU64      AddressOfCallBacks;
+    KU32      SizeOfZeroFill;
+    KU32      Characteristics;
+} IMAGE_TLS_DIRECTORY64;
+typedef IMAGE_TLS_DIRECTORY64 *PIMAGE_TLS_DIRECTORY64;
+
+
+#pragma pack()
+
+#endif
+
Index: /trunk/kStuff/kLdr/kLdrMod.c
===================================================================
--- /trunk/kStuff/kLdr/kLdrMod.c	(revision 3567)
+++ /trunk/kStuff/kLdr/kLdrMod.c	(revision 3568)
@@ -32,11 +32,11 @@
 #include "kLdrHlp.h"
 #include "kLdrInternal.h"
-#include "kLdrModMZ.h"
+#include <k/kLdrFmts/mz.h>
 #if 1 /* testing headers */
-# include "kLdrModPE.h"
-# include "kLdrModLX.h"
-# include "kLdrModELF32.h"
-# include "kLdrModELF64.h"
-# include "kLdrModMachO.h"
+# include <k/kLdrFmts/pe.h>
+# include <k/kLdrFmts/lx.h>
+# include <k/kLdrFmts/elf32.h>
+# include <k/kLdrFmts/elf64.h>
+# include <k/kLdrFmts/mach-o.h>
 #endif
 
Index: unk/kStuff/kLdr/kLdrModELF32.h
===================================================================
--- /trunk/kStuff/kLdr/kLdrModELF32.h	(revision 3567)
+++ 	(revision )
@@ -1,158 +1,0 @@
-/*-
- * Copyright (c) 1996-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.
- *
- * $FreeBSD: src/sys/sys/elf32.h,v 1.8 2002/05/30 08:32:18 dfr Exp $
- */
-
-#ifndef __kLdrModELF32_h__
-#define __kLdrModELF32_h__
-
-#include "kLdrBase.h"
-#include "kLdrModELFCommon.h"
-
-/*
- * ELF definitions common to all 32-bit architectures.
- */
-
-typedef KU32	Elf32_Addr;
-typedef KU16	Elf32_Half;
-typedef KU32	Elf32_Off;
-typedef KI32		Elf32_Sword;
-typedef KU32	Elf32_Word;
-typedef KU32	Elf32_Size;
-typedef Elf32_Off	Elf32_Hashelt;
-
-/*
- * ELF header.
- */
-
-typedef struct Elf32_Ehdr {
-	unsigned char	e_ident[EI_NIDENT];	/* File identification. */
-	Elf32_Half	e_type;		/* File type. */
-	Elf32_Half	e_machine;	/* Machine architecture. */
-	Elf32_Word	e_version;	/* ELF format version. */
-	Elf32_Addr	e_entry;	/* Entry point. */
-	Elf32_Off	e_phoff;	/* Program header file offset. */
-	Elf32_Off	e_shoff;	/* Section header file offset. */
-	Elf32_Word	e_flags;	/* Architecture-specific flags. */
-	Elf32_Half	e_ehsize;	/* Size of ELF header in bytes. */
-	Elf32_Half	e_phentsize;	/* Size of program header entry. */
-	Elf32_Half	e_phnum;	/* Number of program header entries. */
-	Elf32_Half	e_shentsize;	/* Size of section header entry. */
-	Elf32_Half	e_shnum;	/* Number of section header entries. */
-	Elf32_Half	e_shstrndx;	/* Section name strings section. */
-} Elf32_Ehdr;
-
-/*
- * Section header.
- */
-
-typedef struct {
-	Elf32_Word	sh_name;	/* Section name (index into the
-					   section header string table). */
-	Elf32_Word	sh_type;	/* Section type. */
-	Elf32_Word	sh_flags;	/* Section flags. */
-	Elf32_Addr	sh_addr;	/* Address in memory image. */
-	Elf32_Off	sh_offset;	/* Offset in file. */
-	Elf32_Size	sh_size;	/* Size in bytes. */
-	Elf32_Word	sh_link;	/* Index of a related section. */
-	Elf32_Word	sh_info;	/* Depends on section type. */
-	Elf32_Size	sh_addralign;	/* Alignment in bytes. */
-	Elf32_Size	sh_entsize;	/* Size of each entry in section. */
-} Elf32_Shdr;
-
-/*
- * Program header.
- */
-
-typedef struct {
-	Elf32_Word	p_type;		/* Entry type. */
-	Elf32_Off	p_offset;	/* File offset of contents. */
-	Elf32_Addr	p_vaddr;	/* Virtual address in memory image. */
-	Elf32_Addr	p_paddr;	/* Physical address (not used). */
-	Elf32_Size	p_filesz;	/* Size of contents in file. */
-	Elf32_Size	p_memsz;	/* Size of contents in memory. */
-	Elf32_Word	p_flags;	/* Access permission flags. */
-	Elf32_Size	p_align;	/* Alignment in memory and file. */
-} Elf32_Phdr;
-
-/*
- * Dynamic structure.  The ".dynamic" section contains an array of them.
- */
-
-typedef struct {
-	Elf32_Sword	d_tag;		/* Entry type. */
-	union {
-		Elf32_Size	d_val;	/* Integer value. */
-		Elf32_Addr	d_ptr;	/* Address value. */
-	} d_un;
-} Elf32_Dyn;
-
-/*
- * Relocation entries.
- */
-
-/* Relocations that don't need an addend field. */
-typedef struct {
-	Elf32_Addr	r_offset;	/* Location to be relocated. */
-	Elf32_Word	r_info;		/* Relocation type and symbol index. */
-} Elf32_Rel;
-
-/* Relocations that need an addend field. */
-typedef struct {
-	Elf32_Addr	r_offset;	/* Location to be relocated. */
-	Elf32_Word	r_info;		/* Relocation type and symbol index. */
-	Elf32_Sword	r_addend;	/* Addend. */
-} Elf32_Rela;
-
-/* Macros for accessing the fields of r_info. */
-#define ELF32_R_SYM(info)	((info) >> 8)
-#define ELF32_R_TYPE(info)	((unsigned char)(info))
-
-/* Macro for constructing r_info from field values. */
-#define ELF32_R_INFO(sym, type)	(((sym) << 8) + (unsigned char)(type))
-
-/*
- * Symbol table entries.
- */
-
-typedef struct {
-	Elf32_Word	st_name;	/* String table index of name. */
-	Elf32_Addr	st_value;	/* Symbol value. */
-	Elf32_Size	st_size;	/* Size of associated object. */
-	unsigned char	st_info;	/* Type and binding information. */
-	unsigned char	st_other;	/* Reserved (not used). */
-	Elf32_Half	st_shndx;	/* Section index of symbol. */
-} Elf32_Sym;
-
-/* Macros for accessing the fields of st_info. */
-#define ELF32_ST_BIND(info)		((info) >> 4)
-#define ELF32_ST_TYPE(info)		((info) & 0xf)
-
-/* Macro for constructing st_info from field values. */
-#define ELF32_ST_INFO(bind, type)	(((bind) << 4) + ((type) & 0xf))
-
-#endif
-
Index: unk/kStuff/kLdr/kLdrModELF64.h
===================================================================
--- /trunk/kStuff/kLdr/kLdrModELF64.h	(revision 3567)
+++ 	(revision )
@@ -1,171 +1,0 @@
-/*-
- * Copyright (c) 1996-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.
- *
- * $FreeBSD: src/sys/sys/elf64.h,v 1.10 2002/05/30 08:32:18 dfr Exp $
- */
-
-#ifndef __kLdrModELF64_h__
-#define __kLdrModELF64_h__
-
-#include "kLdrBase.h"
-#include "kLdrModELFCommon.h"
-
-/*
- * ELF definitions common to all 64-bit architectures.
- */
-
-typedef KU64    Elf64_Addr;
-typedef KU32    Elf64_Half;
-typedef KU64    Elf64_Off;
-typedef KI64    Elf64_Sword;
-typedef KU64    Elf64_Word;
-typedef KU64    Elf64_Size;
-typedef KU16    Elf64_Quarter;
-
-/*
- * Types of dynamic symbol hash table bucket and chain elements.
- *
- * This is inconsistent among 64 bit architectures, so a machine dependent
- * typedef is required.
- */
-
-#ifdef __alpha__
-typedef Elf64_Off	Elf64_Hashelt;
-#else
-typedef Elf64_Half	Elf64_Hashelt;
-#endif
-
-/*
- * ELF header.
- */
-
-typedef struct {
-	unsigned char	e_ident[EI_NIDENT];	/* File identification. */
-	Elf64_Quarter	e_type;		/* File type. */
-	Elf64_Quarter	e_machine;	/* Machine architecture. */
-	Elf64_Half	e_version;	/* ELF format version. */
-	Elf64_Addr	e_entry;	/* Entry point. */
-	Elf64_Off	e_phoff;	/* Program header file offset. */
-	Elf64_Off	e_shoff;	/* Section header file offset. */
-	Elf64_Half	e_flags;	/* Architecture-specific flags. */
-	Elf64_Quarter	e_ehsize;	/* Size of ELF header in bytes. */
-	Elf64_Quarter	e_phentsize;	/* Size of program header entry. */
-	Elf64_Quarter	e_phnum;	/* Number of program header entries. */
-	Elf64_Quarter	e_shentsize;	/* Size of section header entry. */
-	Elf64_Quarter	e_shnum;	/* Number of section header entries. */
-	Elf64_Quarter	e_shstrndx;	/* Section name strings section. */
-} Elf64_Ehdr;
-
-/*
- * Section header.
- */
-
-typedef struct {
-	Elf64_Half	sh_name;	/* Section name (index into the
-					   section header string table). */
-	Elf64_Half	sh_type;	/* Section type. */
-	Elf64_Size	sh_flags;	/* Section flags. */
-	Elf64_Addr	sh_addr;	/* Address in memory image. */
-	Elf64_Off	sh_offset;	/* Offset in file. */
-	Elf64_Size	sh_size;	/* Size in bytes. */
-	Elf64_Half	sh_link;	/* Index of a related section. */
-	Elf64_Half	sh_info;	/* Depends on section type. */
-	Elf64_Size	sh_addralign;	/* Alignment in bytes. */
-	Elf64_Size	sh_entsize;	/* Size of each entry in section. */
-} Elf64_Shdr;
-
-/*
- * Program header.
- */
-
-typedef struct {
-	Elf64_Half	p_type;		/* Entry type. */
-	Elf64_Half	p_flags;	/* Access permission flags. */
-	Elf64_Off	p_offset;	/* File offset of contents. */
-	Elf64_Addr	p_vaddr;	/* Virtual address in memory image. */
-	Elf64_Addr	p_paddr;	/* Physical address (not used). */
-	Elf64_Size	p_filesz;	/* Size of contents in file. */
-	Elf64_Size	p_memsz;	/* Size of contents in memory. */
-	Elf64_Size	p_align;	/* Alignment in memory and file. */
-} Elf64_Phdr;
-
-/*
- * Dynamic structure.  The ".dynamic" section contains an array of them.
- */
-
-typedef struct {
-	Elf64_Size	d_tag;		/* Entry type. */
-	union {
-		Elf64_Size	d_val;	/* Integer value. */
-		Elf64_Addr	d_ptr;	/* Address value. */
-	} d_un;
-} Elf64_Dyn;
-
-/*
- * Relocation entries.
- */
-
-/* Relocations that don't need an addend field. */
-typedef struct {
-	Elf64_Addr	r_offset;	/* Location to be relocated. */
-	Elf64_Size	r_info;		/* Relocation type and symbol index. */
-} Elf64_Rel;
-
-/* Relocations that need an addend field. */
-typedef struct {
-	Elf64_Addr	r_offset;	/* Location to be relocated. */
-	Elf64_Size	r_info;		/* Relocation type and symbol index. */
-	Elf64_Off	r_addend;	/* Addend. */
-} Elf64_Rela;
-
-/* Macros for accessing the fields of r_info. */
-#define ELF64_R_SYM(info)	((info) >> 32)
-#define ELF64_R_TYPE(info)	((unsigned char)(info))
-
-/* Macro for constructing r_info from field values. */
-#define ELF64_R_INFO(sym, type)	(((sym) << 32) + (unsigned char)(type))
-
-/*
- * Symbol table entries.
- */
-
-typedef struct {
-	Elf64_Half	st_name;	/* String table index of name. */
-	unsigned char	st_info;	/* Type and binding information. */
-	unsigned char	st_other;	/* Reserved (not used). */
-	Elf64_Quarter	st_shndx;	/* Section index of symbol. */
-	Elf64_Addr	st_value;	/* Symbol value. */
-	Elf64_Size	st_size;	/* Size of associated object. */
-} Elf64_Sym;
-
-/* Macros for accessing the fields of st_info. */
-#define ELF64_ST_BIND(info)		((info) >> 4)
-#define ELF64_ST_TYPE(info)		((info) & 0xf)
-
-/* Macro for constructing st_info from field values. */
-#define ELF64_ST_INFO(bind, type)	(((bind) << 4) + ((type) & 0xf))
-
-#endif
-
Index: unk/kStuff/kLdr/kLdrModELFAmd64.h
===================================================================
--- /trunk/kStuff/kLdr/kLdrModELFAmd64.h	(revision 3567)
+++ 	(revision )
@@ -1,130 +1,0 @@
-/*-
- * 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.
- *
- * $FreeBSD: src/sys/amd64/include/elf.h,v 1.18 2004/08/03 08:21:48 dfr Exp $
- */
-
-#ifndef __kLdrModELFAmd64_h__
-#define	__kLdrModELFAmd64_h__
-
-/*
- * ELF definitions for the AMD64 architecture.
- */
-
-#if 0 /** @todo Auxiliary vector entries. */
-/*
- * 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 /* [todo] */
-
-/*
- * 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: unk/kStuff/kLdr/kLdrModELFCommon.h
===================================================================
--- /trunk/kStuff/kLdr/kLdrModELFCommon.h	(revision 3567)
+++ 	(revision )
@@ -1,300 +1,0 @@
-/*-
- * 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.
- *
- * $FreeBSD: src/sys/sys/elf_common.h,v 1.15 2004/05/05 02:38:54 marcel Exp $
- */
-
-#ifndef __kLdrModELFCommon_h__
-#define __kLdrModELFCommon_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 {
-	KU32	n_namesz;	/* Length of name. */
-	KU32	n_descsz;	/* Length of descriptor. */
-	KU32	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_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. */
-#define NT_PRSTATUS	1	/* Process status. */
-#define NT_FPREGSET	2	/* Floating point registers. */
-#define NT_PRPSINFO	3	/* Process state info. */
-
-/* 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_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: unk/kStuff/kLdr/kLdrModELFi386.h
===================================================================
--- /trunk/kStuff/kLdr/kLdrModELFi386.h	(revision 3567)
+++ 	(revision )
@@ -1,133 +1,0 @@
-/*-
- * 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.
- *
- * $FreeBSD: src/sys/i386/include/elf.h,v 1.16 2004/08/02 19:12:17 dfr Exp $
- */
-
-#ifndef __kLdrModELFi386_h__
-#define __kLdrModELFi386_h__
-
-#if 0 /** @todo Auxiliary vector entries. */
-
-/*
- * 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 /* [todo] */
-
-
-/*
- * 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/kStuff/kLdr/kLdrModLX.c
===================================================================
--- /trunk/kStuff/kLdr/kLdrModLX.c	(revision 3567)
+++ /trunk/kStuff/kLdr/kLdrModLX.c	(revision 3568)
@@ -32,5 +32,5 @@
 #include "kLdrHlp.h"
 #include "kLdrInternal.h"
-#include "kLdrModLX.h"
+#include <k/kLdrFmts/lx.h>
 
 
Index: unk/kStuff/kLdr/kLdrModLX.h
===================================================================
--- /trunk/kStuff/kLdr/kLdrModLX.h	(revision 3567)
+++ 	(revision )
@@ -1,456 +1,0 @@
-/* $Id $ */
-
-#ifndef __kLdrModLX_h__
-#define __kLdrModLX_h__
-
-#include "kLdrBase.h"
-
-
-#ifndef IMAGE_OS2_SIGNATURE_LX
-/** LX signature ("LX") */
-# define IMAGE_LX_SIGNATURE  KLDR_LE2H_U16('L' | ('X' << 8))
-#endif
-
-#pragma pack(1)
-
-/**
- * Linear eXecutable header.
- * This structure is exactly 196 bytes long.
- */
-struct e32_exe
-{
-    KU8                 e32_magic[2];
-    KU8                 e32_border;
-    KU8                 e32_worder;
-    KU32                e32_level;
-    KU16                e32_cpu;
-    KU16                e32_os;
-    KU32                e32_ver;
-    KU32                e32_mflags;
-    KU32                e32_mpages;
-    KU32                e32_startobj;
-    KU32                e32_eip;
-    KU32                e32_stackobj;
-    KU32                e32_esp;
-    KU32                e32_pagesize;
-    KU32                e32_pageshift;
-    /** The size of the fixup section.
-     * The fixup section consists of the fixup page table, the fixup record table,
-     * the import module table, and the import procedure name table.
-     */
-    KU32                e32_fixupsize;
-    KU32                e32_fixupsum;
-    /** The size of the resident loader section.
-     * This includes the object table, the object page map table, the resource table, the resident name table,
-     * the entry table, the module format directives table, and the page checksum table (?). */
-    KU32                e32_ldrsize;
-    /** The checksum of the loader section. 0 if not calculated. */
-    KU32                e32_ldrsum;
-    /** The offset of the object table relative to this structure. */
-    KU32                e32_objtab;
-    /** Count of objects. */
-    KU32                e32_objcnt;
-    /** The offset of the object page map table relative to this structure. */
-    KU32                e32_objmap;
-    /** The offset of the object iterated pages (whatever this is used for) relative to the start of the file. */
-    KU32                e32_itermap;
-    /** The offset of the resource table relative to this structure. */
-    KU32                e32_rsrctab;
-    /** The number of entries in the resource table. */
-    KU32                e32_rsrccnt;
-    /** The offset of the resident name table relative to this structure. */
-    KU32                e32_restab;
-    /** The offset of the entry (export) table relative to this structure. */
-    KU32                e32_enttab;
-    /** The offset of the module format directives table relative to this structure. */
-    KU32                e32_dirtab;
-    /** The number of entries in the module format directives table. */
-    KU32                e32_dircnt;
-    /** The offset of the fixup page table relative to this structure. */
-    KU32                e32_fpagetab;
-    /** The offset of the fixup record table relative to this structure. */
-    KU32                e32_frectab;
-    /** The offset of the import module name table relative to this structure. */
-    KU32                e32_impmod;
-    /** The number of entries in the import module name table. */
-    KU32                e32_impmodcnt;
-    /** The offset of the import procedure name table relative to this structure. */
-    KU32                e32_impproc;
-    /** The offset of the page checksum table relative to this structure. */
-    KU32                e32_pagesum;
-    /** The offset of the data pages relative to the start of the file. */
-    KU32                e32_datapage;
-    /** The number of preload pages (ignored). */
-    KU32                e32_preload;
-    /** The offset of the non-resident name table relative to the start of the file. */
-    KU32                e32_nrestab;
-    /** The size of the non-resident name table. */
-    KU32                e32_cbnrestab;
-    KU32                e32_nressum;
-    KU32                e32_autodata;
-    KU32                e32_debuginfo;
-    KU32                e32_debuglen;
-    KU32                e32_instpreload;
-    KU32                e32_instdemand;
-    KU32                e32_heapsize;
-    KU32                e32_stacksize;
-    KU8                 e32_res3[20];
-};
-
-/** e32_magic[0] */
-#define E32MAGIC1       'L'
-/** e32_magic[1] */
-#define E32MAGIC2       'X'
-/** MAKEWORD(e32_magic[0], e32_magic[1]) */
-#define E32MAGIC        0x584c
-/** e32_border - little endian */
-#define E32LEBO         0
-/** e32_border - big endian */
-#define E32BEBO         1
-/** e32_worder - little endian */
-#define E32LEWO         0
-/** e32_worder - big endian */
-#define E32BEWO         1
-/** e32_level */
-#define E32LEVEL        KU32_C(0)
-/** e32_cpu - 80286 */
-#define E32CPU286       1
-/** e32_cpu - 80386 */
-#define E32CPU386       2
-/** e32_cpu - 80486 */
-#define E32CPU486       3
-/** e32_pagesize */
-#define OBJPAGELEN      KU32_C(0x1000)
-
-
-/** @name e32_mflags
- * @{ */
-/** App Type: Fullscreen only. */
-#define E32NOPMW         KU32_C(0x00000100)
-/** App Type: PM API. */
-#define E32PMAPI         KU32_C(0x00000300)
-/** App Type: PM VIO compatible. */
-#define E32PMW           KU32_C(0x00000200)
-/** Application type mask. */
-#define E32APPMASK       KU32_C(0x00000300)
-/** Executable module. */
-#define E32MODEXE        KU32_C(0x00000000)
-/** Dynamic link library (DLL / library) module. */
-#define E32MODDLL        KU32_C(0x00008000)
-/** Protected memory DLL. */
-#define E32PROTDLL       KU32_C(0x00010000)
-/** Physical Device Driver. */
-#define E32MODPDEV       KU32_C(0x00020000)
-/** Virtual Device Driver. */
-#define E32MODVDEV       KU32_C(0x00028000)
-/** Device driver */
-#define E32DEVICE        E32MODPDEV
-/** Dynamic link library (DLL / library) module. */
-#define E32NOTP          E32MODDLL
-/** Protected memory DLL. */
-#define E32MODPROTDLL    (E32MODDLL | E32PROTDLL)
-/** Module Type mask. */
-#define E32MODMASK       KU32_C(0x00038000)
-/** Not loadable (linker error). */
-#define E32NOLOAD        KU32_C(0x00002000)
-/** No internal fixups. */
-#define E32NOINTFIX      KU32_C(0x00000010)
-/** No external fixups (i.e. imports). */
-#define E32NOEXTFIX      KU32_C(0x00000020)
-/** System DLL, no internal fixups. */
-#define E32SYSDLL        KU32_C(0x00000008)
-/** Global (set) or per instance (cleared) library initialization. */
-#define E32LIBINIT       KU32_C(0x00000004)
-/** Global (set) or per instance (cleared) library termination. */
-#define E32LIBTERM       KU32_C(0x40000000)
-/** Indicates when set in an executable that the process isn't SMP safe. */
-#define E32NOTMPSAFE     KU32_C(0x00080000)
-/** @} */
-
-/** @name Relocations (aka Fixups).
- * @{ */
-typedef union _offset
-{
-    KU16                offset16;
-    KU32                offset32;
-} offset;
-
-/** A relocation.
- * @remark this structure isn't very usable since LX relocations comes in too many size variations.
- */
-struct r32_rlc
-{
-    KU8                 nr_stype;
-    KU8                 nr_flags;
-    KI16                r32_soff;
-    KU16                r32_objmod;
-
-    union targetid
-    {
-        offset          intref;
-        union extfixup
-        {
-            offset      proc;
-            KU32        ord;
-        } extref;
-        struct addfixup
-        {
-            KU16        entry;
-            offset      addval;
-        } addfix;
-    } r32_target;
-    KU16                r32_srccount;
-    KU16                r32_chain;
-};
-
-/** @name Some attempt at size constanstants.
- * @{
- */
-#define RINTSIZE16      8
-#define RINTSIZE32      10
-#define RORDSIZE        8
-#define RNAMSIZE16      8
-#define RNAMSIZE32      10
-#define RADDSIZE16      10
-#define RADDSIZE32      12
-/** @} */
-
-/** @name nr_stype (source flags)
- * @{ */
-#define NRSBYT          0x00
-#define NRSSEG          0x02
-#define NRSPTR          0x03
-#define NRSOFF          0x05
-#define NRPTR48         0x06
-#define NROFF32         0x07
-#define NRSOFF32        0x08
-#define NRSTYP          0x0f
-#define NRSRCMASK       0x0f
-#define NRALIAS         0x10
-#define NRCHAIN         0x20
-/** @} */
-
-/** @name nr_flags (target flags)
- * @{ */
-#define NRRINT          0x00
-#define NRRORD          0x01
-#define NRRNAM          0x02
-#define NRRENT          0x03
-#define NRRTYP          0x03
-#define NRADD           0x04
-#define NRICHAIN        0x08
-#define NR32BITOFF      0x10
-#define NR32BITADD      0x20
-#define NR16OBJMOD      0x40
-#define NR8BITORD       0x80
-/** @} */
-
-/** @} */
-
-
-/** @name The Object Table (aka segment table)
- * @{ */
-
-/** The Object Table Entry. */
-struct o32_obj
-{
-    /** The size of the object. */
-    KU32                o32_size;
-    /** The base address of the object. */
-    KU32                o32_base;
-    /** Object flags. */
-    KU32                o32_flags;
-    /** Page map index. */
-    KU32                o32_pagemap;
-    /** Page map size. (doesn't need to be o32_size >> page shift). */
-    KU32                o32_mapsize;
-    /** Reserved */
-    KU32                o32_reserved;
-};
-
-/** @name o32_flags
- * @{ */
-/** Read access. */
-#define OBJREAD         KU32_C(0x00000001)
-/** Write access. */
-#define OBJWRITE        KU32_C(0x00000002)
-/** Execute access. */
-#define OBJEXEC         KU32_C(0x00000004)
-/** Resource object. */
-#define OBJRSRC         KU32_C(0x00000008)
-/** The object is discarable (i.e. don't swap, just load in pages from the executable).
- * This overlaps a bit with object type. */
-#define OBJDISCARD      KU32_C(0x00000010)
-/** The object is shared. */
-#define OBJSHARED       KU32_C(0x00000020)
-/** The object has preload pages. */
-#define OBJPRELOAD      KU32_C(0x00000040)
-/** The object has invalid pages. */
-#define OBJINVALID      KU32_C(0x00000080)
-/** Non-permanent, link386 bug. */
-#define LNKNONPERM      KU32_C(0x00000600)
-/** Non-permanent, correct 'value'. */
-#define OBJNONPERM      KU32_C(0x00000000)
-/** Obj Type: The object is permanent and swappable. */
-#define OBJPERM         KU32_C(0x00000100)
-/** Obj Type: The object is permanent and resident (i.e. not swappable). */
-#define OBJRESIDENT     KU32_C(0x00000200)
-/** Obj Type: The object is resident and contigious. */
-#define OBJCONTIG       KU32_C(0x00000300)
-/** Obj Type: The object is permanent and long locable. */
-#define OBJDYNAMIC      KU32_C(0x00000400)
-/** Object type mask. */
-#define OBJTYPEMASK     KU32_C(0x00000700)
-/** x86: The object require an 16:16 alias. */
-#define OBJALIAS16      KU32_C(0x00001000)
-/** x86: Big/Default selector setting, i.e. toggle 32-bit or 16-bit. */
-#define OBJBIGDEF       KU32_C(0x00002000)
-/** x86: conforming selector setting (weird stuff). */
-#define OBJCONFORM      KU32_C(0x00004000)
-/** x86: IOPL. */
-#define OBJIOPL         KU32_C(0x00008000)
-/** @} */
-
-/** A Object Page Map Entry. */
-struct o32_map
-{
-    /** The file offset of the page. */
-    KU32                o32_pagedataoffset;
-    /** The number of bytes of raw page data. */
-    KU16                o32_pagesize;
-    /** Per page flags describing how the page is encoded in the file. */
-    KU16                o32_pageflags;
-};
-
-/** @name o32 o32_pageflags
- * @{
- */
-/** Raw page (uncompressed) in the file. */
-#define VALID           KU16_C(0x0000)
-/** RLE encoded page in file. */
-#define ITERDATA        KU16_C(0x0001)
-/** Invalid page, nothing in the file. */
-#define INVALID         KU16_C(0x0002)
-/** Zero page, nothing in file. */
-#define ZEROED          KU16_C(0x0003)
-/** range of pages (what is this?) */
-#define RANGE           KU16_C(0x0004)
-/** Compressed page in file. */
-#define ITERDATA2       KU16_C(0x0005)
-/** @} */
-
-
-/** Iteration Record format (RLE compressed page). */
-struct LX_Iter
-{
-    /** Number of iterations. */
-    KU16                LX_nIter;
-    /** The number of bytes that's being iterated. */
-    KU16                LX_nBytes;
-    /** The bytes. */
-    KU8                 LX_Iterdata;
-};
-
-/** @} */
-
-
-/** A Resource Table Entry */
-struct rsrc32
-{
-    /** Resource Type. */
-    KU16                type;
-    /** Resource ID. */
-    KU16                name;
-    /** Resource size in bytes. */
-    KU32                cb;
-    /** The index of the object containing the resource. */
-    KU16                obj;
-    /** Offset of the resource that within the object. */
-    KU32                offset;
-};
-
-
-/** @name The Entry Table (aka Export Table)
- * @{ */
-
-/** Entry bundle.
- * Header descripting up to 255 entries that follows immediatly after this structure. */
-struct b32_bundle
-{
-    /** The number of entries. */
-    KU8                 b32_cnt;
-    /** The type of bundle. */
-    KU8                 b32_type;
-    /** The index of the object containing these entry points. */
-    KU16                b32_obj;
-};
-
-/** @name b32_type
- * @{ */
-/** Empty bundle, filling up unused ranges of ordinals. */
-#define EMPTY           0x00
-/** 16-bit offset entry point. */
-#define ENTRY16         0x01
-/** 16-bit callgate entry point. */
-#define GATE16          0x02
-/** 32-bit offset entry point. */
-#define ENTRY32         0x03
-/** Forwarder entry point. */
-#define ENTRYFWD        0x04
-/** Typing information present indicator. */
-#define TYPEINFO        0x80
-/** @} */
-
-
-/** Entry point. */
-struct e32_entry
-{
-    /** Entry point flags */
-    KU8                 e32_flags;      /* Entry point flags */
-    union entrykind
-    {
-        /** ENTRY16 or ENTRY32. */
-        offset          e32_offset;
-        /** GATE16 */
-        struct callgate
-        {
-            /** Offset into segment. */
-            KU16        offset;
-            /** The callgate selector */
-            KU16        callgate;
-        } e32_callgate;
-        /** ENTRYFWD */
-        struct fwd
-        {
-            /** Module ordinal number (i.e. into the import module table). */
-            KU16        modord;
-            /** Procedure name or ordinal number. */
-            KU32        value;
-        } e32_fwd;
-    } e32_variant;
-};
-
-/** @name e32_flags
- * @{ */
-/** Exported entry (set) or private entry (clear). */
-#define E32EXPORT       0x01
-/** Uses shared data. */
-#define E32SHARED       0x02
-/** Parameter word count mask. */
-#define E32PARAMS       0xf8
-/** ENTRYFWD: Imported by ordinal (set) or by name (clear). */
-#define FWD_ORDINAL     0x01
-/** @} */
-
-/** @name dunno
- * @{ */
-#define FIXENT16        3
-#define FIXENT32        5
-#define GATEENT16       5
-#define FWDENT          7
-/** @} */
-
-#pragma pack()
-
-#endif
-
Index: unk/kStuff/kLdr/kLdrModMZ.h
===================================================================
--- /trunk/kStuff/kLdr/kLdrModMZ.h	(revision 3567)
+++ 	(revision )
@@ -1,41 +1,0 @@
-/* $Id$ */
-
-#ifndef __kLdrModMZ_h__
-#define __kLdrModMZ_h__
-
-#include "kLdrBase.h"
-
-#pragma pack(1) /* not required */
-
-typedef struct _IMAGE_DOS_HEADER
-{
-    KU16       e_magic;
-    KU16       e_cblp;
-    KU16       e_cp;
-    KU16       e_crlc;
-    KU16       e_cparhdr;
-    KU16       e_minalloc;
-    KU16       e_maxalloc;
-    KU16       e_ss;
-    KU16       e_sp;
-    KU16       e_csum;
-    KU16       e_ip;
-    KU16       e_cs;
-    KU16       e_lfarlc;
-    KU16       e_ovno;
-    KU16       e_res[4];
-    KU16       e_oemid;
-    KU16       e_oeminfo;
-    KU16       e_res2[10];
-    KU32       e_lfanew;
-} IMAGE_DOS_HEADER;
-typedef IMAGE_DOS_HEADER *PIMAGE_DOS_HEADER;
-
-#ifndef IMAGE_DOS_SIGNATURE
-# define IMAGE_DOS_SIGNATURE KLDR_LE2H_U16('M' | ('Z' << 8))
-#endif
-
-#pragma pack()
-
-#endif
-
Index: /trunk/kStuff/kLdr/kLdrModMachO.c
===================================================================
--- /trunk/kStuff/kLdr/kLdrModMachO.c	(revision 3567)
+++ /trunk/kStuff/kLdr/kLdrModMachO.c	(revision 3568)
@@ -32,5 +32,5 @@
 #include "kLdrHlp.h"
 #include "kLdrInternal.h"
-#include "kLdrModMachO.h"
+#include <k/kLdrFmts/mach-o.h>
 
 
Index: unk/kStuff/kLdr/kLdrModMachO.h
===================================================================
--- /trunk/kStuff/kLdr/kLdrModMachO.h	(revision 3567)
+++ 	(revision )
@@ -1,900 +1,0 @@
-/* $Id $ */
-/** @file
- * Mach-0 structures, types and defines.
- */
-
-#ifndef __kLdrModMachO_h__
-#define __kLdrModMachO_h__
-
-#include "kLdrBase.h"
-
-/** @defgroup grp_mach_o    The Mach-O Structures, Types, and Defines.
- * @{
- */
-
-
-#ifndef IMAGE_FAT_SIGNATURE
-/** The FAT signature (universal binaries). */
-# define IMAGE_FAT_SIGNATURE            KU32_C(0xcafebabe)
-#endif
-#ifndef IMAGE_FAT_SIGNATURE_OE
-/** The FAT signature (universal binaries), other endian. */
-# define IMAGE_FAT_SIGNATURE_OE         KU32_C(0xbebafeca)
-#endif
-
-/**
- * The fat header found at the start of universal binaries.
- * It is followed by \a nfat_arch numbers of \a fat_arch structures.
- */
-typedef struct fat_header
-{
-    KU32            magic;
-    KU32            nfat_arch;
-} fat_header_t;
-
-/**
- * Description of fat file item.
- */
-typedef struct fat_arch
-{
-    KI32            cputype;
-    KI32            cpusubtype;
-    KU32            offset;
-    KU32            size;
-    KU32            align;          /**< Power of 2. */
-} fat_arch_t;
-
-
-
-#ifndef IMAGE_MACHO32_SIGNATURE
-/** The 32-bit Mach-O signature. */
-# define IMAGE_MACHO32_SIGNATURE        KU32_C(0xfeedface)
-#endif
-#ifndef IMAGE_MACHO32_SIGNATURE_OE
-/** The 32-bit Mach-O signature, other endian. */
-# define IMAGE_MACHO32_SIGNATURE_OE     KU32_C(0xcefaedfe)
-#endif
-#define MH_MAGIC    IMAGE_MACHO32_SIGNATURE
-#define MH_CIGAM    IMAGE_MACHO32_SIGNATURE_OE
-
-/**
- * 32-bit Mach-O header.
- * This is followed by \a ncmds number of load commands.
- * @see mach_header_64
- */
-typedef struct mach_header_32
-{
-    KU32            magic;
-    KI32            cputype;
-    KI32            cpusubtype;
-    KU32            filetype;
-    KU32            ncmds;
-    KU32            sizeofcmds;
-    KU32            flags;
-} mach_header_32_t;
-
-
-
-#ifndef IMAGE_MACHO64_SIGNATURE
-/** The 64-bit Mach-O signature. */
-# define IMAGE_MACHO64_SIGNATURE        KU32_C(0xfeedfacf)
-#endif
-#ifndef IMAGE_MACHO64_SIGNATURE_OE
-/** The 64-bit Mach-O signature, other endian. */
-# define IMAGE_MACHO64_SIGNATURE_OE     KU32_C(0xfefaedfe)
-#endif
-#define MH_MAGIC_64 IMAGE_MACHO64_SIGNATURE
-#define MH_CIGAM_64 IMAGE_MACHO64_SIGNATURE_OE
-
-/**
- * 64-bit Mach-O header.
- * This is followed by \a ncmds number of load commands.
- * @see mach_header
- */
-typedef struct mach_header_64
-{
-    KU32            magic;
-    KI32            cputype;
-    KI32            cpusubtype;
-    KU32            filetype;
-    KU32            ncmds;
-    KU32            sizeofcmds;
-    KU32            flags;
-    KU32            reserved;       /**< (for proper struct and command alignment I guess) */
-} mach_header_64_t;
-
-
-/** @name File types (mach_header_64::filetype, mach_header_32::filetype)
- * @{
- */
-#define MH_OBJECT           KU32_C(1) /**< Object (relocatable). */
-#define MH_EXECUTE          KU32_C(2) /**< Executable (demand paged). */
-#define MH_FVMLIB           KU32_C(3) /**< Fixed VM shared library. */
-#define MH_CORE             KU32_C(4) /**< Core file. */
-#define MH_PRELOAD          KU32_C(5) /**< Preloaded executable. */
-#define MH_DYLIB            KU32_C(6) /**< Dynamically bound shared library. */
-#define MH_DYLINKER         KU32_C(7) /**< Dynamic linker. */
-#define MH_BUNDLE           KU32_C(8) /**< Dymamically bound bundle. */
-#define MH_DYLIB_STUB       KU32_C(9) /**< Shared library stub for static linking. */
-#define MH_DSYM             KU32_C(10)/**< Debug symbols. */
-
-/** @} */
-
-
-/** @name Mach-O Header flags (mach_header_64::flags, mach_header_32::flags)
- * @{
- */
-#define MH_NOUNDEFS                 KU32_C(0x00000001) /**< No undefined symbols. */
-#define MH_INCRLINK                 KU32_C(0x00000002) /**< Partial increment link output. */
-#define MH_DYLDLINK                 KU32_C(0x00000004) /**< Food for the dynamic linker, not for ld. */
-#define MH_BINDATLOAD               KU32_C(0x00000008) /**< Bind all undefined symbols at load time. */
-#define MH_PREBOUND                 KU32_C(0x00000010) /**< Contains prebound undefined symbols. */
-#define MH_SPLIT_SEGS               KU32_C(0x00000020) /**< Read-only and read-write segments are split. */
-#define MH_LAZY_INIT                KU32_C(0x00000040) /**< Obsolete flag for doing lazy init when data is written. */
-#define MH_TWOLEVEL                 KU32_C(0x00000080) /**< Uses two-level name space bindings. */
-#define MH_FORCE_FLAT               KU32_C(0x00000100) /**< Task: The executable forces all images to use flat name space bindings. */
-#define MH_NOMULTIDEFS              KU32_C(0x00000200) /**< No multiple symbol definitions, safe to use two-level namespace hints. */
-#define MH_NOFIXPREBINDING          KU32_C(0x00000400) /**< The dynamic linker should not notify the prebinding agent about this executable. */
-#define MH_PREBINDABLE              KU32_C(0x00000800) /**< Not prebound, but it can be. Invalid if MH_PREBOUND is set. */
-#define MH_ALLMODSBOUND             KU32_C(0x00001000) /**< Binds to all two-level namespace modules of preqs. Requires MH_PREBINDABLE and MH_TWOLEVEL to be set. */
-#define MH_SUBSECTIONS_VIA_SYMBOLS  KU32_C(0x00002000) /**< Safe to divide sections into sub-sections via symbols for dead code stripping. */
-#define MH_CANONICAL                KU32_C(0x00004000) /**< Canonicalized via unprebind. */
-#define MH_WEAK_DEFINES             KU32_C(0x00008000) /**< The (finally) linked image has weak symbols. */
-#define MH_BINDS_TO_WEAK            KU32_C(0x00010000) /**< The (finally) linked image uses weak symbols. */
-#define MH_ALLOW_STACK_EXECUTION    KU32_C(0x00020000) /**< Task: allow stack execution. (MH_EXECUTE only) */
-#define MH_VALID_FLAGS              KU32_C(0x0003ffff) /**< Mask containing the defined flags. */
-/** @} */
-
-
-/** @name CPU types / bits (mach_header_64::cputype, mach_header_32::cputype, fat_arch::cputype)
- * @{
- */
-#define CPU_ARCH_MASK               KI32_C(0xff000000)
-#define CPU_ARCH_ABI64              KI32_C(0x01000000)
-#define CPU_TYPE_ANY                KI32_C(-1)
-#define CPU_TYPE_VAX                KI32_C(1)
-#define CPU_TYPE_MC680x0            KI32_C(6)
-#define CPU_TYPE_X86                KI32_C(7)
-#define CPU_TYPE_I386               CPU_TYPE_X86
-#define CPU_TYPE_X86_64             (CPU_TYPE_X86 | CPU_ARCH_ABI64)
-#define CPU_TYPE_MC98000            KI32_C(10)
-#define CPU_TYPE_HPPA               KI32_C(11)
-#define CPU_TYPE_MC88000            KI32_C(13)
-#define CPU_TYPE_SPARC              KI32_C(14)
-#define CPU_TYPE_I860               KI32_C(15)
-#define CPU_TYPE_POWERPC            KI32_C(18)
-#define CPU_TYPE_POWERPC64          (CPU_TYPE_POWERPC | CPU_ARCH_ABI64)
-/** @} */
-
-
-/** @name CPU subtypes (mach_header_64::cpusubtype, mach_header_32::cpusubtype, fat_arch::cpusubtype)
- * @{ */
-#define CPU_SUBTYPE_MULTIPLE        KI32_C(-1)
-#define CPU_SUBTYPE_LITTLE_ENDIAN   KI32_C(0)  /**< figure this one out. */
-#define CPU_SUBTYPE_BIG_ENDIAN      KI32_C(1)  /**< ditto */
-
-/* VAX */
-#define CPU_SUBTYPE_VAX_ALL         KI32_C(0)
-#define CPU_SUBTYPE_VAX780          KI32_C(1)
-#define CPU_SUBTYPE_VAX785          KI32_C(2)
-#define CPU_SUBTYPE_VAX750          KI32_C(3)
-#define CPU_SUBTYPE_VAX730          KI32_C(4)
-#define CPU_SUBTYPE_UVAXI           KI32_C(5)
-#define CPU_SUBTYPE_UVAXII          KI32_C(6)
-#define CPU_SUBTYPE_VAX8200         KI32_C(7)
-#define CPU_SUBTYPE_VAX8500         KI32_C(8)
-#define CPU_SUBTYPE_VAX8600         KI32_C(9)
-#define CPU_SUBTYPE_VAX8650         KI32_C(10)
-#define CPU_SUBTYPE_VAX8800         KI32_C(11)
-#define CPU_SUBTYPE_UVAXIII         KI32_C(12)
-
-/* MC680xx */
-#define CPU_SUBTYPE_MC680x0_ALL     KI32_C(1)
-#define CPU_SUBTYPE_MC68030         KI32_C(1)
-#define CPU_SUBTYPE_MC68040         KI32_C(2)
-#define CPU_SUBTYPE_MC68030_ONLY    KI32_C(3)
-
-/* I386 */
-#define CPU_SUBTYPE_INTEL(fam, model)       ( (KI32)(((model) << 4) | (fam)) )
-#define CPU_SUBTYPE_INTEL_FAMILY(subtype)   ( (subtype) & 0xf )
-#define CPU_SUBTYPE_INTEL_MODEL(subtype)    ( (subtype) >> 4 )
-#define CPU_SUBTYPE_INTEL_FAMILY_MAX        0xf
-#define CPU_SUBTYPE_INTEL_MODEL_ALL         0
-
-#define CPU_SUBTYPE_I386_ALL        CPU_SUBTYPE_INTEL(3, 0)
-#define CPU_SUBTYPE_386             CPU_SUBTYPE_INTEL(3, 0)
-#define CPU_SUBTYPE_486             CPU_SUBTYPE_INTEL(4, 0)
-#define CPU_SUBTYPE_486SX           CPU_SUBTYPE_INTEL(4, 8)
-#define CPU_SUBTYPE_586             CPU_SUBTYPE_INTEL(5, 0)
-#define CPU_SUBTYPE_PENT            CPU_SUBTYPE_INTEL(5, 0)
-#define CPU_SUBTYPE_PENTPRO         CPU_SUBTYPE_INTEL(6, 1)
-#define CPU_SUBTYPE_PENTII_M3       CPU_SUBTYPE_INTEL(6, 3)
-#define CPU_SUBTYPE_PENTII_M5       CPU_SUBTYPE_INTEL(6, 5)
-#define CPU_SUBTYPE_CELERON         CPU_SUBTYPE_INTEL(7, 6)
-#define CPU_SUBTYPE_CELERON_MOBILE  CPU_SUBTYPE_INTEL(7, 7)
-#define CPU_SUBTYPE_PENTIUM_3       CPU_SUBTYPE_INTEL(8, 0)
-#define CPU_SUBTYPE_PENTIUM_3_M     CPU_SUBTYPE_INTEL(8, 1)
-#define CPU_SUBTYPE_PENTIUM_3_XEON  CPU_SUBTYPE_INTEL(8, 2)
-#define CPU_SUBTYPE_PENTIUM_M       CPU_SUBTYPE_INTEL(9, 0)
-#define CPU_SUBTYPE_PENTIUM_4       CPU_SUBTYPE_INTEL(10, 0)
-#define CPU_SUBTYPE_PENTIUM_4_M     CPU_SUBTYPE_INTEL(10, 1)
-#define CPU_SUBTYPE_ITANIUM         CPU_SUBTYPE_INTEL(11, 0)
-#define CPU_SUBTYPE_ITANIUM_2       CPU_SUBTYPE_INTEL(11, 1)
-#define CPU_SUBTYPE_XEON            CPU_SUBTYPE_INTEL(12, 0)
-#define CPU_SUBTYPE_XEON_MP         CPU_SUBTYPE_INTEL(12, 1)
-
-/* X86 */
-#define CPU_SUBTYPE_X86_ALL         KI32_C(3) /* CPU_SUBTYPE_I386_ALL */
-#define CPU_SUBTYPE_X86_64_ALL      KI32_C(3) /* CPU_SUBTYPE_I386_ALL */
-#define CPU_SUBTYPE_X86_ARCH1       KI32_C(4) /* CPU_SUBTYPE_I486_ALL */
-
-/* MIPS */
-#define CPU_SUBTYPE_MIPS_ALL        KI32_C(0)
-#define CPU_SUBTYPE_MIPS_R2300      KI32_C(1)
-#define CPU_SUBTYPE_MIPS_R2600      KI32_C(2)
-#define CPU_SUBTYPE_MIPS_R2800      KI32_C(3)
-#define CPU_SUBTYPE_MIPS_R2000a     KI32_C(4)
-#define CPU_SUBTYPE_MIPS_R2000      KI32_C(5)
-#define CPU_SUBTYPE_MIPS_R3000a     KI32_C(6)
-#define CPU_SUBTYPE_MIPS_R3000      KI32_C(7)
-
-/* MC98000 (PowerPC) */
-#define CPU_SUBTYPE_MC98000_ALL     KI32_C(0)
-#define CPU_SUBTYPE_MC98601         KI32_C(1)
-
-/* HP-PA */
-#define CPU_SUBTYPE_HPPA_ALL        KI32_C(0)
-#define CPU_SUBTYPE_HPPA_7100       KI32_C(0)
-#define CPU_SUBTYPE_HPPA_7100LC     KI32_C(1)
-
-/* MC88000 */
-#define CPU_SUBTYPE_MC88000_ALL     KI32_C(0)
-#define CPU_SUBTYPE_MC88100         KI32_C(1)
-#define CPU_SUBTYPE_MC88110         KI32_C(2)
-
-/* SPARC */
-#define CPU_SUBTYPE_SPARC_ALL       KI32_C(0)
-
-/* I860 */
-#define CPU_SUBTYPE_I860_ALL        KI32_C(0)
-#define CPU_SUBTYPE_I860_860        KI32_C(1)
-
-/* PowerPC */
-#define CPU_SUBTYPE_POWERPC_ALL     KI32_C(0)
-#define CPU_SUBTYPE_POWERPC_601     KI32_C(1)
-#define CPU_SUBTYPE_POWERPC_602     KI32_C(2)
-#define CPU_SUBTYPE_POWERPC_603     KI32_C(3)
-#define CPU_SUBTYPE_POWERPC_603e    KI32_C(4)
-#define CPU_SUBTYPE_POWERPC_603ev   KI32_C(5)
-#define CPU_SUBTYPE_POWERPC_604     KI32_C(6)
-#define CPU_SUBTYPE_POWERPC_604e    KI32_C(7)
-#define CPU_SUBTYPE_POWERPC_620     KI32_C(8)
-#define CPU_SUBTYPE_POWERPC_750     KI32_C(9)
-#define CPU_SUBTYPE_POWERPC_7400    KI32_C(10)
-#define CPU_SUBTYPE_POWERPC_7450    KI32_C(11)
-#define CPU_SUBTYPE_POWERPC_Max     KI32_C(10)
-#define CPU_SUBTYPE_POWERPC_SCVger  KI32_C(11)
-#define CPU_SUBTYPE_POWERPC_970     KI32_C(100)
-
-/** @} */
-
-
-
-/** @defgroup grp_macho_o_lc        Load Commands
- * @{ */
-
-/**
- * The load command common core structure.
- *
- * After the Mach-O header follows an array of variable sized
- * load command which all has this header in common.
- */
-typedef struct load_command
-{
-    KU32            cmd;            /**< The load command id. */
-    KU32            cmdsize;        /**< The size of the command (including this header). */
-} load_command_t;
-
-/** @name Load Command IDs (load_command::cmd)
- * @{
- */
-/** Flag that when set requires the dynamic linker to fail if it doesn't
- * grok the command. The dynamic linker will otherwise ignore commands it
- * doesn't understand. Introduced with Mac OS X 10.1. */
-#define LC_REQ_DYLD         KU32_C(0x80000000)
-
-#define LC_SEGMENT_32       KU32_C(0x01)  /**< Segment to be mapped (32-bit). See segment_command_32. */
-#define LC_SYMTAB           KU32_C(0x02)  /**< 'stab' symbol table. See symtab_command. */
-#define LC_SYMSEG           KU32_C(0x03)  /**< Obsoleted gdb symbol table. */
-#define LC_THREAD           KU32_C(0x04)  /**< Thread. See thread_command. */
-#define LC_UNIXTHREAD       KU32_C(0x05)  /**< Unix thread (includes stack and stuff). See thread_command. */
-#define LC_LOADFVMLIB       KU32_C(0x06)  /**< Load a specified fixed VM shared library  (obsolete?). See fvmlib_command. */
-#define LC_IDFVMLIB         KU32_C(0x07)  /**< Fixed VM shared library id (obsolete?). See fvmlib_command. */
-#define LC_IDENT            KU32_C(0x08)  /**< Identification info (obsolete). See ident_command. */
-#define LC_FVMFILE          KU32_C(0x09)  /**< Fixed VM file inclusion (internal). See fvmfile_command. */
-#define LC_PREPAGE          KU32_C(0x0a)  /**< Prepage command (internal). See ?? */
-#define LC_DYSYMTAB         KU32_C(0x0b)  /**< Symbol table for dynamic linking. See dysymtab_command. */
-#define LC_LOAD_DYLIB       KU32_C(0x0c)  /**< Load a dynamically linked shared library. See dylib_command. */
-#define LC_ID_DYLIB         KU32_C(0x0d)  /**< Dynamically linked share library ident. See dylib_command. */
-#define LC_LOAD_DYLINKER    KU32_C(0x0e)  /**< Load a dynamical link editor. See dylinker_command. */
-#define LC_ID_DYLINKER      KU32_C(0x0f)  /**< Dynamic link editor ident. See dylinker_command. */
-#define LC_PREBOUND_DYLIB   KU32_C(0x10)  /**< Prebound modules for dynamically linking of a shared lib. See prebound_dylib_command. */
-#define LC_ROUTINES         KU32_C(0x11)  /**< Image routines. See routines_command_32. */
-#define LC_SUB_FRAMEWORK    KU32_C(0x12)  /**< Sub framework. See sub_framework_command. */
-#define LC_SUB_UMBRELLA     KU32_C(0x13)  /**< Sub umbrella. See sub_umbrella_command. */
-#define LC_SUB_CLIENT       KU32_C(0x14)  /**< Sub client. See sub_client_command. */
-#define LC_SUB_LIBRARY      KU32_C(0x15)  /**< Sub library. See sub_library_command. */
-#define LC_TWOLEVEL_HINTS   KU32_C(0x16)  /**< Two-level namespace lookup hints. See twolevel_hints_command. */
-#define LC_PREBIND_CKSUM    KU32_C(0x17)  /**< Prebind checksum. See prebind_cksum_command. */
-#define LC_LOAD_WEAK_DYLIB (KU32_C(0x18) | LC_REQ_DYLD) /**< Dylib that can be missing, all symbols weak. See dylib_command. */
-#define LC_SEGMENT_64       KU32_C(0x19)  /**< segment to be mapped (64-bit). See segment_command_32. */
-#define LC_ROUTINES_64      KU32_C(0x1a)  /**< Image routines (64-bit). See routines_command_32. */
-#define LC_UUID             KU32_C(0x1b)  /**< The UUID of the object module. See uuid_command.  */
-/** @} */
-
-
-/**
- * Load Command String.
- */
-typedef struct lc_str
-{
-    /** Offset of the string relative to the load_command structure.
-     * The string is zero-terminated. the size of the load command
-     * is zero padded up to a multiple of 4 bytes. */
-    KU32            offset;
-} lc_str_t;
-
-
-/**
- * Segment load command (32-bit).
- */
-typedef struct segment_command_32
-{
-    KU32            cmd;            /**< LC_SEGMENT */
-    KU32            cmdsize;        /**< sizeof(self) + sections. */
-    char            segname[16];    /**< The segment name. */
-    KU32            vmaddr;         /**< Memory address of this segment. */
-    KU32            vmsize;         /**< Size of this segment. */
-    KU32            fileoff;        /**< The file location of the segment. */
-    KU32            filesize;       /**< The file size of the segment. */
-    KU32            maxprot;        /**< Maximum VM protection. */
-    KU32            initprot;       /**< Initial VM protection. */
-    KU32            nsects;         /**< Number of section desciptors following this structure. */
-    KU32            flags;          /**< Flags (SG_*). */
-} segment_command_32_t;
-
-
-/**
- * Segment load command (64-bit).
- * Same as segment_command_32 except 4 members has been blown up to 64-bit.
- */
-typedef struct segment_command_64
-{
-    KU32            cmd;            /**< LC_SEGMENT */
-    KU32            cmdsize;        /**< sizeof(self) + sections. */
-    char            segname[16];    /**< The segment name. */
-    KU64            vmaddr;         /**< Memory address of this segment. */
-    KU64            vmsize;         /**< Size of this segment. */
-    KU64            fileoff;        /**< The file location of the segment. */
-    KU64            filesize;       /**< The file size of the segment. */
-    KU32            maxprot;        /**< Maximum VM protection. */
-    KU32            initprot;       /**< Initial VM protection. */
-    KU32            nsects;         /**< Number of section desciptors following this structure. */
-    KU32            flags;          /**< Flags (SG_*). */
-} segment_command_64_t;
-
-/** @name Segment flags (segment_command_64::flags, segment_command_32::flags)
- * @{ */
-/** Map the file bits in the top end of the memory area for the segment
- * instead of the low end. Intended for stacks in core dumps.
- * The part of the segment memory not covered by file bits will be zeroed. */
-#define SG_HIGHVM           KU32_C(0x00000001)
-/** This segment is the virtual memory allocated by a fixed VM library.
- * (Used for overlap checking in the linker.) */
-#define SG_FVMLIB           KU32_C(0x00000002)
-/** No relocations for or symbols that's relocated to in this segment.
- * The segment can therefore safely be replaced. */
-#define SG_NORELOC          KU32_C(0x00000004)
-/** The segment is protected.
- * The first page isn't protected if it starts at file offset 0
- * (so that the mach header and this load command can be easily mapped). */
-#define SG_PROTECTED_VERSION_1 KU32_C(0x00000008)
-/** @} */
-
-
-/**
- * 32-bit section (part of a segment load command).
- */
-typedef struct section_32
-{
-    char            sectname[16];   /**< The section name. */
-    char            segname[16];    /**< The name of the segment this section goes into. */
-    KU32            addr;           /**< The memory address of this section. */
-    KU32            size;           /**< The size of this section. */
-    KU32            offset;         /**< The file offset of this section. */
-    KU32            align;          /**< The section alignment (**2). */
-    KU32            reloff;         /**< The file offset of the relocations. */
-    KU32            nreloc;         /**< The number of relocations. */
-    KU32            flags;          /**< The section flags; section type and attribs */
-    KU32            reserved1;      /**< Reserved / offset / index. */
-    KU32            reserved2;      /**< Reserved / count / sizeof. */
-} section_32_t;
-
-/**
- * 64-bit section (part of a segment load command).
- */
-typedef struct section_64
-{
-    char            sectname[16];   /**< The section name. */
-    char            segname[16];    /**< The name of the segment this section goes into. */
-    KU64            addr;           /**< The memory address of this section. */
-    KU64            size;           /**< The size of this section. */
-    KU32            offset;         /**< The file offset of this section. */
-    KU32            align;          /**< The section alignment (**2). */
-    KU32            reloff;         /**< The file offset of the relocations. */
-    KU32            nreloc;         /**< The number of relocations. */
-    KU32            flags;          /**< The section flags; section type and attribs */
-    KU32            reserved1;      /**< Reserved / offset / index. */
-    KU32            reserved2;      /**< Reserved / count / sizeof. */
-    KU32            reserved3;      /**< (Just) Reserved. */
-} section_64_t;
-
-/** @name Section flags (section_64::flags, section_32::flags)
- * @{
- */
-/** Section type mask. */
-#define SECTION_TYPE                KU32_C(0x000000ff)
-/** Regular section. */
-#define S_REGULAR                   0x0
-/** Zero filled section. */
-#define S_ZEROFILL                  0x1
-/** C literals. */
-#define S_CSTRING_LITERALS          0x2
-/** 4 byte literals. */
-#define S_4BYTE_LITERALS            0x3
-/** 8 byte literals. */
-#define S_8BYTE_LITERALS            0x4
-/** Pointer to literals. */
-#define S_LITERAL_POINTERS          0x5
-/** Section containing non-lazy symbol pointers.
- * Reserved1 == start index in the indirect symbol table. */
-#define S_NON_LAZY_SYMBOL_POINTERS  0x6
-/** Section containing lazy symbol pointers.
- * Reserved1 == start index in the indirect symbol table. */
-#define S_LAZY_SYMBOL_POINTERS      0x7
-/** Section containing symbol stubs.
- * Reserved2 == stub size. */
-#define S_SYMBOL_STUBS              0x8
-/** Section containing function pointers for module initialization. . */
-#define S_MOD_INIT_FUNC_POINTERS    0x9
-/** Section containing function pointers for module termination. . */
-#define S_MOD_TERM_FUNC_POINTERS    0xa
-/** Section containing symbols that are to be coalesced. */
-#define S_COALESCED                 0xb
-/** Zero filled section that be larger than 4GB. */
-#define S_GB_ZEROFILL               0xc
-/** Section containing pairs of function pointers for interposing. */
-#define S_INTERPOSING               0xd
-/** 16 byte literals. */
-#define S_16BYTE_LITERALS           0xe
-
-/** Section attribute mask. */
-#define SECTION_ATTRIBUTES          KU32_C(0xffffff00)
-
-/** User settable attribute mask. */
-#define SECTION_ATTRIBUTES_USR      KU32_C(0xff000000)
-/** Pure instruction (code). */
-#define S_ATTR_PURE_INSTRUCTIONS    KU32_C(0x80000000)
-/** ranlib, ignore my symbols... */
-#define S_ATTR_NO_TOC               KU32_C(0x40000000)
-/** May strip static symbols when linking int a MH_DYLDLINK file. */
-#define S_ATTR_STRIP_STATIC_SYMS    KU32_C(0x20000000)
-/** No dead stripping. */
-#define S_ATTR_NO_DEAD_STRIP        KU32_C(0x10000000)
-/** Live support. */
-#define S_ATTR_LIVE_SUPPORT         KU32_C(0x08000000)
-/** Contains self modifying code (generally i386 code stub for dyld). */
-#define S_ATTR_SELF_MODIFYING_CODE  KU32_C(0x04000000)
-/** Debug info (DWARF usually). */
-#define S_ATTR_DEBUG                KU32_C(0x02000000)
-
-/** System settable attribute mask. */
-#define SECTION_ATTRIBUTES_SYS      KU32_C(0x00ffff00)
-/** Contains some instructions (code). */
-#define S_ATTR_SOME_INSTRUCTIONS    KU32_C(0x00000400)
-/** Has external relocations. */
-#define S_ATTR_EXT_RELOC            KU32_C(0x00000200)
-/** Has internal (local) relocations. */
-#define S_ATTR_LOC_RELOC            KU32_C(0x00000100)
-/** @} */
-
-/** @name Known Segment and Section Names.
- * Some of these implies special linker behaviour.
- * @{
- */
-/** Page zero - not-present page for catching invalid access. (MH_EXECUTE typically) */
-#define SEG_PAGEZERO        "__PAGEZERO"
-/** Traditional UNIX text segment.
- * Defaults to R-X. */
-#define SEG_TEXT            "__TEXT"
-/** The text part of SEG_TEXT. */
-#define SECT_TEXT               "__text"
-/** The fvmlib initialization. */
-#define SECT_FVMLIB_INIT0       "__fvmlib_init0"
-/** The section following the fvmlib initialization. */
-#define SECT_FVMLIB_INIT1       "__fvmlib_init1"
-/** The traditional UNIX data segment. (DGROUP to DOS and OS/2 people.) */
-#define SEG_DATA            "__DATA"
-/** The initialized data section. */
-#define SECT_DATA               "__data"
-/** The uninitialized data section. */
-#define SECT_BSS                "__bss"
-/** The common symbol section. */
-#define SECT_COMMON             "__common"
-/** Objective-C runtime segment. */
-#define SEG_OBJC            "__OBJC"
-/** Objective-C symbol table section. */
-#define SECT_OBJC_SYMBOLS       "__symbol_table"
-/** Objective-C module information section. */
-#define SECT_OBJC_MODULES       "__module_info"
-/** Objective-C string table section. */
-#define SECT_OBJC_STRINGS       "__selector_strs"
-/** Objective-C string table section. */
-#define SECT_OBJC_REFS          "__selector_refs"
-/** Icon segment. */
-#define SEG_ICON            "__ICON"
-/** The icon headers. */
-#define SECT_ICON_HEADER        "__header"
-/** The icons in the TIFF format. */
-#define SECT_ICON_TIFF          "__tiff"
-/** ld -seglinkedit segment containing all the structs create and maintained
- * by the linker. MH_EXECUTE and MH_FVMLIB only. */
-#define SEG_LINKEDIT        "__LINKEDIT"
-/** The unix stack segment. */
-#define SEG_UNIXSTACK       "__UNIXSTACK"
-/** The segment for the self modifying code for dynamic linking.
- * Implies RWX permissions. */
-#define SEG_IMPORT          "__IMPORT"
-/** @} */
-
-
-/** @todo fvmlib */
-/** @todo fvmlib_command (LC_IDFVMLIB or LC_LOADFVMLIB) */
-/** @todo dylib */
-/** @todo dylib_command (LC_ID_DYLIB, LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB) */
-/** @todo sub_framework_command (LC_SUB_FRAMEWORK) */
-/** @todo sub_client_command (LC_SUB_CLIENT) */
-/** @todo sub_umbrella_command (LC_SUB_UMBRELLA) */
-/** @todo sub_library_command (LC_SUB_LIBRARY) */
-/** @todo prebound_dylib_command (LC_PREBOUND_DYLIB) */
-/** @todo dylinker_command (LC_ID_DYLINKER or LC_LOAD_DYLINKER) */
-
-
-/**
- * Thread command.
- *
- * State description of a thread that is to be created. The description
- * is made up of a number of state structures preceded by a 32-bit flavor
- * and 32-bit count field stating the kind of stat structure and it's size
- * in KU32 items respecitvly.
- *
- * LC_UNIXTHREAD differs from LC_THREAD in that it implies stack creation
- * and that it's started with the typical main(int, char **, char **) frame
- * on the stack.
- */
-typedef struct thread_command
-{
-    KU32            cmd;        /**< LC_UNIXTHREAD or LC_THREAD. */
-    KU32            cmdsize;    /**< The size of the command (including this header). */
-} thread_command_t;
-
-
-/** @todo routines_command (LC_ROUTINES) */
-/** @todo routines_command_64 (LC_ROUTINES_64) */
-
-
-/**
- * Symbol table command.
- * Contains a.out style symbol table with some tricks.
- */
-typedef struct symtab_command
-{
-    KU32            cmd;        /**< LC_SYMTAB */
-    KU32            cmdsize;    /** sizeof(symtab_command_t) */
-    KU32            symoff;     /** The file offset of the symbol table. */
-    KU32            nsyms;      /** The number of symbols in the symbol table. */
-    KU32            stroff;     /** The file offset of the string table. */
-    KU32            strsize;    /** The size of the string table. */
-} symtab_command_t;
-
-
-/** @todo dysymtab_command (LC_DYSYMTAB)  */
-/** @todo dylib_table_of_contents */
-/** @todo dylib_module_32 */
-/** @todo dylib_module_64 */
-/** @todo dylib_reference */
-/** @todo twolevel_hints_command (LC_TWOLEVEL_HINTS) */
-/** @todo twolevel_hint */
-/** @todo prebind_cksum_command (LC_PREBIND_CKSUM) */
-
-
-/**
- * UUID generated by ld.
- */
-typedef struct uuid_command
-{
-    KU32            cmd;        /**< LC_UUID */
-    KU32            cmdsize;    /**< sizeof(uuid_command_t) */
-    KU8             uuid[16];   /** The UUID bytes. */
-} uuid_command_t;
-
-
-/** @todo symseg_command (LC_SYMSEG) */
-/** @todo ident_command (LC_IDENT) */
-/** @todo fvmfile_command (LC_FVMFILE) */
-
-/** @} */
-
-
-
-/** @defgroup grp_macho_o_syms  Symbol Table
- * @{ */
-
-/**
- * The 32-bit Mach-O version of the nlist structure.
- *
- * This differs from the a.out nlist struct in that the unused n_other field
- * was renamed to n_sect and used for keeping the relevant section number.
- * @remark  This structure is not name mach_nlist_32 in the Apple headers, but nlist.
- */
-typedef struct macho_nlist_32
-{
-    union
-    {
-        KI32    n_strx;         /**< Offset (index) into the string table. 0 means "". */
-    }           n_un;
-    KU8         n_type;         /**< Symbol type. */
-    KU8         n_sect;         /**< Section number of NO_SECT. */
-    KI16        n_desc;         /**< Type specific, debug info details mostly.*/
-    KU32        n_value;        /**< The symbol value or stab offset. */
-} macho_nlist_32_t;
-
-
-/**
- * The 64-bit Mach-O version of the nlist structure.
- * @see macho_nlist_32
- */
-typedef struct macho_nlist_64
-{
-    union
-    {
-        KU32    n_strx;         /**< Offset (index) into the string table. 0 means "". */
-    }           n_un;
-    KU8         n_type;         /**< Symbol type. */
-    KU8         n_sect;         /**< Section number of NO_SECT. */
-    KI16        n_desc;         /**< Type specific, debug info details mostly.*/
-    KU64        n_value;        /**< The symbol value or stab offset. */
-} macho_nlist_64_t;
-
-
-/** @name Symbol Type Constants (macho_nlist_32_t::n_type, macho_nlist_64_t::n_type)
- *
- * In the Mach-O world n_type is somewhat similar to a.out, meaning N_EXT, N_UNDF, N_ABS
- * and the debug symbols are essentially the same, but the remaining stuff is different.
- * The main reason for this is that the encoding of section has been moved to n_sect
- * to permit up to 255 sections instead of the fixed 3 a.out sections (not counting
- * the abs symbols and set vectors).
- *
- * To avoid confusion with a.out the Mach-O constants has been fitted with a MACHO_
- * prefix here.
- *
- * Common symbols (aka communal symbols and comdefs) are represented by
- * n_type = MACHO_N_EXT | MACHO_N_UNDF, n_sect = NO_SECT and n_value giving
- * the size.
- *
- *
- * Symbol table entries can be inserted directly in the assembly code using
- * this notation:
- * @code
- *      .stabs "n_name", n_type, n_sect, n_desc, n_value
- * @endcode
- *
- * (1) The line number is optional, GCC doesn't set it.
- * (2) The type is optional, GCC doesn't set it.
- * (3) The binutil header is "skeptical" about the line. I'm skeptical about the whole thing... :-)
- * (M) Mach-O specific?
- * (S) Sun specific?
- * @{
- */
-
-/* Base masks. */
-#define MACHO_N_EXT     KU8_C(0x01)   /**< External symbol (when set) (N_EXT). */
-#define MACHO_N_TYPE    KU8_C(0x0e)   /**< Symbol type (N_TYPE without the 8th bit). */
-#define MACHO_N_PEXT    KU8_C(0x10)   /**< Private extern symbol (when set). (M) */
-#define MACHO_N_STAB    KU8_C(0xe0)   /**< Debug symbol mask (N_STAB). */
-
-/* MACHO_N_TYPE values. */
-#define MACHO_N_UNDF    KU8_C(0x00)   /**< MACHO_N_TYPE: Undefined symbol (N_UNDF). n_sect = NO_SECT. */
-#define MACHO_N_ABS     KU8_C(0x02)   /**< MACHO_N_TYPE: Absolute symbol (N_UNDF). n_sect = NO_SECT. */
-#define MACHO_N_INDR    KU8_C(0x0a)   /**< MACHO_N_TYPE: Indirect symbol, n_value is the index of the symbol. (M) */
-#define MACHO_N_PBUD    KU8_C(0x0c)   /**< MACHO_N_TYPE: Prebound undefined symbo (defined in a dylib). (M) */
-#define MACHO_N_SECT    KU8_C(0x0e)   /**< MACHO_N_TYPE: Defined in the section given by n_sects. (M) */
-
-/* Debug symbols. */
-#define MACHO_N_GSYM    KU8_C(0x20)   /**< Global variable.       "name",, NO_SECT, type, 0       (2) */
-#define MACHO_N_FNAME   KU8_C(0x22)   /**< Function name (F77).   "name",, NO_SECT, 0, 0 */
-#define MACHO_N_FUN     KU8_C(0x24)   /**< Function / text var.   "name",, section, line, address (1) */
-#define MACHO_N_STSYM   KU8_C(0x26)   /**< Static data symbol.    "name",, section, type, address (2) */
-#define MACHO_N_LCSYM   KU8_C(0x28)   /**< static bss symbol.     "name",, section, type, address (2) */
-    /* omits N_MAIN and N_ROSYM. */
-#define MACHO_N_BNSYM   KU8_C(0x2e)   /**< Begin nsect symbol.         0,, section, 0, address (M) */
-#define MACHO_N_PC      KU8_C(0x30)   /**< Global pascal symbol.  "name",, NO_SECT, subtype?, line (3) */
-    /* omits N_NSYMS, N_NOMAP and N_OBJ. */
-#define MACHO_N_OPT     KU8_C(0x3c)   /**< Options for the debugger related to the language of the
-                                             source file.           "options?",,,, */
-#define MACHO_N_RSYM    KU8_C(0x40)   /**< Register variable.     "name",, NO_SECT, type, register */
-    /* omits N_M2C */
-#define MACHO_N_SLINE   KU8_C(0x44)   /**< Source line.                0,, section, line, address */
-    /* omits N_DSLINE, N_BSLINE / N_BROWS, N_DEFD and N_FLINE. */
-#define MACHO_N_ENSYM   KU8_C(0x4e)   /**< End nsect symbol.           0,, section, 0, address (M) */
-    /* omits N_EHDECL / N_MOD2 and N_CATCH. */
-#define MACHO_N_SSYM    KU8_C(0x60)   /**< Struct/union element.  "name",, NO_SECT, type, offset */
-    /* omits N_ENDM */
-#define MACHO_N_SO      KU8_C(0x64)   /**< Source file name.      "fname",, section, 0, address */
-#define MACHO_N_OSO     KU8_C(0x66)   /**< Object file name.      "fname",, 0, 0, st_mtime (M?) */
-    /* omits N_ALIAS */
-#define MACHO_N_LSYM    KU8_C(0x80)   /**< Stack variable.        "name",, NO_SECT, type, frame_offset */
-#define MACHO_N_BINCL   KU8_C(0x82)   /**< Begin #include.        "fname",, NO_SECT, 0, sum? */
-#define MACHO_N_SOL     KU8_C(0x84)   /**< #included file.        "fname",, section, 0, start_address (S) */
-#define MACHO_N_PARAMS  KU8_C(0x86)   /**< Compiler params.       "params",, NO_SECT, 0, 0 */
-#define MACHO_N_VERSION KU8_C(0x88)   /**< Compiler version.      "version",, NO_SECT, 0, 0 */
-#define MACHO_N_OLEVEL  KU8_C(0x8A)   /**< Compiler -O level.     "level",, NO_SECT, 0, 0 */
-#define MACHO_N_PSYM    KU8_C(0xa0)   /**< Parameter variable.    "name",, NO_SECT, type, frame_offset */
-#define MACHO_N_EINCL   KU8_C(0xa2)   /**< End #include.          "fname",, NO_SECT, 0, 0 (S) */
-#define MACHO_N_ENTRY   KU8_C(0xa4)   /**< Alternate entry point. "name",, section, line, address */
-#define MACHO_N_LBRAC   KU8_C(0xc0)   /**< Left bracket.               0,, NO_SECT, nesting_level, address */
-#define MACHO_N_EXCL    KU8_C(0xc2)   /**< Deleted include file.  "fname",, NO_SECT, 0, sum?  (S) */
-    /* omits N_SCOPE */
-#define MACHO_N_RBRAC   KU8_C(0xe0)   /**< Right bracket.              0,, NO_SECT, nesting_level, address */
-#define MACHO_N_BCOMM   KU8_C(0xe2)   /**< Begin common.          "name",, NO_SECT?, 0, 0 */
-#define MACHO_N_ECOMM   KU8_C(0xe4)   /**< End common.            "name",, section, 0, 0 */
-#define MACHO_N_ECOML   KU8_C(0xe8)   /**< End local common.           0,, section, 0, address */
-#define MACHO_N_LENG    KU8_C(0xfe)   /**< Length-value of the preceding entry.
-                                                                    "name",, NO_SECT, 0, length */
-
-/** @} */
-
-/** @name Symbol Description Bits (macho_nlist_32_t::n_desc, macho_nlist_64_t::n_desc)
- *
- * Mach-O puts the n_desc field to a number of uses, like lazy binding , library
- * ordinal numbers for -twolevel_namespace, stripping and weak symbol handling.
- *
- * @remark The REFERENCE_FLAGS_* are really not flags in the normal sense (bit),
- *         they are more like enum values.
- * @{
- */
-
-#define REFERENCE_TYPE                  KU16_C(0x000f)    /**< The reference type mask. */
-#define REFERENCE_FLAG_UNDEFINED_NON_LAZY             0     /**< Normal undefined symbol. */
-#define REFERENCE_FLAG_UNDEFINED_LAZY                 1     /**< Lazy undefined symbol. */
-#define REFERENCE_FLAG_DEFINED                        2     /**< Defined symbol (dynamic linking). */
-#define REFERENCE_FLAG_PRIVATE_DEFINED                3     /**< Defined private symbol (dynamic linking). */
-#define REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY     4     /**< Normal undefined private symbol. */
-#define REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY         5     /**< Lazy undefined private symbol. */
-
-#define REFERENCED_DYNAMICALLY          KU16_C(0x0010)    /**< Don't strip. */
-
-
-/** Get the dynamic library ordinal. */
-#define GET_LIBRARY_ORDINAL(n_desc)     \
-    (((n_desc) >> 8) & 0xff)
-/** Set the dynamic library ordinal. */
-#define SET_LIBRARY_ORDINAL(n_desc, ordinal) \
-    (n_desc) = (((n_desc) & 0xff) | (((ordinal) & 0xff) << 8))
-#define SELF_LIBRARY_ORDINAL            0x00                /**< Special ordinal for refering to onself. */
-#define MAX_LIBRARY_ORDINAL             0xfd                /**< Maximum ordinal number. */
-#define DYNAMIC_LOOKUP_ORDINAL          0xfe                /**< Special ordinal number for dynamic lookup. (Mac OS X 10.3 and later) */
-#define EXECUTABLE_ORDINAL              0xff                /**< Special ordinal number for the executable.  */
-
-
-/** Only MH_OBJECT: Never dead strip me! */
-#define N_NO_DEAD_STRIP                 KU16_C(0x0020)
-/** Not MH_OBJECT: Discarded symbol. */
-#define N_DESC_DISCARDED                KU16_C(0x0020)
-/** Weak external symbol. Symbol can be missing, in which case it's will have the value 0. */
-#define N_WEAK_REF                      KU16_C(0x0040)
-/** Weak symbol definition. The symbol can be overridden by another weak
- * symbol already present or by a non-weak (strong) symbol definition.
- * Currently only supported for coalesed symbols.
- * @remark This bit means something differently for undefined symbols, see N_REF_TO_WEAK.
- */
-#define N_WEAK_DEF                      KU16_C(0x0080)
-/** Reference to a weak symbol, resolve using flat namespace searching.
- * @remark This bit means something differently for defined symbols, see N_WEAK_DEF. */
-#define N_REF_TO_WEAK                   KU16_C(0x0080)
-
-/** @} */
-
-/** @} */
-
-
-/** @defgroup grp_macho_o_relocs    Relocations
- * @{ */
-
-/**
- * Relocation entry.
- *
- * Differs from a.out in the meaning of r_symbolnum when r_extern=0 and
- * that r_pad is made into r_type.
- *
- * @remark  This structure and type has been prefixed with macho_ to avoid
- *          confusion with the original a.out type.
- */
-typedef struct macho_relocation_info
-{
-    KI32        r_address;          /**< Section relative address of the fixup.
-                                         The top bit (signed) indicates that this is a scattered
-                                         relocation if set, see scattered_relocation_info_t. */
-    KU32        r_symbolnum : 24,   /**< r_extern=1: Symbol table index, relocate with the address of this symbol.
-                                         r_extern=0: Section ordinal, relocate with the address of this section. */
-                r_pcrel : 1,        /**< PC (program counter) relative fixup; subtract the fixup address. */
-                r_length : 2,       /**< Fixup length: 0=KU8, 1=KU16, 2=KU32, 3=KU64. */
-                r_extern : 1,       /**< External or internal fixup, decides the r_symbolnum interpretation.. */
-                r_type : 4;         /**< Relocation type; 0 is standard, non-zero are machine specific. */
-} macho_relocation_info_t;
-
-/** Special section ordinal value for absolute relocations. */
-#define R_ABS           0
-
-/** Flag in r_address indicating that the relocation is of the
- * scattered_relocation_info_t kind and not macho_relocation_info_t. */
-#define R_SCATTERED     KU32_C(0x80000000)
-
-/**
- * Scattered relocation.
- *
- * This is a hack mainly for RISC machines which restricts section size
- * to 16MB among other things.
- *
- * The reason for the big/little endian differences here is of course because
- * of the R_SCATTERED mask and the way bitfields are implemented by the
- * C/C++ compilers.
- */
-typedef struct scattered_relocation_info
-{
-#ifdef KLDR_LITTLE_ENDIAN
-    KU32        r_address : 24,     /**< Section relative address of the fixup. (macho_relocation_info_t::r_address) */
-                r_type : 4,         /**< Relocation type; 0 is standard, non-zero are machine specific. (macho_relocation_info_t::r_type) */
-                r_length : 2,       /**< Fixup length: 0=KU8, 1=KU16, 2=KU32, 3=KU64. (macho_relocation_info_t::r_length) */
-                r_pcrel : 1,        /**< PC (program counter) relative fixup; subtract the fixup address. (macho_relocation_info_t::r_pcrel) */
-                r_scattered : 1;    /**< Set if scattered relocation, clear if normal relocation. */
-#elif defined(KLDR_BIG_ENDIAN)
-    KU32        r_scattered : 1,    /**< Set if scattered relocation, clear if normal relocation. */
-                r_pcrel : 1,        /**< PC (program counter) relative fixup; subtract the fixup address. (macho_relocation_info_t::r_pcrel) */
-                r_length : 2,       /**< Fixup length: 0=KU8, 1=KU16, 2=KU32, 3=KU64. (macho_relocation_info_t::r_length) */
-                r_type : 4,         /**< Relocation type; 0 is standard, non-zero are machine specific. (macho_relocation_info_t::r_type) */
-                r_address : 24;     /**< Section relative address of the fixup. (macho_relocation_info_t::r_address) */
-#else
-# error "Neither KLDR_LITTLE_ENDIAN nor KLDR_BIG_ENDIAN is defined!"
-#endif
-    KI32        r_value;            /**< The value the fixup is refering to (without offset added). */
-} scattered_relocation_info_t;
-
-/**
- * Relocation type values for a generic implementation (for r_type).
- */
-typedef enum reloc_type_generic
-{
-    GENERIC_RELOC_VANILLA = 0,      /**< Standard relocation. */
-    GENERIC_RELOC_PAIR,             /**< Follows GENERIC_RELOC_SECTDIFF. */
-    GENERIC_RELOC_SECTDIFF,         /**< ??? */
-    GENERIC_RELOC_PB_LA_PTR,        /**< Prebound lazy pointer whatever that. */
-    GENERIC_RELOC_LOCAL_SECTDIFF    /**< ??? */
-} reloc_type_generic_t;
-
-/** @} */
-
-
-/** @} */
-#endif
-
Index: /trunk/kStuff/kLdr/kLdrModPE.c
===================================================================
--- /trunk/kStuff/kLdr/kLdrModPE.c	(revision 3567)
+++ /trunk/kStuff/kLdr/kLdrModPE.c	(revision 3568)
@@ -32,5 +32,5 @@
 #include "kLdrHlp.h"
 #include "kLdrInternal.h"
-#include "kLdrModPE.h"
+#include <k/kLdrFmts/pe.h>
 
 
Index: unk/kStuff/kLdr/kLdrModPE.h
===================================================================
--- /trunk/kStuff/kLdr/kLdrModPE.h	(revision 3567)
+++ 	(revision )
@@ -1,477 +1,0 @@
-/* $Id$ */
-
-#ifndef __kLdrModPE_h__
-#define __kLdrModPE_h__
-
-
-/*******************************************************************************
-*   Header Files                                                               *
-*******************************************************************************/
-#include "kLdrBase.h"
-
-
-/*******************************************************************************
-*   Defined Constants And Macros                                               *
-*******************************************************************************/
-#ifndef IMAGE_NT_SIGNATURE
-# define  IMAGE_NT_SIGNATURE KLDR_LE2H_U32('P' | ('E' << 8))
-#endif
-
-/* file header */
-#define  IMAGE_FILE_MACHINE_I386  0x014c
-#define  IMAGE_FILE_MACHINE_AMD64  0x8664
-
-#define  IMAGE_FILE_RELOCS_STRIPPED  0x0001
-#define  IMAGE_FILE_EXECUTABLE_IMAGE  0x0002
-#define  IMAGE_FILE_LINE_NUMS_STRIPPED  0x0004
-#define  IMAGE_FILE_LOCAL_SYMS_STRIPPED  0x0008
-#define  IMAGE_FILE_AGGRESIVE_WS_TRIM  0x0010
-#define  IMAGE_FILE_LARGE_ADDRESS_AWARE  0x0020
-#define  IMAGE_FILE_16BIT_MACHINE  0x0040
-#define  IMAGE_FILE_BYTES_REVERSED_LO  0x0080
-#define  IMAGE_FILE_32BIT_MACHINE  0x0100
-#define  IMAGE_FILE_DEBUG_STRIPPED  0x0200
-#define  IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP  0x0400
-#define  IMAGE_FILE_NET_RUN_FROM_SWAP  0x0800
-#define  IMAGE_FILE_SYSTEM  0x1000
-#define  IMAGE_FILE_DLL  0x2000
-#define  IMAGE_FILE_UP_SYSTEM_ONLY  0x4000
-#define  IMAGE_FILE_BYTES_REVERSED_HI  0x8000
-
-
-/* optional header */
-#define  IMAGE_NT_OPTIONAL_HDR32_MAGIC  0x10B
-#define  IMAGE_NT_OPTIONAL_HDR64_MAGIC  0x20B
-
-#define  IMAGE_SUBSYSTEM_UNKNOWN  0x0
-#define  IMAGE_SUBSYSTEM_NATIVE  0x1
-#define  IMAGE_SUBSYSTEM_WINDOWS_GUI  0x2
-#define  IMAGE_SUBSYSTEM_WINDOWS_CUI  0x3
-#define  IMAGE_SUBSYSTEM_OS2_GUI  0x4
-#define  IMAGE_SUBSYSTEM_OS2_CUI  0x5
-#define  IMAGE_SUBSYSTEM_POSIX_CUI  0x7
-
-#define  IMAGE_LIBRARY_PROCESS_INIT  0x0001
-#define  IMAGE_LIBRARY_PROCESS_TERM  0x0002
-#define  IMAGE_LIBRARY_THREAD_INIT  0x0004
-#define  IMAGE_LIBRARY_THREAD_TERM  0x0008
-#define  IMAGE_DLLCHARACTERISTICS_NO_ISOLATION  0x0200
-#define  IMAGE_DLLCHARACTERISTICS_NO_SEH  0x0400
-#define  IMAGE_DLLCHARACTERISTICS_NO_BIND  0x0800
-#define  IMAGE_DLLCHARACTERISTICS_WDM_DRIVER  0x2000
-#define  IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE  0x8000
-
-#define  IMAGE_NUMBEROF_DIRECTORY_ENTRIES  0x10
-
-#define  IMAGE_DIRECTORY_ENTRY_EXPORT  0x0
-#define  IMAGE_DIRECTORY_ENTRY_IMPORT  0x1
-#define  IMAGE_DIRECTORY_ENTRY_RESOURCE  0x2
-#define  IMAGE_DIRECTORY_ENTRY_EXCEPTION  0x3
-#define  IMAGE_DIRECTORY_ENTRY_SECURITY  0x4
-#define  IMAGE_DIRECTORY_ENTRY_BASERELOC  0x5
-#define  IMAGE_DIRECTORY_ENTRY_DEBUG  0x6
-#define  IMAGE_DIRECTORY_ENTRY_ARCHITECTURE  0x7
-#define  IMAGE_DIRECTORY_ENTRY_COPYRIGHT IMAGE_DIRECTORY_ENTRY_ARCHITECTURE
-#define  IMAGE_DIRECTORY_ENTRY_GLOBALPTR  0x8
-#define  IMAGE_DIRECTORY_ENTRY_TLS  0x9
-#define  IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG  0xa
-#define  IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT  0xb
-#define  IMAGE_DIRECTORY_ENTRY_IAT  0xc
-#define  IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT  0xd
-#define  IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR  0xe
-
-
-/* section header */
-#define  IMAGE_SIZEOF_SHORT_NAME  0x8
-
-#define  IMAGE_SCN_TYPE_REG  0x00000000
-#define  IMAGE_SCN_TYPE_DSECT  0x00000001
-#define  IMAGE_SCN_TYPE_NOLOAD  0x00000002
-#define  IMAGE_SCN_TYPE_GROUP  0x00000004
-#define  IMAGE_SCN_TYPE_NO_PAD  0x00000008
-#define  IMAGE_SCN_TYPE_COPY  0x00000010
-
-#define  IMAGE_SCN_CNT_CODE  0x00000020
-#define  IMAGE_SCN_CNT_INITIALIZED_DATA  0x00000040
-#define  IMAGE_SCN_CNT_UNINITIALIZED_DATA  0x00000080
-
-#define  IMAGE_SCN_LNK_OTHER  0x00000100
-#define  IMAGE_SCN_LNK_INFO  0x00000200
-#define  IMAGE_SCN_TYPE_OVER  0x00000400
-#define  IMAGE_SCN_LNK_REMOVE  0x00000800
-#define  IMAGE_SCN_LNK_COMDAT  0x00001000
-#define  IMAGE_SCN_MEM_PROTECTED  0x00004000
-#define  IMAGE_SCN_NO_DEFER_SPEC_EXC  0x00004000
-#define  IMAGE_SCN_GPREL  0x00008000
-#define  IMAGE_SCN_MEM_FARDATA  0x00008000
-#define  IMAGE_SCN_MEM_SYSHEAP  0x00010000
-#define  IMAGE_SCN_MEM_PURGEABLE  0x00020000
-#define  IMAGE_SCN_MEM_16BIT  0x00020000
-#define  IMAGE_SCN_MEM_LOCKED  0x00040000
-#define  IMAGE_SCN_MEM_PRELOAD  0x00080000
-
-#define  IMAGE_SCN_ALIGN_1BYTES  0x00100000
-#define  IMAGE_SCN_ALIGN_2BYTES  0x00200000
-#define  IMAGE_SCN_ALIGN_4BYTES  0x00300000
-#define  IMAGE_SCN_ALIGN_8BYTES  0x00400000
-#define  IMAGE_SCN_ALIGN_16BYTES  0x00500000
-#define  IMAGE_SCN_ALIGN_32BYTES  0x00600000
-#define  IMAGE_SCN_ALIGN_64BYTES  0x00700000
-#define  IMAGE_SCN_ALIGN_128BYTES  0x00800000
-#define  IMAGE_SCN_ALIGN_256BYTES  0x00900000
-#define  IMAGE_SCN_ALIGN_512BYTES  0x00A00000
-#define  IMAGE_SCN_ALIGN_1024BYTES  0x00B00000
-#define  IMAGE_SCN_ALIGN_2048BYTES  0x00C00000
-#define  IMAGE_SCN_ALIGN_4096BYTES  0x00D00000
-#define  IMAGE_SCN_ALIGN_8192BYTES  0x00E00000
-#define  IMAGE_SCN_ALIGN_MASK  0x00F00000
-
-#define  IMAGE_SCN_LNK_NRELOC_OVFL  0x01000000
-#define  IMAGE_SCN_MEM_DISCARDABLE  0x02000000
-#define  IMAGE_SCN_MEM_NOT_CACHED  0x04000000
-#define  IMAGE_SCN_MEM_NOT_PAGED  0x08000000
-#define  IMAGE_SCN_MEM_SHARED  0x10000000
-#define  IMAGE_SCN_MEM_EXECUTE  0x20000000
-#define  IMAGE_SCN_MEM_READ  0x40000000
-#define  IMAGE_SCN_MEM_WRITE  0x80000000
-
-
-/* relocations */
-#define  IMAGE_REL_BASED_ABSOLUTE  0x0
-#define  IMAGE_REL_BASED_HIGH  0x1
-#define  IMAGE_REL_BASED_LOW  0x2
-#define  IMAGE_REL_BASED_HIGHLOW  0x3
-#define  IMAGE_REL_BASED_HIGHADJ  0x4
-#define  IMAGE_REL_BASED_MIPS_JMPADDR  0x5
-#define  IMAGE_REL_BASED_SECTION  0x6
-#define  IMAGE_REL_BASED_REL32  0x7
-/*#define  IMAGE_REL_BASED_RESERVED1 0x8 */
-#define  IMAGE_REL_BASED_MIPS_JMPADDR16 0x9
-#define  IMAGE_REL_BASED_IA64_IMM64  0x9
-#define  IMAGE_REL_BASED_DIR64  0xa
-#define  IMAGE_REL_BASED_HIGH3ADJ 0xb
-
-/* imports */
-#define  IMAGE_ORDINAL_FLAG32  0x80000000
-#define  IMAGE_ORDINAL32(ord)  ((ord) &  0xffff)
-#define  IMAGE_SNAP_BY_ORDINAL32(ord)  (!!((ord) & IMAGE_ORDINAL_FLAG32))
-
-#define  IMAGE_ORDINAL_FLAG64  0x8000000000000000ULL
-#define  IMAGE_ORDINAL64(ord)  ((ord) &  0xffff)
-#define  IMAGE_SNAP_BY_ORDINAL64(ord)  (!!((ord) & IMAGE_ORDINAL_FLAG64))
-
-
-/* dll/tls entry points argument */
-#define DLL_PROCESS_DETACH      0
-#define DLL_PROCESS_ATTACH      1
-#define DLL_THREAD_ATTACH       2
-#define DLL_THREAD_DETACH       3
-
-
-/*******************************************************************************
-*   Structures and Typedefs                                                    *
-*******************************************************************************/
-#pragma pack(4)
-
-typedef struct _IMAGE_FILE_HEADER
-{
-    KU16      Machine;
-    KU16      NumberOfSections;
-    KU32      TimeDateStamp;
-    KU32      PointerToSymbolTable;
-    KU32      NumberOfSymbols;
-    KU16      SizeOfOptionalHeader;
-    KU16      Characteristics;
-} IMAGE_FILE_HEADER;
-typedef IMAGE_FILE_HEADER *PIMAGE_FILE_HEADER;
-
-
-typedef struct _IMAGE_DATA_DIRECTORY
-{
-    KU32      VirtualAddress;
-    KU32      Size;
-} IMAGE_DATA_DIRECTORY;
-typedef IMAGE_DATA_DIRECTORY *PIMAGE_DATA_DIRECTORY;
-
-
-typedef struct _IMAGE_OPTIONAL_HEADER32
-{
-    KU16    Magic;
-    KU8     MajorLinkerVersion;
-    KU8     MinorLinkerVersion;
-    KU32    SizeOfCode;
-    KU32    SizeOfInitializedData;
-    KU32    SizeOfUninitializedData;
-    KU32    AddressOfEntryPoint;
-    KU32    BaseOfCode;
-    KU32    BaseOfData;
-    KU32    ImageBase;
-    KU32    SectionAlignment;
-    KU32    FileAlignment;
-    KU16    MajorOperatingSystemVersion;
-    KU16    MinorOperatingSystemVersion;
-    KU16    MajorImageVersion;
-    KU16    MinorImageVersion;
-    KU16    MajorSubsystemVersion;
-    KU16    MinorSubsystemVersion;
-    KU32    Win32VersionValue;
-    KU32    SizeOfImage;
-    KU32    SizeOfHeaders;
-    KU32    CheckSum;
-    KU16    Subsystem;
-    KU16    DllCharacteristics;
-    KU32    SizeOfStackReserve;
-    KU32    SizeOfStackCommit;
-    KU32    SizeOfHeapReserve;
-    KU32    SizeOfHeapCommit;
-    KU32    LoaderFlags;
-    KU32    NumberOfRvaAndSizes;
-    IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
-} IMAGE_OPTIONAL_HEADER32;
-typedef IMAGE_OPTIONAL_HEADER32 *PIMAGE_OPTIONAL_HEADER32;
-
-typedef struct _IMAGE_OPTIONAL_HEADER64
-{
-    KU16    Magic;
-    KU8     MajorLinkerVersion;
-    KU8     MinorLinkerVersion;
-    KU32    SizeOfCode;
-    KU32    SizeOfInitializedData;
-    KU32    SizeOfUninitializedData;
-    KU32    AddressOfEntryPoint;
-    KU32    BaseOfCode;
-    KU64    ImageBase;
-    KU32    SectionAlignment;
-    KU32    FileAlignment;
-    KU16    MajorOperatingSystemVersion;
-    KU16    MinorOperatingSystemVersion;
-    KU16    MajorImageVersion;
-    KU16    MinorImageVersion;
-    KU16    MajorSubsystemVersion;
-    KU16    MinorSubsystemVersion;
-    KU32    Win32VersionValue;
-    KU32    SizeOfImage;
-    KU32    SizeOfHeaders;
-    KU32    CheckSum;
-    KU16    Subsystem;
-    KU16    DllCharacteristics;
-    KU64    SizeOfStackReserve;
-    KU64    SizeOfStackCommit;
-    KU64    SizeOfHeapReserve;
-    KU64    SizeOfHeapCommit;
-    KU32    LoaderFlags;
-    KU32    NumberOfRvaAndSizes;
-    IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
-} IMAGE_OPTIONAL_HEADER64;
-typedef IMAGE_OPTIONAL_HEADER64 *PIMAGE_OPTIONAL_HEADER64;
-
-
-typedef struct _IMAGE_NT_HEADERS
-{
-    KU32 Signature;
-    IMAGE_FILE_HEADER FileHeader;
-    IMAGE_OPTIONAL_HEADER32 OptionalHeader;
-} IMAGE_NT_HEADERS32;
-typedef IMAGE_NT_HEADERS32 *PIMAGE_NT_HEADERS32;
-
-typedef struct _IMAGE_NT_HEADERS64
-{
-    KU32 Signature;
-    IMAGE_FILE_HEADER FileHeader;
-    IMAGE_OPTIONAL_HEADER64 OptionalHeader;
-} IMAGE_NT_HEADERS64;
-typedef IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64;
-
-
-typedef struct _IMAGE_SECTION_HEADER
-{
-    KU8      Name[IMAGE_SIZEOF_SHORT_NAME];
-    union
-    {
-        KU32      PhysicalAddress;
-        KU32      VirtualSize;
-    } Misc;
-    KU32      VirtualAddress;
-    KU32      SizeOfRawData;
-    KU32      PointerToRawData;
-    KU32      PointerToRelocations;
-    KU32      PointerToLinenumbers;
-    KU16      NumberOfRelocations;
-    KU16      NumberOfLinenumbers;
-    KU32      Characteristics;
-} IMAGE_SECTION_HEADER;
-typedef IMAGE_SECTION_HEADER *PIMAGE_SECTION_HEADER;
-
-
-typedef struct _IMAGE_BASE_RELOCATION
-{
-    KU32      VirtualAddress;
-    KU32      SizeOfBlock;
-} IMAGE_BASE_RELOCATION;
-typedef IMAGE_BASE_RELOCATION *PIMAGE_BASE_RELOCATION;
-
-
-typedef struct _IMAGE_EXPORT_DIRECTORY
-{
-    KU32      Characteristics;
-    KU32      TimeDateStamp;
-    KU16      MajorVersion;
-    KU16      MinorVersion;
-    KU32      Name;
-    KU32      Base;
-    KU32      NumberOfFunctions;
-    KU32      NumberOfNames;
-    KU32      AddressOfFunctions;
-    KU32      AddressOfNames;
-    KU32      AddressOfNameOrdinals;
-} IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY;
-
-
-typedef struct _IMAGE_IMPORT_DESCRIPTOR
-{
-    union
-    {
-        KU32      Characteristics;
-        KU32      OriginalFirstThunk;
-    } u;
-    KU32      TimeDateStamp;
-    KU32      ForwarderChain;
-    KU32      Name;
-    KU32      FirstThunk;
-} IMAGE_IMPORT_DESCRIPTOR;
-typedef IMAGE_IMPORT_DESCRIPTOR *PIMAGE_IMPORT_DESCRIPTOR;
-
-
-typedef struct _IMAGE_IMPORT_BY_NAME
-{
-    KU16      Hint;
-    KU8      Name[1];
-} IMAGE_IMPORT_BY_NAME;
-typedef IMAGE_IMPORT_BY_NAME *PIMAGE_IMPORT_BY_NAME;
-
-
-/* The image_thunk_data32/64 structures are not very helpful except for getting RSI. keep them around till all the code has been converted. */
-typedef struct _IMAGE_THUNK_DATA64
-{
-    union
-    {
-        KU64      ForwarderString;
-        KU64      Function;
-        KU64      Ordinal;
-        KU64      AddressOfData;
-    } u1;
-} IMAGE_THUNK_DATA64;
-typedef IMAGE_THUNK_DATA64 *PIMAGE_THUNK_DATA64;
-
-typedef struct _IMAGE_THUNK_DATA32
-{
-    union
-    {
-        KU32      ForwarderString;
-        KU32      Function;
-        KU32      Ordinal;
-        KU32      AddressOfData;
-    } u1;
-} IMAGE_THUNK_DATA32;
-typedef IMAGE_THUNK_DATA32 *PIMAGE_THUNK_DATA32;
-
-
-typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32
-{
-    KU32      Size;
-    KU32      TimeDateStamp;
-    KU16      MajorVersion;
-    KU16      MinorVersion;
-    KU32      GlobalFlagsClear;
-    KU32      GlobalFlagsSet;
-    KU32      CriticalSectionDefaultTimeout;
-    KU32      DeCommitFreeBlockThreshold;
-    KU32      DeCommitTotalFreeThreshold;
-    KU32      LockPrefixTable;
-    KU32      MaximumAllocationSize;
-    KU32      VirtualMemoryThreshold;
-    KU32      ProcessHeapFlags;
-    KU32      ProcessAffinityMask;
-    KU16      CSDVersion;
-    KU16      Reserved1;
-    KU32      EditList;
-    KU32      SecurityCookie;
-    KU32      SEHandlerTable;
-    KU32      SEHandlerCount;
-} IMAGE_LOAD_CONFIG_DIRECTORY32;
-typedef IMAGE_LOAD_CONFIG_DIRECTORY32 PIMAGE_LOAD_CONFIG_DIRECTORY32;
-
-typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64
-{
-    KU32      Size;
-    KU32      TimeDateStamp;
-    KU16      MajorVersion;
-    KU16      MinorVersion;
-    KU32      GlobalFlagsClear;
-    KU32      GlobalFlagsSet;
-    KU32      CriticalSectionDefaultTimeout;
-    KU64      DeCommitFreeBlockThreshold;
-    KU64      DeCommitTotalFreeThreshold;
-    KU64      LockPrefixTable;
-    KU64      MaximumAllocationSize;
-    KU64      VirtualMemoryThreshold;
-    KU64      ProcessAffinityMask;
-    KU32      ProcessHeapFlags;
-    KU16      CSDVersion;
-    KU16      Reserved1;
-    KU64      EditList;
-    KU64      SecurityCookie;
-    KU64      SEHandlerTable;
-    KU64      SEHandlerCount;
-} IMAGE_LOAD_CONFIG_DIRECTORY64;
-typedef IMAGE_LOAD_CONFIG_DIRECTORY64 *PIMAGE_LOAD_CONFIG_DIRECTORY64;
-
-typedef struct _IMAGE_DEBUG_DIRECTORY
-{
-    KU32      Characteristics;
-	KU32  TimeDateStamp;
-    KU16      MajorVersion;
-    KU16      MinorVersion;
-    KU32      Type;
-    KU32      SizeOfData;
-    KU32      AddressOfRawData;
-    KU32      PointerToRawData;
-} IMAGE_DEBUG_DIRECTORY;
-typedef IMAGE_DEBUG_DIRECTORY *PIMAGE_DEBUG_DIRECTORY;
-
-#define IMAGE_DEBUG_TYPE_UNKNOWN  0
-#define IMAGE_DEBUG_TYPE_COFF 1
-#define IMAGE_DEBUG_TYPE_CODEVIEW 2 /* 4.0 */
-#define IMAGE_DEBUG_TYPE_FPO 3 /* FPO = frame pointer omission */
-#define IMAGE_DEBUG_TYPE_MISC 4
-#define IMAGE_DEBUG_TYPE_EXCEPTION 5
-#define IMAGE_DEBUG_TYPE_FIXUP 6
-#define IMAGE_DEBUG_TYPE_BORLAND 9
-
-typedef struct _IMAGE_TLS_DIRECTORY32
-{
-    KU32      StartAddressOfRawData;
-    KU32      EndAddressOfRawData;
-    KU32      AddressOfIndex;
-    KU32      AddressOfCallBacks;
-    KU32      SizeOfZeroFill;
-    KU32      Characteristics;
-} IMAGE_TLS_DIRECTORY32;
-typedef IMAGE_TLS_DIRECTORY32 *PIMAGE_TLS_DIRECTORY32;
-
-typedef struct _IMAGE_TLS_DIRECTORY64
-{
-    KU64      StartAddressOfRawData;
-    KU64      EndAddressOfRawData;
-    KU64      AddressOfIndex;
-    KU64      AddressOfCallBacks;
-    KU32      SizeOfZeroFill;
-    KU32      Characteristics;
-} IMAGE_TLS_DIRECTORY64;
-typedef IMAGE_TLS_DIRECTORY64 *PIMAGE_TLS_DIRECTORY64;
-
-
-#pragma pack()
-
-#endif
-
