クラス Onikiri::EmulatorUtility::ElfReader

#include <ElfReader.h>

Onikiri::EmulatorUtility::ElfReaderのコラボレーション図

Collaboration graph
[凡例]
すべてのメンバ一覧

Public 型

typedef u64 Elf_Addr
typedef ELF64_HEADER Elf_Ehdr
typedef u64 Elf_Off
typedef ELF64_PROGRAM Elf_Phdr
typedef ELF64_SECTION Elf_Shdr
typedef u32 Elf_Word
typedef std::streamsize streamsize

Public メソッド

void Close ()
 ElfReader ()
int FindSection (const char *name) const
int GetClass () const
int GetDataEncoding () const
Elf_Addr GetEntryPoint () const
streamsize GetImageSize () const
u16 GetMachine () const
const Elf_PhdrGetProgramHeader (int index) const
int GetProgramHeaderCount () const
Elf_Off GetProgramHeaderOffset () const
const Elf_ShdrGetSectionHeader (int index) const
int GetSectionHeaderCount () const
Elf_Off GetSectionHeaderOffset () const
const char * GetSectionName (int index) const
int GetVersion () const
bool IsBigEndian () const
void Open (const char *name)
void ReadImage (char *buf, size_t buf_size) const
void ReadRange (size_t offset, char *buf, size_t buf_size) const
void ReadSectionBody (int index, char *buf, size_t buf_size) const
 ~ElfReader ()

説明

ElfReader.h45 行で定義されています。


型定義

typedef u64 Onikiri::EmulatorUtility::ElfReader::Elf_Addr

ElfReader.h51 行で定義されています。

typedef ELF64_HEADER Onikiri::EmulatorUtility::ElfReader::Elf_Ehdr

ElfReader.h48 行で定義されています。

typedef u64 Onikiri::EmulatorUtility::ElfReader::Elf_Off

ElfReader.h53 行で定義されています。

typedef ELF64_PROGRAM Onikiri::EmulatorUtility::ElfReader::Elf_Phdr

ElfReader.h50 行で定義されています。

typedef ELF64_SECTION Onikiri::EmulatorUtility::ElfReader::Elf_Shdr

ElfReader.h49 行で定義されています。

typedef u32 Onikiri::EmulatorUtility::ElfReader::Elf_Word

ElfReader.h52 行で定義されています。

typedef std::streamsize Onikiri::EmulatorUtility::ElfReader::streamsize

ElfReader.h55 行で定義されています。


コンストラクタとデストラクタ

ElfReader::ElfReader (  )  [explicit]

ElfReader.cpp47 行で定義されています。

00048 {
00049     m_sectionNameTable = 0;
00050     m_bigEndian = false;
00051 }

ElfReader::~ElfReader (  ) 

ElfReader.cpp53 行で定義されています。

00054 {
00055     delete[] m_sectionNameTable;
00056 }


関数

void ElfReader::Close (  ) 

ElfReader.cpp183 行で定義されています。

00184 {
00185     m_file.close();
00186 }

int ElfReader::FindSection ( const char *  name  )  const

ElfReader.cpp213 行で定義されています。

参照先 GetSectionHeaderCount()GetSectionName().

00214 {
00215     for (int i = 0; i < GetSectionHeaderCount(); i++) {
00216         if (strcmp(GetSectionName(i), name) == 0)
00217             return i;
00218     }
00219 
00220     return -1;
00221 }

関数の呼び出しグラフ:

int ElfReader::GetClass (  )  const

ElfReader.cpp243 行で定義されています。

参照先 Onikiri::EmulatorUtility::ELF::EI_CLASS.

00244 {
00245     return m_elfHeader.e_ident[EI_CLASS];
00246 }

int ElfReader::GetDataEncoding (  )  const

ElfReader.cpp248 行で定義されています。

参照先 Onikiri::EmulatorUtility::ELF::EI_DATA.

00249 {
00250     return m_elfHeader.e_ident[EI_DATA];
00251 }

ElfReader::Elf_Addr ElfReader::GetEntryPoint (  )  const

ElfReader.cpp268 行で定義されています。

参照元 Onikiri::EmulatorUtility::Linux64Loader::CalculateEntryPoint()Onikiri::PPC64Linux::PPC64LinuxLoader::CalculateEntryPoint()Onikiri::PPC64Linux::PPC64LinuxLoader::CalculateOthers().

00269 {
00270     return m_elfHeader.e_entry;
00271 }

Here is the caller graph for this function:

streamsize ElfReader::GetImageSize (  )  const

ElfReader.cpp223 行で定義されています。

参照元 ReadImage().

00224 {
00225     m_file.seekg(0, ios_base::end);
00226     return m_file.tellg();
00227 }

Here is the caller graph for this function:

u16 ElfReader::GetMachine (  )  const

ElfReader.cpp258 行で定義されています。

参照元 Onikiri::EmulatorUtility::Linux64Loader::LoadBinary().

00259 {
00260     return m_elfHeader.e_machine;
00261 }

Here is the caller graph for this function:

const ElfReader::Elf_Phdr & ElfReader::GetProgramHeader ( int  index  )  const

ElfReader.cpp299 行で定義されています。

参照元 Onikiri::EmulatorUtility::Linux64Loader::LoadBinary().

00300 {
00301     return m_elfProgramHeaders[index];
00302 }

Here is the caller graph for this function:

int ElfReader::GetProgramHeaderCount (  )  const

ElfReader.cpp289 行で定義されています。

参照元 Onikiri::EmulatorUtility::Linux64Loader::LoadBinary().

00290 {
00291     return (int)m_elfProgramHeaders.size();
00292 }

Here is the caller graph for this function:

ElfReader::Elf_Off ElfReader::GetProgramHeaderOffset (  )  const

ElfReader.cpp278 行で定義されています。

参照元 Onikiri::EmulatorUtility::Linux64Loader::LoadBinary().

00279 {
00280     return m_elfHeader.e_phoff;
00281 }

Here is the caller graph for this function:

const ElfReader::Elf_Shdr & ElfReader::GetSectionHeader ( int  index  )  const

ElfReader.cpp294 行で定義されています。

参照元 GetSectionName()ReadSectionBody().

00295 {
00296     return m_elfSectionHeaders[index];
00297 }

Here is the caller graph for this function:

int ElfReader::GetSectionHeaderCount (  )  const

ElfReader.cpp283 行で定義されています。

参照元 FindSection().

00284 {
00285     // XElf32_Half = 16bit
00286     return (int)m_elfSectionHeaders.size();
00287 }

Here is the caller graph for this function:

ElfReader::Elf_Off ElfReader::GetSectionHeaderOffset (  )  const

ElfReader.cpp273 行で定義されています。

00274 {
00275     return m_elfHeader.e_shoff;
00276 }

const char * ElfReader::GetSectionName ( int  index  )  const

ElfReader.cpp206 行で定義されています。

参照先 GetSectionHeader()Onikiri::EmulatorUtility::ELF64::ELF64_SECTION::sh_name.

参照元 FindSection().

00207 {
00208     const Elf_Shdr &sh = GetSectionHeader(index);
00209 
00210     return m_sectionNameTable + sh.sh_name;
00211 }

関数の呼び出しグラフ:

Here is the caller graph for this function:

int ElfReader::GetVersion (  )  const

ElfReader.cpp253 行で定義されています。

参照先 Onikiri::EmulatorUtility::ELF::EI_VERSION.

00254 {
00255     return m_elfHeader.e_ident[EI_VERSION];
00256 }

bool ElfReader::IsBigEndian (  )  const

ElfReader.cpp263 行で定義されています。

参照元 Onikiri::EmulatorUtility::Linux64Loader::LoadBinary().

00264 {
00265     return m_bigEndian;
00266 }

Here is the caller graph for this function:

void ElfReader::Open ( const char *  name  ) 

ElfReader.cpp58 行で定義されています。

参照元 Onikiri::EmulatorUtility::Linux64Loader::LoadBinary().

00059 {
00060     m_file.open(name, ios_base::in | ios_base::binary);
00061     if (m_file.fail()) {
00062         stringstream ss;
00063         ss << "'" << name << "' : cannot open file";
00064         throw runtime_error(ss.str());
00065     }
00066 
00067     try {
00068         ReadELFHeader();
00069         ReadSectionHeaders();
00070         ReadProgramHeaders();
00071         ReadSectionNameTable();
00072     }
00073     catch (runtime_error& e) {
00074         m_file.close();
00075 
00076         stringstream ss;
00077         ss << "'" << name << "' : " << e.what();
00078         throw runtime_error(ss.str());
00079     }
00080 }

Here is the caller graph for this function:

void ElfReader::ReadImage ( char *  buf,
size_t  buf_size 
) const

ElfReader.cpp229 行で定義されています。

参照先 GetImageSize().

00230 {
00231     streamsize size = GetImageSize();
00232     if ((streamsize)buf_size < size)
00233         throw runtime_error("read error");
00234 
00235     m_file.seekg(0, ios_base::beg);
00236     m_file.read(buf, static_cast<std::streamoff>(size));
00237 
00238     if (m_file.fail())
00239         throw runtime_error("read error");
00240 }

関数の呼び出しグラフ:

void ElfReader::ReadRange ( size_t  offset,
char *  buf,
size_t  buf_size 
) const

ElfReader.cpp197 行で定義されています。

参照元 Onikiri::EmulatorUtility::Linux64Loader::LoadBinary()ReadSectionBody().

00198 {
00199     m_file.seekg(static_cast<istream::off_type>(offset), ios_base::beg);
00200     m_file.read(buf, static_cast<std::streamsize>(buf_size));
00201 
00202     if (m_file.fail())
00203         throw runtime_error("read error");
00204 }

Here is the caller graph for this function:

void ElfReader::ReadSectionBody ( int  index,
char *  buf,
size_t  buf_size 
) const

ElfReader.cpp188 行で定義されています。

参照先 GetSectionHeader()ReadRange()Onikiri::EmulatorUtility::ELF64::ELF64_SECTION::sh_offsetOnikiri::EmulatorUtility::ELF64::ELF64_SECTION::sh_size.

00189 {
00190     const Elf_Shdr &sh = GetSectionHeader(index);
00191     if (buf_size != sh.sh_size)
00192         throw runtime_error("not enough buffer");
00193 
00194     ReadRange((size_t)sh.sh_offset, buf, (size_t)sh.sh_size);
00195 }

関数の呼び出しグラフ:


このクラスの説明は次のファイルから生成されました:
Onikiri2に対してTue Jun 18 15:25:39 2013に生成されました。  doxygen 1.4.7