src/Emu/Utility/System/Loader/ELF64.h

説明を見る。
00001 // 
00002 // Copyright (c) 2005-2008 Kenichi Watanabe.
00003 // Copyright (c) 2005-2008 Yasuhiro Watari.
00004 // Copyright (c) 2005-2008 Hironori Ichibayashi.
00005 // Copyright (c) 2008-2009 Kazuo Horio.
00006 // Copyright (c) 2009-2013 Naruki Kurata.
00007 // Copyright (c) 2005-2013 Ryota Shioya.
00008 // Copyright (c) 2005-2013 Masahiro Goshima.
00009 // 
00010 // This software is provided 'as-is', without any express or implied
00011 // warranty. In no event will the authors be held liable for any damages
00012 // arising from the use of this software.
00013 // 
00014 // Permission is granted to anyone to use this software for any purpose,
00015 // including commercial applications, and to alter it and redistribute it
00016 // freely, subject to the following restrictions:
00017 // 
00018 // 1. The origin of this software must not be misrepresented; you must not
00019 // claim that you wrote the original software. If you use this software
00020 // in a product, an acknowledgment in the product documentation would be
00021 // appreciated but is not required.
00022 // 
00023 // 2. Altered source versions must be plainly marked as such, and must not be
00024 // misrepresented as being the original software.
00025 // 
00026 // 3. This notice may not be removed or altered from any source
00027 // distribution.
00028 // 
00029 // 
00030 
00031 
00032 #ifndef __EMULATORUTILITY_ELF64_H__
00033 #define __EMULATORUTILITY_ELF64_H__
00034 
00035 namespace Onikiri {
00036     namespace EmulatorUtility {
00037 
00038         namespace ELF64 {
00039 
00040             // ELF Header
00041             struct ELF64_HEADER
00042             {
00043                 u8  e_ident[16];
00044                 u16 e_type;
00045                 u16 e_machine;
00046                 u32 e_version;
00047                 u64 e_entry;
00048                 u64 e_phoff;
00049                 u64 e_shoff;
00050                 u32 e_flags;
00051                 u16 e_ehsize;
00052                 u16 e_phentsize;
00053                 u16 e_phnum;
00054                 u16 e_shentsize;
00055                 u16 e_shnum;
00056                 u16 e_shstrndx;
00057             };
00058 
00059             // ELF Section
00060             struct ELF64_SECTION
00061             {
00062                 u32 sh_name;
00063                 u32 sh_type;
00064                 u64 sh_flags;
00065                 u64 sh_addr;
00066                 u64 sh_offset;
00067                 u64 sh_size;
00068                 u32 sh_link;
00069                 u32 sh_info;
00070                 u64 sh_addralign;
00071                 u64 sh_entsize;
00072             };
00073 
00074             // ELF Program Header
00075             struct ELF64_PROGRAM
00076             {
00077                 u32 p_type;
00078                 u32 p_flags;
00079                 u64 p_offset;
00080                 u64 p_vaddr;
00081                 u64 p_paddr;
00082                 u64 p_filesz;
00083                 u64 p_memsz;
00084                 u64 p_align;
00085             };
00086 
00087             // auxiliary vector
00088             struct ELF64_AUXV
00089             {
00090                 s64 a_type;
00091                 union
00092                 {
00093                     s64 a_val;
00094 
00095                     // 32bit/64bit |C^CgpD
00096                     //void *a_ptr;
00097                     //void (*a_fcn) (void);
00098                 } a_un;
00099             };
00100         }   // namespace ELF64
00101 
00102         namespace ELF {
00103             // section type
00104             const u32 SHT_NOBITS = 8;
00105 
00106             // section flag
00107             const int SHF_WRITE     = 1 << 0;
00108             const int SHF_ALLOC     = 1 << 1;
00109             const int SHF_EXECINSTR = 1 << 2;
00110 
00111             // segment type
00112             const u32 PT_LOAD = 1;
00113 
00114             // segment flag
00115             const int PF_X = (1 << 0);
00116             const int PF_W = (1 << 1);
00117             const int PF_R = (1 << 2);
00118 
00119             // ident index
00120             const int EI_CLASS = 4;
00121             const int EI_DATA = 5;
00122             const int EI_VERSION = 6;
00123 
00124             // a_type
00125             const int AT_NULL = 0;
00126             const int AT_IGNORE = 1;
00127             const int AT_EXECFD = 2;
00128             const int AT_PHDR = 3;
00129             const int AT_PHENT = 4;
00130             const int AT_PHNUM = 5;
00131             const int AT_PAGESZ = 6;
00132             const int AT_BASE = 7;
00133             const int AT_FLAGS = 8;
00134             const int AT_ENTRY = 9;
00135             const int AT_NOTELF = 10;
00136             const int AT_UID = 11;
00137             const int AT_EUID = 12;
00138             const int AT_GID = 13;
00139             const int AT_EGID = 14;
00140             //const int AT_DCACHEBSIZE = 19;    // (PowerPC) Data Cache Block Size
00141         
00142         }   // namespace ELF
00143 
00144         using namespace ELF64;
00145         using namespace ELF;
00146 
00147     } // EmulatorUtility
00148 
00149     void EndianSpecifiedToHostInPlace(EmulatorUtility::ELF64_HEADER& h, bool bigEndian);
00150     void EndianSpecifiedToHostInPlace(EmulatorUtility::ELF64_SECTION& h, bool bigEndian);
00151     void EndianSpecifiedToHostInPlace(EmulatorUtility::ELF64_PROGRAM& h, bool bigEndian);
00152 } // namespace Onikiri
00153 #endif

Onikiri2に対してTue Jun 18 14:34:20 2013に生成されました。  doxygen 1.4.7