iPXE
elf.h
Go to the documentation of this file.
00001 #ifndef ELF_H
00002 #define ELF_H
00003 
00004 /**
00005  * @file
00006  *
00007  * ELF headers
00008  *
00009  */
00010 
00011 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00012 
00013 #include <stdint.h>
00014 
00015 typedef uint32_t Elf32_Addr;
00016 typedef uint16_t Elf32_Half;
00017 typedef uint32_t Elf32_Off;
00018 typedef int32_t Elf32_Sword;
00019 typedef uint32_t Elf32_Word;
00020 
00021 /** Length of ELF identifier */
00022 #define EI_NIDENT 16
00023 
00024 /** ELF header */
00025 typedef struct {
00026         unsigned char e_ident[EI_NIDENT];
00027         Elf32_Half e_type;
00028         Elf32_Half e_machine;
00029         Elf32_Word e_version;
00030         Elf32_Addr e_entry;
00031         Elf32_Off e_phoff;
00032         Elf32_Off e_shoff;
00033         Elf32_Word e_flags;
00034         Elf32_Half e_ehsize;
00035         Elf32_Half e_phentsize;
00036         Elf32_Half e_phnum;
00037         Elf32_Half e_shentsize;
00038         Elf32_Half e_shnum;
00039         Elf32_Half e_shstrndx;
00040 } Elf32_Ehdr;
00041 
00042 /* ELF identifier indexes */
00043 #define EI_MAG0 0
00044 #define EI_MAG1 1
00045 #define EI_MAG2 2
00046 #define EI_MAG3 3
00047 #define EI_CLASS 4
00048 #define EI_DATA 5
00049 #define EI_VERSION 6
00050 
00051 /* ELF magic signature bytes */
00052 #define ELFMAG0 0x7f
00053 #define ELFMAG1 'E'
00054 #define ELFMAG2 'L'
00055 #define ELFMAG3 'F'
00056 
00057 /* ELF classes */
00058 #define ELFCLASS32 1
00059 
00060 /* ELF data encodings */
00061 #define ELFDATA2LSB 1
00062 
00063 /* ELF versions */
00064 #define EV_CURRENT 1
00065 
00066 /** ELF program header */
00067 typedef struct {
00068         Elf32_Word p_type;
00069         Elf32_Off p_offset;
00070         Elf32_Addr p_vaddr;
00071         Elf32_Addr p_paddr;
00072         Elf32_Word p_filesz;
00073         Elf32_Word p_memsz;
00074         Elf32_Word p_flags;
00075         Elf32_Word p_align;
00076 } Elf32_Phdr;
00077 
00078 /* ELF segment types */
00079 #define PT_LOAD 1
00080 
00081 #endif /* ELF_H */