mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-31 19:26:42 +00:00
- PSEH changes imported in the main tree
- initial (dead, disabled) import of ELF support svn path=/trunk/; revision=12398
This commit is contained in:
+12
-480
@@ -1,488 +1,20 @@
|
||||
#ifndef __INCLUDE_ELF_H
|
||||
#define __INCLUDE_ELF_H
|
||||
#ifndef _REACTOS_ELF_H_
|
||||
#define _REACTOS_ELF_H_ 1
|
||||
|
||||
|
||||
#ifdef __64BITS__ /* FIXME: how to check for 64 bits? */
|
||||
# define ELF_ARCH_SIZE 64
|
||||
#else
|
||||
# define ELF_ARCH_SIZE 32
|
||||
#endif
|
||||
|
||||
|
||||
/* 32-bit data types */
|
||||
typedef unsigned long ELF32_ADDR; /* Unsigned program address */
|
||||
typedef unsigned short ELF32_HALF; /* Unsigned medium integer */
|
||||
typedef unsigned long ELF32_OFF; /* Unsigned file offset */
|
||||
typedef unsigned long ELF32_SWORD; /* Signed large integer */
|
||||
typedef unsigned long ELF32_WORD; /* Unsigned large integer */
|
||||
typedef ELF32_OFF ELF32_HASHELT; /* Hash element? */
|
||||
|
||||
/* Elf data encodings */
|
||||
#define IMAGE_ELF_DATA_NONE 0 /* Invalid data encoding */
|
||||
#define IMAGE_ELF_DATA_2LSB 1 /* 2's complement, LSB first */
|
||||
#define IMAGE_ELF_DATA_2MSB 2 /* 2's complement, MSB first */
|
||||
|
||||
/* Elf object file types */
|
||||
#define IMAGE_ELF_TYPE_NONE 0 /* No file type */
|
||||
#define IMAGE_ELF_TYPE_REL 1 /* Relocatable file */
|
||||
#define IMAGE_ELF_TYPE_EXEC 2 /* Executable file */
|
||||
#define IMAGE_ELF_TYPE_DYN 3 /* Shared object file */
|
||||
#define IMAGE_ELF_TYPE_CORE 4 /* Core file */
|
||||
|
||||
/* Elf machines */
|
||||
#define IMAGE_ELF_MACHINE_NONE 0 /* No machine */
|
||||
#define IMAGE_ELF_MACHINE_M32 1 /* AT&T WE 32100 */
|
||||
#define IMAGE_ELF_MACHINE_SPARC 2 /* SPARC */
|
||||
#define IMAGE_ELF_MACHINE_386 3 /* Intel 80386 */
|
||||
#define IMAGE_ELF_MACHINE_68K 4 /* Motorola 68000 */
|
||||
#define IMAGE_ELF_MACHINE_88K 5 /* Motorola 88000 */
|
||||
/* 6 is reserved */
|
||||
#define IMAGE_ELF_MACHINE_860 7 /* Intel 80860 */
|
||||
#define IMAGE_ELF_MACHINE_MIPS 8 /* MIPS RS3000 (MIPS I) */
|
||||
#define IMAGE_ELF_MACHINE_S370 9 /* IBM System/370 Processor */
|
||||
#define IMAGE_ELF_MACHINE_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */
|
||||
/* 11-14 are reserved */
|
||||
#define IMAGE_ELF_MACHINE_PARISC 15 /* Hewlett-Packard PA-RISC */
|
||||
/* 16 is reserved */
|
||||
#define IMAGE_ELF_MACHINE_VPP500 17 /* Fujitsu VPP500 */
|
||||
#define IMAGE_ELF_MACHINE_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
|
||||
#define IMAGE_ELF_MACHINE_960 19 /* Intel 80960 */
|
||||
#define IMAGE_ELF_MACHINE_PPC 20 /* PowerPC */
|
||||
#define IMAGE_ELF_MACHINE_PPC64 21 /* 64-bit PowerPC */
|
||||
/* 22-35 are reserved */
|
||||
#define IMAGE_ELF_MACHINE_V800 36 /* NEC V800 */
|
||||
#define IMAGE_ELF_MACHINE_FR20 37 /* Fujitsu FR20 */
|
||||
#define IMAGE_ELF_MACHINE_RH32 38 /* TRW RH-32 */
|
||||
#define IMAGE_ELF_MACHINE_RCE 39 /* Motorola RCE */
|
||||
#define IMAGE_ELF_MACHINE_ARM 40 /* Advanced RISC Machines ARM */
|
||||
#define IMAGE_ELF_MACHINE_ALPHA 41 /* Digital Alpha */
|
||||
#define IMAGE_ELF_MACHINE_SH 42 /* Hitachi SH */
|
||||
#define IMAGE_ELF_MACHINE_SPARCV9 43 /* SPARC Version 9 */
|
||||
#define IMAGE_ELF_MACHINE_TRICORE 44 /* Siemens Tricore embedded processor */
|
||||
#define IMAGE_ELF_MACHINE_ARC 45 /* Argonaut RISC Core, Argonaut Technologies Inc. */
|
||||
#define IMAGE_ELF_MACHINE_H8_300 46 /* Hitachi H8/300 */
|
||||
#define IMAGE_ELF_MACHINE_H8_300H 47 /* Hitachi H8/300H */
|
||||
#define IMAGE_ELF_MACHINE_H8S 48 /* Hitachi H8S */
|
||||
#define IMAGE_ELF_MACHINE_H8_500 49 /* Hitachi H8/500 */
|
||||
#define IMAGE_ELF_MACHINE_IA_64 50 /* Intel IA-64 processor architecture */
|
||||
#define IMAGE_ELF_MACHINE_MIPS_X 51 /* Stanford MIPS-X */
|
||||
#define IMAGE_ELF_MACHINE_COLDFIRE 52 /* Motorola ColdFire */
|
||||
#define IMAGE_ELF_MACHINE_68HC12 53 /* Motorola M68HC12 */
|
||||
#define IMAGE_ELF_MACHINE_MMA 54 /* Fujitsu MMA Multimedia Accelerator */
|
||||
#define IMAGE_ELF_MACHINE_PCP 55 /* Siemens PCP */
|
||||
#define IMAGE_ELF_MACHINE_NCPU 56 /* Sony nCPU embedded RISC processor */
|
||||
#define IMAGE_ELF_MACHINE_NDR1 57 /* Denso NDR1 microprocessor */
|
||||
#define IMAGE_ELF_MACHINE_STARCORE 58 /* Motorola Star*Core processor */
|
||||
#define IMAGE_ELF_MACHINE_ME16 59 /* Toyota ME16 processor */
|
||||
#define IMAGE_ELF_MACHINE_ST100 60 /* STMicroelectronics ST100 processor */
|
||||
#define IMAGE_ELF_MACHINE_TINYJ 61 /* Advanced Logic Corp. TinyJ embedded processor family */
|
||||
/* 62-65 are reserved */
|
||||
#define IMAGE_ELF_MACHINE_FX66 66 /* Siemens FX66 microcontroller */
|
||||
#define IMAGE_ELF_MACHINE_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 bit microcontroller */
|
||||
#define IMAGE_ELF_MACHINE_ST7 68 /* STMicroelectronics ST7 8-bit microcontroller */
|
||||
#define IMAGE_ELF_MACHINE_68HC16 69 /* Motorola MC68HC16 Microcontroller */
|
||||
#define IMAGE_ELF_MACHINE_68HC11 70 /* Motorola MC68HC11 Microcontroller */
|
||||
#define IMAGE_ELF_MACHINE_68HC08 71 /* Motorola MC68HC08 Microcontroller */
|
||||
#define IMAGE_ELF_MACHINE_68HC05 72 /* Motorola MC68HC05 Microcontroller */
|
||||
#define IMAGE_ELF_MACHINE_SVX 73 /* Silicon Graphics SVx */
|
||||
#define IMAGE_ELF_MACHINE_ST19 74 /* STMicroelectronics ST19 8-bit microcontroller */
|
||||
#define IMAGE_ELF_MACHINE_VAX 75 /* Digital VAX */
|
||||
#define IMAGE_ELF_MACHINE_CRIS 76 /* Axis Communications 32-bit embedded processor */
|
||||
#define IMAGE_ELF_MACHINE_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */
|
||||
#define IMAGE_ELF_MACHINE_FIREPATH 78 /* Element 14 64-bit DSP Processor */
|
||||
#define IMAGE_ELF_MACHINE_ZSP 79 /* LSI Logic 16-bit DSP Processor */
|
||||
#define IMAGE_ELF_MACHINE_MMIX 80 /* Donald Knuth's educational 64-bit processor */
|
||||
#define IMAGE_ELF_MACHINE_HUANY 81 /* Harvard University machine-independent object files */
|
||||
#define IMAGE_ELF_MACHINE_PRISM 82 /* SiTera Prism */
|
||||
#define IMAGE_ELF_MACHINE_AVR 83 /* Atmel AVR 8-bit microcontroller */
|
||||
#define IMAGE_ELF_MACHINE_FR30 84 /* Fujitsu FR30 */
|
||||
#define IMAGE_ELF_MACHINE_D10V 85 /* Mitsubishi D10V */
|
||||
#define IMAGE_ELF_MACHINE_D30V 86 /* Mitsubishi D30V */
|
||||
#define IMAGE_ELF_MACHINE_V850 87 /* NEC v850 */
|
||||
#define IMAGE_ELF_MACHINE_M32R 88 /* Mitsubishi M32R */
|
||||
#define IMAGE_ELF_MACHINE_MN10300 89 /* Matsushita MN10300 */
|
||||
#define IMAGE_ELF_MACHINE_MN10200 90 /* Matsushita MN10200 */
|
||||
#define IMAGE_ELF_MACHINE_PJ 91 /* picoJava */
|
||||
#define IMAGE_ELF_MACHINE_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
|
||||
|
||||
/* Elf versions */
|
||||
#define IMAGE_ELF_VERSION_NONE 0 /* Invalid version */
|
||||
#define IMAGE_ELF_VERSION_CURRENT 1 /* Current version */
|
||||
|
||||
/* Elf identification */
|
||||
#define IMAGE_ELF_SIZEOF_IDENT 16
|
||||
#define IMAGE_ELF_IDENT_MAGIC0 0 /* Magic */
|
||||
#define IMAGE_ELF_IDENT_MAGIC1 1
|
||||
#define IMAGE_ELF_IDENT_MAGIC2 2
|
||||
#define IMAGE_ELF_IDENT_MAGIC3 3
|
||||
#define IMAGE_ELF_IDENT_CLASS 4 /* File class */
|
||||
#define IMAGE_ELF_IDENT_DATA 5 /* Data encoding */
|
||||
#define IMAGE_ELF_IDENT_VERSION 6 /* File version */
|
||||
#define IMAGE_ELF_IDENT_OSABI 7 /* Operating system/ABI identification */
|
||||
#define IMAGE_ELF_IDENT_ABIVERSION 8 /* ABI version */
|
||||
#define IMAGE_ELF_IDENT_PAD 9 /* Start of padding bytes */
|
||||
|
||||
/* Magic numbers */
|
||||
#define IMAGE_ELF_MAGIC0 0x7f
|
||||
#define IMAGE_ELF_MAGIC1 'E'
|
||||
#define IMAGE_ELF_MAGIC2 'L'
|
||||
#define IMAGE_ELF_MAGIC3 'F'
|
||||
|
||||
/* Elf file classes */
|
||||
#define IMAGE_ELF_CLASS_NONE 0 /* Invalid class */
|
||||
#define IMAGE_ELF_CLASS_32 1 /* 32-bit object */
|
||||
#define IMAGE_ELF_CLASS_64 2 /* 64-bit object */
|
||||
|
||||
/* Check elf magic */
|
||||
#define IMAGE_IS_ELF(hdr) ((hdr).Ident[IMAGE_ELF_IDENT_MAGIC0] == IMAGE_ELF_MAGIC0 && \
|
||||
(hdr).Ident[IMAGE_ELF_IDENT_MAGIC1] == IMAGE_ELF_MAGIC1 && \
|
||||
(hdr).Ident[IMAGE_ELF_IDENT_MAGIC2] == IMAGE_ELF_MAGIC2 && \
|
||||
(hdr).Ident[IMAGE_ELF_IDENT_MAGIC3] == IMAGE_ELF_MAGIC3)
|
||||
|
||||
|
||||
|
||||
/* 32-bit Elf header */
|
||||
typedef struct _IMAGE_ELF32_HEADER {
|
||||
unsigned char Ident[IMAGE_ELF_SIZEOF_IDENT]; /* Identification */
|
||||
ELF32_HALF Type; /* Object file type */
|
||||
ELF32_HALF Machine; /* Required architecture */
|
||||
ELF32_WORD Version; /* Object file version */
|
||||
ELF32_ADDR Entry; /* Virtual address of entry point */
|
||||
ELF32_OFF PhOff; /* Program header table offset in file */
|
||||
ELF32_OFF ShOff; /* Section header offset in file */
|
||||
ELF32_WORD Flags; /* Processor specific flags - zero for SPARC and x86 */
|
||||
ELF32_HALF EhSize; /* Elf header size in bytes (this struct) */
|
||||
ELF32_HALF PhEntSize; /* Size of an entry in the program header table */
|
||||
ELF32_HALF PhNum; /* Number of entries in the program header table */
|
||||
ELF32_HALF ShEntSize; /* Size of an entry in the section header table */
|
||||
ELF32_HALF ShNum; /* Number of entries in the section header table */
|
||||
ELF32_HALF ShStrNdx; /* Index into the section header table for the entry of the section name string table */
|
||||
} IMAGE_ELF32_HEADER, *PIMAGE_ELF32_HEADER;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Special section indexes */
|
||||
#define IMAGE_ELF_SECTION_INDEX_UNDEF 0
|
||||
/*#define IMAGE_ELF_SECTION_INDEX_LORESERVE 0xff00
|
||||
#define IMAGE_ELF_SECTION_INDEX_LOPROC 0xff00
|
||||
#define IMAGE_ELF_SECTION_INDEX_HIPROC 0xff1f*/
|
||||
#define IMAGE_ELF_SECTION_INDEX_ABS 0xfff1
|
||||
#define IMAGE_ELF_SECTION_INDEX_COMMON 0xfff2
|
||||
/*#define IMAGE_ELF_SECTION_INDEX_HIRESERVE 0xffff*/
|
||||
|
||||
/* Section types */
|
||||
#define IMAGE_ELF_SECTION_TYPE_NULL 0 /* Incactive section header */
|
||||
#define IMAGE_ELF_SECTION_TYPE_PROGBITS 1 /* Program defined section */
|
||||
#define IMAGE_ELF_SECTION_TYPE_SYMTAB 2 /* Symbol table (for link editing) */
|
||||
#define IMAGE_ELF_SECTION_TYPE_STRTAB 3 /* String table */
|
||||
#define IMAGE_ELF_SECTION_TYPE_RELA 4 /* Relocation table (with explicit addends) */
|
||||
#define IMAGE_ELF_SECTION_TYPE_HASH 5 /* Symbol hash table */
|
||||
#define IMAGE_ELF_SECTION_TYPE_DYNAMIC 6 /* Information for dynamic linking */
|
||||
#define IMAGE_ELF_SECTION_TYPE_NOTE 7 /* Note section ;-) */
|
||||
#define IMAGE_ELF_SECTION_TYPE_NOBITS 8 /* Occupies no space in the file, otherwise like PROGBITS */
|
||||
#define IMAGE_ELF_SECTION_TYPE_REL 9 /* Relocation table (without explicit addends) */
|
||||
#define IMAGE_ELF_SECTION_TYPE_SHLIB 10 /* Reserved, unspecified */
|
||||
#define IMAGE_ELF_SECTION_TYPE_DYNSYM 11 /* Symbol table (for dynamic linking) */
|
||||
/*#define IMAGE_ELF_SECTION_TYPE_LOPROC 0x70000000
|
||||
#define IMAGE_ELF_SECTION_TYPE_HIPROC 0x7fffffff
|
||||
#define IMAGE_ELF_SECTION_TYPE_LOUSER 0x80000000
|
||||
#define IMAGE_ELF_SECTION_TYPE_HIUSER 0xffffffff*/
|
||||
|
||||
/* Section flags/attributes */
|
||||
#define SHF_WRITE 0x1 /* Section must be writeable */
|
||||
#define SHF_ALLOC 0x2 /* Section must be loaded/mapped into memory */
|
||||
#define SHF_EXECINSTR 0x4 /* The section contains executable code */
|
||||
/*#define SHF_MASKPROC 0xf0000000*/
|
||||
|
||||
/* 32-bit Section header entry */
|
||||
typedef struct _IMAGE_ELF32_SECTION_HEADER {
|
||||
ELF32_WORD Name; /* Name of the section (index into the section header string table) */
|
||||
ELF32_WORD Type; /* Type of section */
|
||||
ELF32_WORD Flags; /* Attributes */
|
||||
ELF32_ADDR Addr; /* Virtual address to load section at */
|
||||
ELF32_OFF Offset; /* Offset into the file of the section's data */
|
||||
ELF32_WORD Size; /* Size of the section */
|
||||
ELF32_WORD Link; /* Section header table index link... */
|
||||
ELF32_WORD Info; /* Extra information... */
|
||||
ELF32_WORD AddrAlign; /* Required alignment */
|
||||
ELF32_WORD EntSize; /* Size of entries in the table */
|
||||
} IMAGE_ELF32_SECTION_HEADER, *PIMAGE_ELF32_SECTION_HEADER;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Symbol table indexes */
|
||||
#define IMAGE_ELF_SYMBOL_INDEX_UNDEF 0 /* Undefined symbol */
|
||||
|
||||
/* Symbol binding/types */
|
||||
#define IMAGE_ELF32_SYMBOL_BIND(Info) ((Info) >> 4)
|
||||
#define IMAGE_ELF32_SYMBOL_TYPE(Info) ((Info) & 0x0f)
|
||||
#define IMAGE_ELF32_SYMBOL_INFO(Bind, Type) (((Bind) << 4) | ((Type) & 0x0f))
|
||||
|
||||
#define IMAGE_ELF_SYMBOL_BINDING_LOCAL 0 /* Local ("static") symbol */
|
||||
#define IMAGE_ELF_SYMBOL_BINDING_GLOBAL 1 /* Global symbol */
|
||||
#define IMAGE_ELF_SYMBOL_BINDING_WEAK 2 /* Weak symbol... */
|
||||
/*#define IMAGE_ELF_SYMBOL_BINDING_LOPROC 13
|
||||
#define IMAGE_ELF_SYMBOL_BINDING_HIPROC 15*/
|
||||
|
||||
#define IMAGE_ELF_SYMBOL_TYPE_NOTYPE 0 /* Unspecified symbol type */
|
||||
#define IMAGE_ELF_SYMBOL_TYPE_OBJECT 1 /* Data object (i.e. an array, variable, ...) */
|
||||
#define IMAGE_ELF_SYMBOL_TYPE_FUNC 2 /* Function (or other executable code) */
|
||||
#define IMAGE_ELF_SYMBOL_TYPE_SECTION 3 /* Symbol for relocating (usually has local binding) */
|
||||
#define IMAGE_ELF_SYMBOL_TYPE_FILE 4 /* Name of the associated source file */
|
||||
#define IMAGE_ELF_SYMBOL_TYPE_LOPROC 13
|
||||
#define IMAGE_ELF_SYMBOL_TYPE_HIPROC 15
|
||||
|
||||
/* 32-bit Symbol entry */
|
||||
typedef struct _IMAGE_ELF32_SYMBOL {
|
||||
ELF32_WORD Name; /* Symbol name (index into the symbol string table) */
|
||||
ELF32_ADDR Value; /* Value of symbol */
|
||||
ELF32_WORD Size; /* Size of symbol (0 means unknown) */
|
||||
unsigned char Info; /* Type and binding attributes */
|
||||
unsigned char Other; /* Unused - 0 */
|
||||
ELF32_HALF Shndx; /* Section index */
|
||||
} IMAGE_ELF32_SYMBOL, *PIMAGE_ELF32_SYMBOL;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Relocation macros */
|
||||
#define IMAGE_ELF32_RELOC_SYM(Info) ((Info) >> 8)
|
||||
#define IMAGE_ELF32_RELOC_TYPE(Info) ((unsigned char)(Info))
|
||||
#define IMAGE_ELF32_RELOC_INFO(Sym,Type) (((Sym) << 8) | (unsigned char)(Type))
|
||||
|
||||
/* 386 Relocation types */
|
||||
#define IMAGE_ELF_RELOC_386_NONE 0 /* none */
|
||||
#define IMAGE_ELF_RELOC_386_32 1
|
||||
#define IMAGE_ELF_RELOC_386_PC32 2
|
||||
#define IMAGE_ELF_RELOC_386_GOT32 3
|
||||
#define IMAGE_ELF_RELOC_386_PLT32 4
|
||||
#define IMAGE_ELF_RELOC_386_COPY 5
|
||||
#define IMAGE_ELF_RELOC_386_GLOB_DAT 6
|
||||
#define IMAGE_ELF_RELOC_386_JMP_SLOT 7
|
||||
#define IMAGE_ELF_RELOC_386_RELATIVE 8
|
||||
#define IMAGE_ELF_RELOC_386_GOTOFF 9
|
||||
#define IMAGE_ELF_RELOC_386_GOTPC 10
|
||||
|
||||
/* 386 TLS Relocation types */
|
||||
#define IMAGE_ELF_RELOC_386_TLS_GD_PLT 12
|
||||
#define IMAGE_ELF_RELOC_386_TLS_LDM_PLT 13
|
||||
#define IMAGE_ELF_RELOC_386_TLS_TPOFF 14
|
||||
#define IMAGE_ELF_RELOC_386_TLS_IE 15
|
||||
#define IMAGE_ELF_RELOC_386_TLS_GOTIE 16
|
||||
#define IMAGE_ELF_RELOC_386_TLS_LE 17
|
||||
#define IMAGE_ELF_RELOC_386_TLS_GD 18
|
||||
#define IMAGE_ELF_RELOC_386_TLS_LDM 19
|
||||
#define IMAGE_ELF_RELOC_386_TLS_LDO_32 32
|
||||
#define IMAGE_ELF_RELOC_386_TLS_DTPMOD32 35
|
||||
#define IMAGE_ELF_RELOC_386_TLS_DTPOFF32 36
|
||||
|
||||
/* 32-bit Relocation entries */
|
||||
typedef struct _IMAGE_ELF32_RELOC {
|
||||
ELF32_ADDR Offset; /* Section offset/virtual address */
|
||||
ELF32_WORD Info; /* Symbol table index/relocation type */
|
||||
} IMAGE_ELF32_RELOC, *PIMAGE_ELF32_RELOC;
|
||||
|
||||
typedef struct _IMAGE_ELF32_RELOCA {
|
||||
ELF32_ADDR Offset; /* Section offset/virtual address */
|
||||
ELF32_WORD Info; /* Symbol table index/relocation type */
|
||||
ELF32_SWORD Addend; /* Addend */
|
||||
} IMAGE_ELF32_RELOCA, *PIMAGE_ELF32_RELOCA;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Program header/segment types */
|
||||
#define IMAGE_ELF_SEGMENT_TYPE_NULL 0 /* Unused array entry */
|
||||
#define IMAGE_ELF_SEGMENT_TYPE_LOAD 1 /* Loadable segment */
|
||||
#define IMAGE_ELF_SEGMENT_TYPE_DYNAMIC 2 /* Dynamic linking info... */
|
||||
#define IMAGE_ELF_SEGMENT_TYPE_INTERP 3 /* Interpreter */
|
||||
#define IMAGE_ELF_SEGMENT_TYPE_NOTE 4 /* Note... */
|
||||
#define IMAGE_ELF_SEGMENT_TYPE_SHLIB 5 /* Reserved but unspecified */
|
||||
#define IMAGE_ELF_SEGMENT_TYPE_PHDR 6 /* Program header table */
|
||||
#define IMAGE_ELF_SEGMENT_TYPE_TLS 7 /* Thread local storage */
|
||||
|
||||
#define IMAGE_ELF_SEGMENT_TYPE_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */
|
||||
#define IMAGE_ELF_SEGMENT_TYPE_GNU_STACK 0x6474e551 /* Indicates stack executability */
|
||||
/*#define IMAGE_ELF_SEGMENT_TYPE_LOPROC 0x70000000
|
||||
#define IMAGE_ELF_SEGMENT_TYPE_HIPROC 0x7fffffff*/
|
||||
|
||||
/* Program header/segment flags */
|
||||
#define IMAGE_ELF_SEGMENT_FLAG_EXEC 0x01
|
||||
#define IMAGE_ELF_SEGMENT_FLAG_WRITE 0x02
|
||||
#define IMAGE_ELF_SEGMENT_FLAG_READ 0x04
|
||||
/*#define IMAGE_ELF_SEGMENT_FLAG_MASKPROC 0xf0000000*/
|
||||
|
||||
/* 32-bit Program header entry */
|
||||
typedef struct _IMAGE_ELF32_PROGRAM_HEADER {
|
||||
ELF32_WORD Type; /* Type of segment */
|
||||
ELF32_OFF Offset; /* File offset of segment data */
|
||||
ELF32_ADDR VAddr; /* Virtual address to load segment at */
|
||||
ELF32_ADDR PAddr; /* Physical address to load segment at */
|
||||
ELF32_WORD FileSz; /* Size in file of segment */
|
||||
ELF32_WORD MemSz; /* Size in memory of segment */
|
||||
ELF32_WORD Flags; /* Flags of segment */
|
||||
ELF32_WORD Align; /* Required alignment */
|
||||
} IMAGE_ELF32_PROGRAM_HEADER, *PIMAGE_ELF32_PROGRAM_HEADER;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Dynamic array tags */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_NULL 0 /* End of array */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_NEEDED 1 /* Dependency */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_PLTRELSZ 2 /* Size in bytes of the relocation entries associated with the plt */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_PLTGOT 3 /* Address associated with got/plt */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_HASH 4 /* Hash table for symbol table indicated by SYMTAB */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_STRTAB 5 /* Address of string table */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_SYMTAB 6 /* Address of the symbol table */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_RELA 7 /* Address of reloc table with addends */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_RELASZ 8 /* Size of reloc table in bytes */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_RELAENT 9 /* Size of reloc table entry in bytes? */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_STRSZ 10 /* Size of the string table in bytes */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_SYMENT 11 /* Size of symbol table entry in bytes */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_INIT 12 /* Address of initialization function */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_FINI 13 /* Address of termination function */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_SONAME 14 /* Name of the shared object (string table offset) */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_RPATH 15 /* Library search path (string table offset) */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_SYMBOLIC 16 /* Alter runtime-linkers symbol resolution... */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_REL 17 /* Address of reloc table without addends */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_RELSZ 18 /* Size of reloc table in bytes */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_RELENT 19 /* Size of reloc table entry in bytes? */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_PLTREL 20 /* Type of relocation entry for plt (...TAG_REL or ...TAG_RELA) */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_DEBUG 21 /* Used for debugging */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_TEXTREL 22 /* If present informs the linker that a relocation might update a non-writable segment */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_JMPREL 23 /* Address of relocation entries associated solely with the plt */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_FILTER 24 /* Specifies the name of a shared objects for which this one acts as a filter */
|
||||
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_RUNPATH 29 /* String table offset of a null-terminated library search path string. */
|
||||
#define IMAGE_ELF_DYNAMIC_TAG_FLAGS 30 /* Object specific flag values. */
|
||||
|
||||
/* Dynamic flags (for IMAGE_ELF_DYNAMIC_TAG_FLAGS) */
|
||||
#define IMAGE_ELF_DYNAMIC_FLAG_ORIGIN 0x0001 /* Indicates that the object being loaded may make reference to the $ORIGIN substitution string.*/
|
||||
#define IMAGE_ELF_DYNAMIC_FLAG_SYMBOLIC 0x0002 /* Indicates "symbolic" linking. */
|
||||
#define IMAGE_ELF_DYNAMIC_FLAG_TEXTREL 0x0004 /* Indicates there may be relocations in non-writable segments. */
|
||||
#define IMAGE_ELF_DYNAMIC_FLAG_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 IMAGE_ELF_DYNAMIC_FLAG_STATIC_TLS 0x0010 /* Indicates that the shared object or executable contains code using a static
|
||||
thread-local storage scheme. */
|
||||
|
||||
/* Dynamic array entry */
|
||||
typedef struct _IMAGE_ELF32_DYNAMIC {
|
||||
ELF32_SWORD Tag;
|
||||
union {
|
||||
ELF32_WORD Val;
|
||||
ELF32_ADDR Ptr;
|
||||
} Un;
|
||||
} IMAGE_ELF32_DYNAMIC, *PIMAGE_ELF32_DYNAMIC;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Auxiliary types */
|
||||
#define IMAGE_ELF_AUX_TYPE_NULL 0 /* Terminates the vector. */
|
||||
#define IMAGE_ELF_AUX_TYPE_IGNORE 1 /* Ignored entry. */
|
||||
#define IMAGE_ELF_AUX_TYPE_EXECFD 2 /* File descriptor of program to load. */
|
||||
#define IMAGE_ELF_AUX_TYPE_PHDR 3 /* Program header of program already loaded. */
|
||||
#define IMAGE_ELF_AUX_TYPE_PHENT 4 /* Size of each program header entry. */
|
||||
#define IMAGE_ELF_AUX_TYPE_PHNUM 5 /* Number of program header entries. */
|
||||
#define IMAGE_ELF_AUX_TYPE_PAGESZ 6 /* Page size in bytes. */
|
||||
#define IMAGE_ELF_AUX_TYPE_BASE 7 /* Interpreter's base address. */
|
||||
#define IMAGE_ELF_AUX_TYPE_FLAGS 8 /* Flags (unused for i386). */
|
||||
#define IMAGE_ELF_AUX_TYPE_ENTRY 9 /* Where interpreter should transfer control. */
|
||||
/* Machine-independent and word-size-independent definitions */
|
||||
#include <elf/common.h>
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* Word-size-dependent definitions. All ReactOS builds support all of them,
|
||||
* even if (obviously) code for the wrong architecture cannot be executed - the
|
||||
* files can still be used in machine-independent ways, e.g. as resource DLLs
|
||||
*/
|
||||
#define IMAGE_ELF_AUX_TYPE_BRK 10 /* Starting point for sbrk and brk. */
|
||||
#define IMAGE_ELF_AUX_TYPE_DEBUG 11 /* Debugging level. */
|
||||
#include <elf/elf32.h>
|
||||
#include <elf/elf64.h>
|
||||
|
||||
/*
|
||||
* The following non-standard values are used in Linux ELF binaries.
|
||||
*/
|
||||
#define IMAGE_ELF_AUX_TYPE_NOTELF 10 /* Program is not ELF ?? */
|
||||
#define IMAGE_ELF_AUX_TYPE_UID 11 /* Real uid. */
|
||||
#define IMAGE_ELF_AUX_TYPE_EUID 12 /* Effective uid. */
|
||||
#define IMAGE_ELF_AUX_TYPE_GID 13 /* Real gid. */
|
||||
#define IMAGE_ELF_AUX_TYPE_EGID 14 /* Effective gid. */
|
||||
/* Machine-dependent definitions */
|
||||
#include <elf/machine.h>
|
||||
|
||||
#define IMAGE_ELF_AUX_TYPE_COUNT 15 /* Count of defined aux entry types. */
|
||||
|
||||
|
||||
/* Auxiliary vector entry on initial stack */
|
||||
typedef struct _IMAGE_ELF32_AUXINFO {
|
||||
ELF32_SWORD Type; /* Entry type. */
|
||||
union {
|
||||
ELF32_SWORD Val; /* Integer value. */
|
||||
ELF32_ADDR Ptr; /* Address. */
|
||||
void (*Fcn)(void); /* Function pointer (not used). */
|
||||
} Un;
|
||||
} IMAGE_ELF32_AUXINFO, *PIMAGE_ELF32_AUXINFO;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* arch data types */
|
||||
|
||||
#if ELF_ARCH_SIZE == 32
|
||||
|
||||
#define IMAGE_ELF_SYMBOL_BIND(args...) IMAGE_ELF32_SYMBOL_BIND(args)
|
||||
#define IMAGE_ELF_SYMBOL_TYPE(args...) IMAGE_ELF32_SYMBOL_TYPE(args)
|
||||
#define IMAGE_ELF_SYMBOL_INFO(args...) IMAGE_ELF32_SYMBOL_INFO(args)
|
||||
|
||||
#define IMAGE_ELF_RELOC_SYM(args...) IMAGE_ELF32_RELOC_SYM(args)
|
||||
#define IMAGE_ELF_RELOC_TYPE(args...) IMAGE_ELF32_RELOC_TYPE(args)
|
||||
#define IMAGE_ELF_RELOC_INFO(args...) IMAGE_ELF32_RELOC_INFO(args)
|
||||
|
||||
typedef ELF32_ADDR ELF_ADDR;
|
||||
typedef ELF32_HALF ELF_HALF;
|
||||
typedef ELF32_OFF ELF_OFF;
|
||||
typedef ELF32_SWORD ELF_SWORD;
|
||||
typedef ELF32_WORD ELF_WORD;
|
||||
typedef ELF32_HASHELT ELF_HASHELT;
|
||||
|
||||
typedef IMAGE_ELF32_HEADER IMAGE_ELF_HEADER, *PIMAGE_ELF_HEADER;
|
||||
typedef IMAGE_ELF32_SECTION_HEADER IMAGE_ELF_SECTION_HEADER, *PIMAGE_ELF_SECTION_HEADER;
|
||||
typedef IMAGE_ELF32_SYMBOL IMAGE_ELF_SYMBOL, *PIMAGE_ELF_SYMBOL;
|
||||
typedef IMAGE_ELF32_RELOC IMAGE_ELF_RELOC, *PIMAGE_ELF_RELOC;
|
||||
typedef IMAGE_ELF32_RELOCA IMAGE_ELF_RELOCA, *PIMAGE_ELF_RELOCA;
|
||||
typedef IMAGE_ELF32_PROGRAM_HEADER IMAGE_ELF_PROGRAM_HEADER, *PIMAGE_ELF_PROGRAM_HEADER;
|
||||
typedef IMAGE_ELF32_DYNAMIC IMAGE_ELF_DYNAMIC, *PIMAGE_ELF_DYNAMIC;
|
||||
typedef IMAGE_ELF32_AUXINFO IMAGE_ELF_AUXINFO, *PIMAGE_ELF_AUXINFO;
|
||||
|
||||
#elif ELF_ARCH_SIZE == 64
|
||||
# error 64 bits unsupported
|
||||
#else
|
||||
# error Undefined architecture size!
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/* target macros */
|
||||
#ifdef _M_IX86
|
||||
# define IMAGE_ELF_TARGET_CLASS IMAGE_ELF_CLASS_32
|
||||
# define IMAGE_ELF_TARGET_DATA IMAGE_ELF_DATA_2LSB
|
||||
# define IMAGE_ELF_TARGET_MACHINE IMAGE_ELF_MACHINE_386
|
||||
# define IMAGE_ELF_TARGET_VERSION 1
|
||||
#else
|
||||
# error Unsupported architecture!
|
||||
#endif
|
||||
|
||||
#undef ELF_ARCH_SIZE
|
||||
|
||||
#endif /* __INCLUDE_ELF_H */
|
||||
|
||||
/* EOF */
|
||||
|
||||
@@ -0,0 +1,392 @@
|
||||
/*-
|
||||
* 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 _SYS_ELF_COMMON_H_
|
||||
#define _SYS_ELF_COMMON_H_ 1
|
||||
|
||||
/*
|
||||
* ELF definitions that are independent of architecture or word size.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Note header. The ".note" section contains an array of notes. Each
|
||||
* begins with this header, aligned to a word boundary. Immediately
|
||||
* following the note header is n_namesz bytes of name, padded to the
|
||||
* next word boundary. Then comes n_descsz bytes of descriptor, again
|
||||
* padded to a word boundary. The values of n_namesz and n_descsz do
|
||||
* not include the padding.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
UINT32 n_namesz; /* Length of name. */
|
||||
UINT32 n_descsz; /* Length of descriptor. */
|
||||
UINT32 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. */
|
||||
/*
|
||||
* Source:
|
||||
* System V Application Binary Interface (DRAFT) 2003-12-17, Chapter 4, Section
|
||||
* "ELF Header"
|
||||
*/
|
||||
#define EM_NONE 0 /* No machine */
|
||||
#define EM_M32 1 /* AT&T WE 32100 */
|
||||
#define EM_SPARC 2 /* SPARC */
|
||||
#define EM_386 3 /* Intel 80386 */
|
||||
#define EM_68K 4 /* Motorola 68000 */
|
||||
#define EM_88K 5 /* Motorola 88000 */
|
||||
/* reserved 6 Reserved for future use (was EM_486) */
|
||||
#define EM_860 7 /* Intel 80860 */
|
||||
#define EM_MIPS 8 /* MIPS I Architecture */
|
||||
#define EM_S370 9 /* IBM System/370 Processor */
|
||||
#define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */
|
||||
/* reserved 11-14 Reserved for future use */
|
||||
#define EM_PARISC 15 /* Hewlett-Packard PA-RISC */
|
||||
/* reserved 16 Reserved for future use */
|
||||
#define EM_VPP500 17 /* Fujitsu VPP500 */
|
||||
#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
|
||||
#define EM_960 19 /* Intel 80960 */
|
||||
#define EM_PPC 20 /* PowerPC */
|
||||
#define EM_PPC64 21 /* 64-bit PowerPC */
|
||||
#define EM_S390 22 /* IBM System/390 Processor */
|
||||
/* reserved 23-35 Reserved for future use */
|
||||
#define EM_V800 36 /* NEC V800 */
|
||||
#define EM_FR20 37 /* Fujitsu FR20 */
|
||||
#define EM_RH32 38 /* TRW RH-32 */
|
||||
#define EM_RCE 39 /* Motorola RCE */
|
||||
#define EM_ARM 40 /* Advanced RISC Machines ARM */
|
||||
#define EM_ALPHA 41 /* Digital Alpha */
|
||||
#define EM_SH 42 /* Hitachi SH */
|
||||
#define EM_SPARCV9 43 /* SPARC Version 9 */
|
||||
#define EM_TRICORE 44 /* Siemens TriCore embedded processor */
|
||||
#define EM_ARC 45 /* Argonaut RISC Core, Argonaut Technologies
|
||||
Inc. */
|
||||
#define EM_H8_300 46 /* Hitachi H8/300 */
|
||||
#define EM_H8_300H 47 /* Hitachi H8/300H */
|
||||
#define EM_H8S 48 /* Hitachi H8S */
|
||||
#define EM_H8_500 49 /* Hitachi H8/500 */
|
||||
#define EM_IA_64 50 /* Intel IA-64 processor architecture */
|
||||
#define EM_MIPS_X 51 /* Stanford MIPS-X */
|
||||
#define EM_COLDFIRE 52 /* Motorola ColdFire */
|
||||
#define EM_68HC12 53 /* Motorola M68HC12 */
|
||||
#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator */
|
||||
#define EM_PCP 55 /* Siemens PCP */
|
||||
#define EM_NCPU 56 /* Sony nCPU embedded RISC processor */
|
||||
#define EM_NDR1 57 /* Denso NDR1 microprocessor */
|
||||
#define EM_STARCORE 58 /* Motorola Star*Core processor */
|
||||
#define EM_ME16 59 /* Toyota ME16 processor */
|
||||
#define EM_ST100 60 /* STMicroelectronics ST100 processor */
|
||||
#define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ embedded processor
|
||||
family */
|
||||
#define EM_X86_64 62 /* AMD x86-64 architecture */
|
||||
#define EM_PDSP 63 /* Sony DSP Processor */
|
||||
#define EM_PDP10 64 /* Digital Equipment Corp. PDP-10 */
|
||||
#define EM_PDP11 65 /* Digital Equipment Corp. PDP-11 */
|
||||
#define EM_FX66 66 /* Siemens FX66 microcontroller */
|
||||
#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 bit
|
||||
microcontroller */
|
||||
#define EM_ST7 68 /* STMicroelectronics ST7 8-bit
|
||||
microcontroller */
|
||||
#define EM_68HC16 69 /* Motorola MC68HC16 Microcontroller */
|
||||
#define EM_68HC11 70 /* Motorola MC68HC11 Microcontroller */
|
||||
#define EM_68HC08 71 /* Motorola MC68HC08 Microcontroller */
|
||||
#define EM_68HC05 72 /* Motorola MC68HC05 Microcontroller */
|
||||
#define EM_SVX 73 /* Silicon Graphics SVx */
|
||||
#define EM_ST19 74 /* STMicroelectronics ST19 8-bit
|
||||
microcontroller */
|
||||
#define EM_VAX 75 /* Digital VAX */
|
||||
#define EM_CRIS 76 /* Axis Communications 32-bit embedded
|
||||
processor */
|
||||
#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded
|
||||
processor */
|
||||
#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
|
||||
#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
|
||||
#define EM_MMIX 80 /* Donald Knuth's educational 64-bit
|
||||
processor */
|
||||
#define EM_HUANY 81 /* Harvard University machine-independent object
|
||||
files */
|
||||
#define EM_PRISM 82 /* SiTera Prism */
|
||||
#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
|
||||
#define EM_FR30 84 /* Fujitsu FR30 */
|
||||
#define EM_D10V 85 /* Mitsubishi D10V */
|
||||
#define EM_D30V 86 /* Mitsubishi D30V */
|
||||
#define EM_V850 87 /* NEC v850 */
|
||||
#define EM_M32R 88 /* Mitsubishi M32R */
|
||||
#define EM_MN10300 89 /* Matsushita MN10300 */
|
||||
#define EM_MN10200 90 /* Matsushita MN10200 */
|
||||
#define EM_PJ 91 /* picoJava */
|
||||
#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
|
||||
#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
|
||||
#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
|
||||
#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor */
|
||||
#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose
|
||||
Processor */
|
||||
#define EM_NS32K 97 /* National Semiconductor 32000 series */
|
||||
#define EM_TPC 98 /* Tenor Network TPC processor */
|
||||
#define EM_SNP1K 99 /* Trebia SNP 1000 processor */
|
||||
#define EM_ST200 100 /* STMicroelectronics (www.st.com) ST200
|
||||
microcontroller */
|
||||
#define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family */
|
||||
#define EM_MAX 102 /* MAX Processor */
|
||||
#define EM_CR 103 /* National Semiconductor CompactRISC
|
||||
microprocessor */
|
||||
#define EM_F2MC16 104 /* Fujitsu F2MC16 */
|
||||
#define EM_MSP430 105 /* Texas Instruments embedded microcontroller
|
||||
msp430 */
|
||||
#define EM_BLACKFIN 106 /* Analog Devices Blackfin (DSP) processor */
|
||||
#define EM_SE_C33 107 /* S1C33 Family of Seiko Epson processors */
|
||||
#define EM_SEP 108 /* Sharp embedded microprocessor */
|
||||
#define EM_ARCA 109 /* Arca RISC Microprocessor */
|
||||
#define EM_UNICORE 110 /* Microprocessor series from PKU-Unity Ltd. and
|
||||
MPRC of Peking University */
|
||||
|
||||
/* 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 /* !_SYS_ELF_COMMON_H_ */
|
||||
@@ -0,0 +1,153 @@
|
||||
/*-
|
||||
* 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 _MACHINE_ELF_H_
|
||||
#define _MACHINE_ELF_H_ 1
|
||||
|
||||
/*
|
||||
* ELF definitions for the i386 architecture.
|
||||
*/
|
||||
|
||||
#ifdef _REACTOS_ELF_MACHINE_IS_TARGET
|
||||
|
||||
#ifndef __ELF_WORD_SIZE
|
||||
#define __ELF_WORD_SIZE 32 /* Used by <elf/generic.h> */
|
||||
#endif
|
||||
|
||||
#include <elf/generic.h>
|
||||
|
||||
#define ELF_ARCH EM_386
|
||||
|
||||
#define ELF_MACHINE_OK(x) ((x) == EM_386 || (x) == EM_486)
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
||||
__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. */
|
||||
|
||||
/* Define "machine" characteristics */
|
||||
#define ELF_TARG_CLASS ELFCLASS32
|
||||
#define ELF_TARG_DATA ELFDATA2LSB
|
||||
#define ELF_TARG_MACH EM_386
|
||||
#define ELF_TARG_VER 1
|
||||
|
||||
#endif /* _REACTOS_ELF_MACHINE_IS_TARGET */
|
||||
|
||||
/*
|
||||
* 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 /* !_MACHINE_ELF_H_ */
|
||||
@@ -0,0 +1,154 @@
|
||||
/*-
|
||||
* 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 _SYS_ELF32_H_
|
||||
#define _SYS_ELF32_H_ 1
|
||||
|
||||
/*
|
||||
* ELF definitions common to all 32-bit architectures.
|
||||
*/
|
||||
|
||||
typedef ULONG32 Elf32_Addr;
|
||||
typedef USHORT Elf32_Half;
|
||||
typedef ULONG32 Elf32_Off;
|
||||
typedef LONG32 Elf32_Sword;
|
||||
typedef ULONG32 Elf32_Word;
|
||||
typedef ULONG32 Elf32_Size;
|
||||
typedef Elf32_Off Elf32_Hashelt;
|
||||
|
||||
/*
|
||||
* ELF header.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
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 /* !_SYS_ELF32_H_ */
|
||||
@@ -0,0 +1,167 @@
|
||||
/*-
|
||||
* 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 _SYS_ELF64_H_
|
||||
#define _SYS_ELF64_H_ 1
|
||||
|
||||
/*
|
||||
* ELF definitions common to all 64-bit architectures.
|
||||
*/
|
||||
|
||||
typedef ULONG64 Elf64_Addr;
|
||||
typedef ULONG32 Elf64_Half;
|
||||
typedef ULONG64 Elf64_Off;
|
||||
typedef LONG64 Elf64_Sword;
|
||||
typedef ULONG64 Elf64_Word;
|
||||
typedef ULONG64 Elf64_Size;
|
||||
typedef USHORT 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 /* !_SYS_ELF64_H_ */
|
||||
@@ -0,0 +1,87 @@
|
||||
/*-
|
||||
* 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_generic.h,v 1.6 2002/07/20 02:56:11 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_ELF_GENERIC_H_
|
||||
#define _SYS_ELF_GENERIC_H_ 1
|
||||
|
||||
/* [REACTOS] TODO: we need to define this somewhere global */
|
||||
#define __ELF_CONCAT1(x,y) x ## y
|
||||
#define __ELF_CONCAT(x,y) __ELF_CONCAT1(x,y)
|
||||
|
||||
/*
|
||||
* Definitions of generic ELF names which relieve applications from
|
||||
* needing to know the word size.
|
||||
*/
|
||||
|
||||
#if __ELF_WORD_SIZE != 32 && __ELF_WORD_SIZE != 64
|
||||
#error "__ELF_WORD_SIZE must be defined as 32 or 64"
|
||||
#endif
|
||||
|
||||
#define ELF_CLASS __ELF_CONCAT(ELFCLASS,__ELF_WORD_SIZE)
|
||||
|
||||
#if 0
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#define ELF_DATA ELFDATA2LSB
|
||||
#elif BYTE_ORDER == BIG_ENDIAN
|
||||
#define ELF_DATA ELFDATA2MSB
|
||||
#else
|
||||
#error "Unknown byte order"
|
||||
#endif
|
||||
#else
|
||||
/* [REACTOS] FIXME: we need to add this to our build system */
|
||||
#define ELF_DATA ELFDATA2LSB
|
||||
#endif
|
||||
|
||||
#define __elfN(x) __ELF_CONCAT(__ELF_CONCAT(__ELF_CONCAT(elf,__ELF_WORD_SIZE),_),x)
|
||||
#define __ElfN(x) __ELF_CONCAT(__ELF_CONCAT(__ELF_CONCAT(Elf,__ELF_WORD_SIZE),_),x)
|
||||
#define __ELFN(x) __ELF_CONCAT(__ELF_CONCAT(__ELF_CONCAT(ELF,__ELF_WORD_SIZE),_),x)
|
||||
#define __ElfType(x) typedef __ElfN(x) __ELF_CONCAT(Elf_,x)
|
||||
|
||||
__ElfType(Addr);
|
||||
__ElfType(Half);
|
||||
__ElfType(Off);
|
||||
__ElfType(Sword);
|
||||
__ElfType(Word);
|
||||
__ElfType(Size);
|
||||
__ElfType(Hashelt);
|
||||
__ElfType(Ehdr);
|
||||
__ElfType(Shdr);
|
||||
__ElfType(Phdr);
|
||||
__ElfType(Dyn);
|
||||
__ElfType(Rel);
|
||||
__ElfType(Rela);
|
||||
__ElfType(Sym);
|
||||
|
||||
#define ELF_R_SYM __ELFN(R_SYM)
|
||||
#define ELF_R_TYPE __ELFN(R_TYPE)
|
||||
#define ELF_R_INFO __ELFN(R_INFO)
|
||||
#define ELF_ST_BIND __ELFN(ST_BIND)
|
||||
#define ELF_ST_TYPE __ELFN(ST_TYPE)
|
||||
#define ELF_ST_INFO __ELFN(ST_INFO)
|
||||
|
||||
#endif /* !_SYS_ELF_GENERIC_H_ */
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef _REACTOS_ELF_MACHINE_H_
|
||||
#define _REACTOS_ELF_MACHINE_H_ 1
|
||||
|
||||
#ifdef _M_IX86
|
||||
#define _REACTOS_ELF_MACHINE_IS_TARGET
|
||||
#include <elf/elf-i386.h>
|
||||
#undef _REACTOS_ELF_MACHINE_IS_TARGET
|
||||
#else
|
||||
#error Unsupported target architecture
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+69
-4
@@ -40,6 +40,7 @@
|
||||
#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 // File is executable (i.e. no unresolved externel references).
|
||||
#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 // Line nunbers stripped from file.
|
||||
#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 // Local symbols stripped from file.
|
||||
#define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020 // Application supports addresses >2GB
|
||||
#define IMAGE_FILE_BYTES_REVERSED_LO 0x0080 // Bytes of machine word are reversed.
|
||||
#define IMAGE_FILE_32BIT_MACHINE 0x0100 // 32 bit word machine.
|
||||
#define IMAGE_FILE_DEBUG_STRIPPED 0x0200 // Debugging info stripped from file in .DBG file
|
||||
@@ -57,6 +58,12 @@
|
||||
#define IMAGE_FILE_MACHINE_R10000 0x168 // MIPS little-endian
|
||||
#define IMAGE_FILE_MACHINE_ALPHA 0x184 // Alpha_AXP
|
||||
#define IMAGE_FILE_MACHINE_POWERPC 0x1F0 // IBM PowerPC Little-Endian
|
||||
#define IMAGE_FILE_MACHINE_ARM 0x01c0 // ARM little-endian
|
||||
#define IMAGE_FILE_MACHINE_IA64 0x0200 // Intel IA64
|
||||
#define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
|
||||
#define IMAGE_FILE_MACHINE_ALPHA64 0x0284 // Alpha AXP, full 64-bit support
|
||||
#define IMAGE_FILE_MACHINE_AMD64 0x8664 // AMD x86-64
|
||||
#define IMAGE_FILE_MACHINE_M32R 0x9041 // M32R little-endian
|
||||
|
||||
#pragma pack(push,4)
|
||||
typedef struct _IMAGE_FILE_HEADER {
|
||||
@@ -104,7 +111,46 @@ typedef struct _IMAGE_OPTIONAL_HEADER {
|
||||
DWORD LoaderFlags;
|
||||
DWORD NumberOfRvaAndSizes;
|
||||
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
|
||||
} IMAGE_OPTIONAL_HEADER,*PIMAGE_OPTIONAL_HEADER;
|
||||
} IMAGE_OPTIONAL_HEADER32,*PIMAGE_OPTIONAL_HEADER32;
|
||||
typedef struct _IMAGE_OPTIONAL_HEADER64 {
|
||||
WORD Magic;
|
||||
BYTE MajorLinkerVersion;
|
||||
BYTE MinorLinkerVersion;
|
||||
DWORD SizeOfCode;
|
||||
DWORD SizeOfInitializedData;
|
||||
DWORD SizeOfUninitializedData;
|
||||
DWORD AddressOfEntryPoint;
|
||||
DWORD BaseOfCode;
|
||||
ULONGLONG ImageBase;
|
||||
DWORD SectionAlignment;
|
||||
DWORD FileAlignment;
|
||||
WORD MajorOperatingSystemVersion;
|
||||
WORD MinorOperatingSystemVersion;
|
||||
WORD MajorImageVersion;
|
||||
WORD MinorImageVersion;
|
||||
WORD MajorSubsystemVersion;
|
||||
WORD MinorSubsystemVersion;
|
||||
DWORD Reserved1;
|
||||
DWORD SizeOfImage;
|
||||
DWORD SizeOfHeaders;
|
||||
DWORD CheckSum;
|
||||
WORD Subsystem;
|
||||
WORD DllCharacteristics;
|
||||
ULONGLONG SizeOfStackReserve;
|
||||
ULONGLONG SizeOfStackCommit;
|
||||
ULONGLONG SizeOfHeapReserve;
|
||||
ULONGLONG SizeOfHeapCommit;
|
||||
DWORD LoaderFlags;
|
||||
DWORD NumberOfRvaAndSizes;
|
||||
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
|
||||
} IMAGE_OPTIONAL_HEADER64,*PIMAGE_OPTIONAL_HEADER64;
|
||||
#ifdef _WIN64
|
||||
typedef IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER;
|
||||
typedef PIMAGE_OPTIONAL_HEADER64 PIMAGE_OPTIONAL_HEADER;
|
||||
#else
|
||||
typedef IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER;
|
||||
typedef PIMAGE_OPTIONAL_HEADER32 PIMAGE_OPTIONAL_HEADER;
|
||||
#endif
|
||||
typedef struct _IMAGE_ROM_OPTIONAL_HEADER {
|
||||
WORD Magic;
|
||||
BYTE MajorLinkerVersion;
|
||||
@@ -180,8 +226,20 @@ typedef struct _IMAGE_OS2_HEADER {
|
||||
typedef struct _IMAGE_NT_HEADERS {
|
||||
DWORD Signature;
|
||||
IMAGE_FILE_HEADER FileHeader;
|
||||
IMAGE_OPTIONAL_HEADER OptionalHeader;
|
||||
} IMAGE_NT_HEADERS,*PIMAGE_NT_HEADERS;
|
||||
IMAGE_OPTIONAL_HEADER32 OptionalHeader;
|
||||
} IMAGE_NT_HEADERS32,*PIMAGE_NT_HEADERS32;
|
||||
typedef struct _IMAGE_NT_HEADERS64 {
|
||||
DWORD Signature;
|
||||
IMAGE_FILE_HEADER FileHeader;
|
||||
IMAGE_OPTIONAL_HEADER64 OptionalHeader;
|
||||
} IMAGE_NT_HEADERS64,*PIMAGE_NT_HEADERS64;
|
||||
#ifdef _WIN64
|
||||
typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS;
|
||||
typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
|
||||
#else
|
||||
typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS;
|
||||
typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
|
||||
#endif
|
||||
typedef struct _IMAGE_ROM_HEADERS {
|
||||
IMAGE_FILE_HEADER FileHeader;
|
||||
IMAGE_ROM_OPTIONAL_HEADER OptionalHeader;
|
||||
@@ -494,6 +552,12 @@ typedef struct _IMAGE_RESOURCE_DIRECTORY {
|
||||
} IMAGE_RESOURCE_DIRECTORY, *PIMAGE_RESOURCE_DIRECTORY;
|
||||
*/
|
||||
|
||||
#ifdef _WIN64
|
||||
#define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR64_MAGIC
|
||||
#else
|
||||
#define IMAGE_NT_OPTIONAL_HDR_MAGIC IMAGE_NT_OPTIONAL_HDR32_MAGIC
|
||||
#endif
|
||||
|
||||
#endif /* !__USE_W32API */
|
||||
|
||||
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
|
||||
@@ -555,7 +619,8 @@ typedef struct _IMAGE_RESOURCE_DIRECTORY {
|
||||
#define IMAGE_SIZEOF_FILE_HEADER 20
|
||||
#define IMAGE_FILE_MACHINE_UNKNOWN 0
|
||||
#define IMAGE_NT_SIGNATURE 0x00004550
|
||||
#define IMAGE_NT_OPTIONAL_HDR_MAGIC 0x10b
|
||||
#define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
|
||||
#define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
|
||||
#define IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
|
||||
#define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
|
||||
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
|
||||
|
||||
@@ -23,6 +23,50 @@
|
||||
#ifndef KJK_PSEH_H_
|
||||
#define KJK_PSEH_H_
|
||||
|
||||
/* Some useful macros */
|
||||
#if defined(__cplusplus)
|
||||
# define _SEH_PVOID_CAST(TYPE_, P_) ((TYPE_)(P_))
|
||||
#else
|
||||
# define _SEH_PVOID_CAST(TYPE_, P_) (P_)
|
||||
#endif
|
||||
|
||||
#if defined(FIELD_OFFSET)
|
||||
# define _SEH_FIELD_OFFSET FIELD_OFFSET
|
||||
#else
|
||||
# include <stddef.h>
|
||||
# define _SEH_FIELD_OFFSET offsetof
|
||||
#endif
|
||||
|
||||
#if defined(CONTAINING_RECORD)
|
||||
# define _SEH_CONTAINING_RECORD CONTAINING_RECORD
|
||||
#else
|
||||
# define _SEH_CONTAINING_RECORD(ADDR_, TYPE_, FIELD_) \
|
||||
((TYPE_ *)(((char *)(ADDR_)) - _SEH_FIELD_OFFSET(TYPE_, FIELD_)))
|
||||
#endif
|
||||
|
||||
#if defined(__CONCAT)
|
||||
# define _SEH_CONCAT __CONCAT
|
||||
#else
|
||||
# define _SEH_CONCAT1(X_, Y_) X_ ## Y_
|
||||
# define _SEH_CONCAT(X_, Y_) _SEH_CONCAT1(X_, Y_)
|
||||
#endif
|
||||
|
||||
/* Locals sharing support */
|
||||
#define _SEH_LOCALS_TYPENAME(BASENAME_) \
|
||||
struct _SEH_CONCAT(_SEHLocalsTag, BASENAME_)
|
||||
|
||||
#define _SEH_DEFINE_LOCALS(BASENAME_) \
|
||||
_SEH_LOCALS_TYPENAME(BASENAME_)
|
||||
|
||||
#define _SEH_DECLARE_LOCALS(BASENAME_) \
|
||||
_SEH_LOCALS_TYPENAME(BASENAME_) _SEHLocals; \
|
||||
_SEH_LOCALS_TYPENAME(BASENAME_) * _SEHPLocals; \
|
||||
_SEHPLocals = &_SEHLocals;
|
||||
|
||||
/* Dummy locals */
|
||||
static _SEH_LOCALS_TYPENAME(_SEHDummyLocals) { int Dummy_; } _SEHLocals;
|
||||
static void __inline _SEHDummyLocalsUser(void) { (void)_SEHLocals; }
|
||||
|
||||
/* TODO: <pseh/native.h> to wrap native SEH implementations */
|
||||
#include <pseh/framebased.h>
|
||||
|
||||
|
||||
@@ -72,21 +72,66 @@ static __declspec(noreturn) __inline void __stdcall _SEHCompilerSpecificHandler
|
||||
_SEHLongJmp(myframe->SEH_JmpBuf, 1);
|
||||
}
|
||||
|
||||
/* SHARED LOCALS */
|
||||
/* Access the locals for the current frame */
|
||||
#define _SEH_ACCESS_LOCALS(LOCALS_) \
|
||||
_SEH_LOCALS_TYPENAME(LOCALS_) * _SEHPLocals; \
|
||||
_SEHPLocals = \
|
||||
_SEH_PVOID_CAST \
|
||||
( \
|
||||
_SEH_LOCALS_TYPENAME(LOCALS_) *, \
|
||||
_SEH_CONTAINING_RECORD(_SEHPortableFrame, _SEHFrame_t, SEH_Header) \
|
||||
->SEH_Locals \
|
||||
);
|
||||
|
||||
/* Access local variable VAR_ */
|
||||
#define _SEH_VAR(VAR_) _SEHPLocals->VAR_
|
||||
|
||||
/* FILTER FUNCTIONS */
|
||||
/* Declares a filter function's prototype */
|
||||
#define _SEH_FILTER(NAME_) \
|
||||
int __stdcall NAME_ \
|
||||
long __stdcall NAME_ \
|
||||
( \
|
||||
struct _EXCEPTION_POINTERS * _SEHExceptionPointers, \
|
||||
struct __SEHPortableFrame * _SEHPortableFrame \
|
||||
)
|
||||
|
||||
/* Declares a static filter */
|
||||
#define _SEH_STATIC_FILTER(ACTION_) ((_SEHFilter_t)((ACTION_) + 2))
|
||||
|
||||
/* Declares a PSEH filter wrapping a regular filter function */
|
||||
#define _SEH_WRAP_FILTER(WRAPPER_, NAME_) \
|
||||
static __inline _SEH_FILTER(WRAPPER_) \
|
||||
{ \
|
||||
return (NAME_)(_SEHExceptionPointers); \
|
||||
}
|
||||
|
||||
/* FINALLY FUNCTIONS */
|
||||
/* Declares a finally function's prototype */
|
||||
#define _SEH_FINALLY(NAME_) \
|
||||
void __stdcall NAME_ \
|
||||
( \
|
||||
struct __SEHPortableFrame * _SEHPortableFrame \
|
||||
)
|
||||
|
||||
/* Declares a PSEH finally function wrapping a regular function */
|
||||
#define _SEH_WRAP_FINALLY(WRAPPER_, NAME_) \
|
||||
_SEH_WRAP_FINALLY_ARGS(WRAPPER_, NAME_, ())
|
||||
|
||||
#define _SEH_WRAP_FINALLY_ARGS(WRAPPER_, NAME_, ARGS_) \
|
||||
static __inline _SEH_FINALLY(WRAPPER_) \
|
||||
{ \
|
||||
NAME_ ARGS_; \
|
||||
}
|
||||
|
||||
#define _SEH_WRAP_FINALLY_LOCALS_ARGS(WRAPPER_, LOCALS_, NAME_, ARGS_) \
|
||||
static __inline _SEH_FINALLY(WRAPPER_) \
|
||||
{ \
|
||||
_SEH_ACCESS_LOCALS(LOCALS_); \
|
||||
NAME_ ARGS_; \
|
||||
}
|
||||
|
||||
/* SAFE BLOCKS */
|
||||
#define _SEH_TRY_FINALLY(FINALLY_) \
|
||||
_SEH_TRY_FILTER_FINALLY \
|
||||
( \
|
||||
@@ -109,22 +154,36 @@ static __declspec(noreturn) __inline void __stdcall _SEHCompilerSpecificHandler
|
||||
#define _SEH_TRY \
|
||||
_SEH_TRY_HANDLE_FINALLY(NULL)
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define _SEH_DECLARE_HANDLERS(FILTER_, FINALLY_) \
|
||||
const _SEHHandlers_t _SEHHandlers = \
|
||||
{ \
|
||||
(FILTER_), \
|
||||
_SEHCompilerSpecificHandler, \
|
||||
(FINALLY_) \
|
||||
};
|
||||
#else
|
||||
# define _SEH_DECLARE_HANDLERS(FILTER_, FINALLY_) \
|
||||
_SEHHandlers_t _SEHHandlers = \
|
||||
{ \
|
||||
(0), \
|
||||
_SEHCompilerSpecificHandler, \
|
||||
(0) \
|
||||
}; \
|
||||
_SEHHandlers.SH_Filter = (FILTER_); \
|
||||
_SEHHandlers.SH_Finally = (FINALLY_);
|
||||
#endif
|
||||
|
||||
#define _SEH_TRY_FILTER_FINALLY(FILTER_, FINALLY_) \
|
||||
{ \
|
||||
static _SEHHandlers_t _SEHHandlers = \
|
||||
{ \
|
||||
(NULL), \
|
||||
_SEHCompilerSpecificHandler, \
|
||||
(NULL) \
|
||||
}; \
|
||||
_SEHHandlers.SH_Filter = FILTER_; \
|
||||
_SEHHandlers.SH_Finally = FINALLY_; \
|
||||
_SEH_DECLARE_HANDLERS(FILTER_, FINALLY_); \
|
||||
\
|
||||
_SEHFrame_t * _SEHFrame; \
|
||||
volatile _SEHPortableFrame_t * _SEHPortableFrame; \
|
||||
\
|
||||
_SEHFrame = _alloca(sizeof(_SEHFrame_t)); \
|
||||
_SEHFrame->SEH_Header.SPF_Handlers = &_SEHHandlers; \
|
||||
_SEHFrame->SEH_Locals = &_SEHLocals; \
|
||||
\
|
||||
_SEHPortableFrame = &_SEHFrame->SEH_Header; \
|
||||
(void)_SEHPortableFrame; \
|
||||
|
||||
@@ -44,7 +44,7 @@ _SEHRegistration_t;
|
||||
|
||||
struct __SEHPortableFrame;
|
||||
|
||||
typedef int (__stdcall * _SEHFilter_t)
|
||||
typedef long (__stdcall * _SEHFilter_t)
|
||||
(
|
||||
struct _EXCEPTION_POINTERS *,
|
||||
struct __SEHPortableFrame *
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
#ifndef REACTOS_EXEFORMAT_H_INCLUDED_
|
||||
#define REACTOS_EXEFORMAT_H_INCLUDED_ 1
|
||||
|
||||
/*
|
||||
* LOADER API
|
||||
*/
|
||||
/* OUT flags returned by a loader */
|
||||
#define EXEFMT_LOAD_ASSUME_SEGMENTS_SORTED (1 << 0)
|
||||
#define EXEFMT_LOAD_ASSUME_SEGMENTS_NO_OVERLAP (1 << 1)
|
||||
#define EXEFMT_LOAD_ASSUME_SEGMENTS_PAGE_ALIGNED (1 << 2)
|
||||
|
||||
#define EXEFMT_LOAD_ASSUME_SEGMENTS_OK \
|
||||
( \
|
||||
EXEFMT_LOAD_ASSUME_SEGMENTS_SORTED | \
|
||||
EXEFMT_LOAD_ASSUME_SEGMENTS_NO_OVERLAP | \
|
||||
EXEFMT_LOAD_ASSUME_SEGMENTS_PAGE_ALIGNED \
|
||||
)
|
||||
|
||||
/*
|
||||
Minumum size of the buffer passed to each loader for identification of the
|
||||
executable
|
||||
*/
|
||||
#define EXEFMT_LOAD_HEADER_SIZE (0x2000)
|
||||
|
||||
/* Special values for the base address of images */
|
||||
/*
|
||||
Base address can't be represented in an ULONG_PTR: any effective load address
|
||||
will require relocation
|
||||
*/
|
||||
#define EXEFMT_LOAD_BASE_NONE ((ULONG_PTR)-1)
|
||||
|
||||
/* Base address never matters, relocation never required */
|
||||
#define EXEFMT_LOAD_BASE_ANY ((ULONG_PTR)-2)
|
||||
|
||||
typedef NTSTATUS (NTAPI * PEXEFMT_CB_READ_FILE)
|
||||
(
|
||||
IN PVOID File,
|
||||
IN PLARGE_INTEGER Offset,
|
||||
IN ULONG Length,
|
||||
OUT PVOID * Data,
|
||||
OUT PVOID * AllocBase,
|
||||
OUT PULONG ReadSize
|
||||
);
|
||||
|
||||
typedef PMM_SECTION_SEGMENT (NTAPI * PEXEFMT_CB_ALLOCATE_SEGMENTS)
|
||||
(
|
||||
IN ULONG NrSegments
|
||||
);
|
||||
|
||||
typedef NTSTATUS (NTAPI * PEXEFMT_LOADER)
|
||||
(
|
||||
IN CONST VOID * FileHeader,
|
||||
IN SIZE_T FileHeaderSize,
|
||||
IN PVOID File,
|
||||
OUT PMM_IMAGE_SECTION_OBJECT ImageSectionObject,
|
||||
OUT PULONG Flags,
|
||||
IN PEXEFMT_CB_READ_FILE ReadFileCb,
|
||||
IN PEXEFMT_CB_ALLOCATE_SEGMENTS AllocateSegmentsCb
|
||||
);
|
||||
|
||||
/*
|
||||
* STATUS CONSTANTS
|
||||
*/
|
||||
|
||||
#define FACILITY_ROS_EXEFMT (0x10)
|
||||
|
||||
/*
|
||||
* Returned by ExeFormat loaders to tell the caller the format isn't supported,
|
||||
* as opposed to STATUS_INVALID_IMAGE_FORMAT meaning the format is supported,
|
||||
* but the particular file is malformed
|
||||
*/
|
||||
#define STATUS_ROS_EXEFMT_UNKNOWN_FORMAT (0xA0100001)
|
||||
|
||||
/*
|
||||
* Returned by MmCreateSection to signal successful loading of an executable
|
||||
* image, saving the caller the effort of determining the executable's format
|
||||
* again. The full status to return is obtained by performing a bitwise OR of
|
||||
* STATUS_ROS_EXEFMT_LOADED_FORMAT and the appropriate EXEFMT_LOADED_XXX
|
||||
*/
|
||||
#define FACILITY_ROS_EXEFMT_FORMAT (0x11)
|
||||
#define STATUS_ROS_EXEFMT_LOADED_FORMAT (0x60110000)
|
||||
|
||||
/* non-standard format, ZwQuerySection required to retrieve the format tag */
|
||||
#define EXEFMT_LOADED_EXTENDED (0x0000FFFF)
|
||||
|
||||
/* Windows PE32/PE32+ */
|
||||
#define EXEFMT_LOADED_PE32 (0x00000000)
|
||||
#define EXEFMT_LOADED_PE64 (0x00000001)
|
||||
|
||||
/* Wine ELF */
|
||||
#define EXEFMT_LOADED_WINE32 (0x00000002)
|
||||
#define EXEFMT_LOADED_WINE64 (0x00000003)
|
||||
|
||||
/* regular ELF */
|
||||
#define EXEFMT_LOADED_ELF32 (0x00000004)
|
||||
#define EXEFMT_LOADED_ELF64 (0x00000005)
|
||||
|
||||
#endif
|
||||
|
||||
/* EOF */
|
||||
Reference in New Issue
Block a user