00001 /* elf.h */ 00002 00003 #ifndef __SYSTEM 00004 #include "../include/system.h" 00005 #endif 00006 00007 typedef unsigned int Elf32_Addr; 00008 typedef unsigned short Elf32_Half; 00009 typedef unsigned int Elf32_Off; 00010 typedef int Elf32_Sword; 00011 typedef unsigned int Elf32_Word; 00012 00013 #define EI_NIDENT 16 00014 00015 typedef struct Elf32_Ehdr { 00016 unsigned char e_ident[EI_NIDENT]; 00017 Elf32_Half e_type; 00018 Elf32_Half e_machine; 00019 Elf32_Word e_version; 00020 Elf32_Addr e_entry; 00021 Elf32_Off e_phoff; 00022 Elf32_Off e_shoff; 00023 Elf32_Word e_flags; 00024 Elf32_Half e_ehsize; 00025 Elf32_Half e_phentsize; 00026 Elf32_Half e_phnum; 00027 Elf32_Half e_shentsize; 00028 Elf32_Half e_shnum; 00029 Elf32_Half s_shstrndx; 00030 } Elf32_Ehdr; 00031 00032 //e_type 00033 #define ET_NONE 0 00034 #define ET_REL 1 00035 #define ET_EXEC 2 00036 #define ET_DYN 3 00037 #define ET_CORE 4 00038 #define ET_LOPROC 0xff00 00039 #define ET_HIPROC 0xffff 00040 00041 //e_version 00042 #define EV_NONE 0 00043 #define EV_CURRENT 1 00044 00045 #define EM_386 3 00046 00047 00048 struct coff_header{ 00049 unsigned short f_magic; /* magic number */ 00050 unsigned short f_nscns; /* number of sections */ 00051 unsigned long f_timdat; /* time & date stamp */ 00052 unsigned long f_symptr; /* file pointer to symtab */ 00053 unsigned long f_nsyms; /* number of symtab entries */ 00054 unsigned short f_opthdr; /* sizeof(optional hdr) */ 00055 unsigned short f_flags; /* flags */ 00056 }; 00057 00058 // Valor de f_magic para un COFF32 00059 #define COFF32_TYPE 0x14c 00060 00061 struct coff_sections{ 00062 char s_name[8]; /* section name */ 00063 unsigned long s_paddr; /* physical address, aliased s_nlib */ 00064 unsigned long s_vaddr; /* virtual address */ 00065 unsigned long s_size; /* section size */ 00066 unsigned long s_scnptr; /* file ptr to raw data for section */ 00067 unsigned long s_relptr; /* file ptr to relocation */ 00068 unsigned long s_lnnoptr; /* file ptr to line numbers */ 00069 unsigned short s_nreloc; /* number of relocation entries */ 00070 unsigned short s_nlnno; /* number of line number entries */ 00071 unsigned long s_flags; /* flags */ 00072 } ; 00073 00074 #define COFF32_TEXT 0x20 00075 #define COFF32_DATA 0x40 00076 #define COFF32_BSS 0x80 00077