Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

ElfAnalyser Class Reference

#include <elf_analy.h>

Inheritance diagram for ElfAnalyser:

Analyser Object List of all members.

Public Member Functions

void init (ht_elf_shared_data *elf_shared, ht_streamfile *File)
int load (ht_object_stream *f)
virtual void done ()
virtual OBJECT_ID object_id () const
virtual void beginAnalysis ()
virtual uint bufPtr (Address *Addr, byte *buf, int size)
bool convertAddressToELFAddress (Address *addr, ELFAddress *r)
virtual AddresscreateAddress ()
AddresscreateAddress32 (dword addr)
AddresscreateAddress64 (qword addr)
virtual AssemblercreateAssembler ()
virtual const char * getName ()
virtual const char * getType ()
virtual void initCodeAnalyser ()
void initInsertSymbols (int shidx)
void initInsertFakeSymbols ()
virtual void initUnasm ()
virtual void log (const char *msg)
virtual AddressnextValid (Address *Addr)
virtual void store (ht_object_stream *f)
virtual int queryConfig (int mode)
virtual bool validAddress (Address *Addr, tsectype action)
virtual AddressfileofsToAddress (FILEOFS fileofs)
virtual FILEOFS addressToFileofs (Address *Addr)
virtual char * getSegmentNameByAddress (Address *Addr)

Public Attributes

ht_elf_shared_dataelf_shared
ht_streamfilefile
Areavalidarea

Member Function Documentation

FILEOFS ElfAnalyser::addressToFileofs Address Addr  )  [virtual]
 

Implements Analyser.

Definition at line 538 of file elf_analy.cc.

References convertAddressToELFAddress(), dword, ELF_HEADER::e_ident, elf_addr_to_ofs(), ELF_EI_CLASS, elf_shared, FILEOFS, ht_elf_shared_data::ident, INVALID_FILE_OFS, scinitialized, ht_elf_shared_data::sheaders, and validAddress().

Referenced by bufPtr().

void ElfAnalyser::beginAnalysis  )  [virtual]
 

Reimplemented from Analyser.

Definition at line 63 of file elf_analy.cc.

References Area::add(), Address::add(), Analyser::addComment(), AF_FUNCTION_END, Analyser::assignSymbol(), Analyser::beginAnalysis(), elf_section_headers::count, createAddress32(), createAddress64(), Object::duplicate(), ELF_HEADER64::e_entry, ELF_HEADER32::e_entry, ELF_HEADER::e_ident, ELF_HEADER64::e_type, ELF_HEADER32::e_type, ELF_EI_CLASS, ELF_ET_DYN, ELF_ET_EXEC, elf_shared, ELF_SHT_DYNSYM, ELF_SHT_SYMTAB, ELFCLASS32, ELFCLASS64, Location::flags, getSegmentNameByAddress(), ht_elf_shared_data::header32, ht_elf_shared_data::header64, ht_snprintf(), ht_elf_shared_data::ident, initInsertFakeSymbols(), initInsertSymbols(), label_func, Analyser::newLocation(), NULL, Analyser::pushAddress(), scinitialized, scvalid, Analyser::setLocationTreeOptimizeThreshold(), Analyser::setSymbolTreeOptimizeThreshold(), ELF_SECTION_HEADER64::sh_addr, ELF_SECTION_HEADER32::sh_addr, ELF_SECTION_HEADER32::sh_offset, ELF_SECTION_HEADER64::sh_size, ELF_SECTION_HEADER32::sh_size, ELF_SECTION_HEADER64::sh_type, ELF_SECTION_HEADER32::sh_type, ht_elf_shared_data::sheaders, elf_section_headers::sheaders32, elf_section_headers::sheaders64, uint, validAddress(), and validarea.

uint ElfAnalyser::bufPtr Address Addr,
byte *  buf,
int  size
[virtual]
 

Implements Analyser.

Definition at line 458 of file elf_analy.cc.

References addressToFileofs(), assert, buf, file, FILEOFS, INVALID_FILE_OFS, ht_stream::read(), ht_streamfile::seek(), size, and uint.

bool ElfAnalyser::convertAddressToELFAddress Address addr,
ELFAddress r
 

Definition at line 469 of file elf_analy.cc.

References ELFAddress::a32, ELFAddress::a64, ATOM_ADDRESS_FLAT_32, ATOM_ADDRESS_FLAT_64, ATOM_ADDRESS_X86_FLAT_32, and Object::object_id().

Referenced by addressToFileofs(), getSegmentNameByAddress(), and validAddress().

Address * ElfAnalyser::createAddress  )  [virtual]
 

Implements Analyser.

Definition at line 486 of file elf_analy.cc.

References ELF_HEADER::e_ident, ELF_HEADER32::e_machine, ELF_EI_CLASS, ELF_EM_386, elf_shared, ELFCLASS32, ELFCLASS64, ht_elf_shared_data::header32, and ht_elf_shared_data::ident.

Address * ElfAnalyser::createAddress32 dword  addr  ) 
 

Definition at line 507 of file elf_analy.cc.

References ELF_HEADER32::e_machine, ELF_EM_386, elf_shared, and ht_elf_shared_data::header32.

Referenced by beginAnalysis(), fileofsToAddress(), initInsertFakeSymbols(), and initInsertSymbols().

Address * ElfAnalyser::createAddress64 qword  addr  ) 
 

Definition at line 516 of file elf_analy.cc.

Referenced by beginAnalysis(), fileofsToAddress(), and initInsertSymbols().

Assembler * ElfAnalyser::createAssembler  )  [virtual]
 

Reimplemented from Analyser.

Definition at line 524 of file elf_analy.cc.

References ELF_HEADER32::e_machine, ELF_EM_386, elf_shared, ht_elf_shared_data::header32, Object::init(), NULL, X86_ADDRSIZE32, and X86_OPSIZE32.

void ElfAnalyser::done  )  [virtual]
 

Reimplemented from Analyser.

Definition at line 443 of file elf_analy.cc.

References Analyser::done(), Area::done(), and validarea.

Address * ElfAnalyser::fileofsToAddress FILEOFS  fileofs  )  [virtual]
 

converts |FILEOFS fileaddr| to |Address|

Reimplemented from Analyser.

Definition at line 694 of file elf_analy.cc.

References ELFAddress::a32, ELFAddress::a64, createAddress32(), createAddress64(), ELF_HEADER::e_ident, ELF_EI_CLASS, elf_ofs_to_addr(), elf_shared, ELFCLASS32, ELFCLASS64, FILEOFS, ht_elf_shared_data::ident, and ht_elf_shared_data::sheaders.

const char * ElfAnalyser::getName  )  [virtual]
 

Reimplemented from Analyser.

Definition at line 575 of file elf_analy.cc.

References file, and ht_stream::get_desc().

char * ElfAnalyser::getSegmentNameByAddress Address Addr  )  [virtual]
 

Reimplemented from Analyser.

Definition at line 555 of file elf_analy.cc.

References convertAddressToELFAddress(), ELF_HEADER::e_ident, elf_addr_to_section(), ELF_EI_CLASS, elf_shared, ht_elf_shared_data::fake_undefined_shidx, ht_elf_shared_data::ident, NULL, ht_elf_shared_data::sheaders, and ht_elf_shared_data::shnames.

Referenced by beginAnalysis().

const char * ElfAnalyser::getType  )  [virtual]
 

Reimplemented from Analyser.

Definition at line 583 of file elf_analy.cc.

void ElfAnalyser::init ht_elf_shared_data elf_shared,
ht_streamfile File
 

Definition at line 52 of file elf_analy.cc.

References elf_shared, file, Analyser::init(), Area::init(), and validarea.

void ElfAnalyser::initCodeAnalyser  )  [virtual]
 

Reimplemented from Analyser.

Definition at line 591 of file elf_analy.cc.

References Analyser::initCodeAnalyser().

void ElfAnalyser::initInsertFakeSymbols  ) 
 

Definition at line 188 of file elf_analy.cc.

References Analyser::assignSymbol(), buf, ht_elf_shared_data::byte_order, create_host_struct(), createAddress32(), elf_shared, ELF_SYMBOL32_struct, ht_tree::enum_next(), fgetstrz(), file, FILEOFS, ht_snprintf(), label_func, make_valid_name(), NULL, ht_stream::read(), sectionAndIdx::secidx, ht_streamfile::seek(), ht_elf_shared_data::sheaders, elf_section_headers::sheaders32, ELF_SYMBOL32::st_name, sectionAndIdx::symidx, ht_elf_shared_data::undefined2fakeaddr, and value.

Referenced by beginAnalysis().

void ElfAnalyser::initInsertSymbols int  shidx  ) 
 

Definition at line 214 of file elf_analy.cc.

References Analyser::addComment(), Analyser::assignSymbol(), ht_elf_shared_data::byte_order, elf_section_headers::count, cplus_demangle(), create_host_struct(), createAddress32(), createAddress64(), DMGL_ANSI, DMGL_PARAMS, ELF_HEADER::e_ident, elf32_addr, ELF32_ST_BIND, ELF32_ST_TYPE, ELF64_ST_BIND, ELF64_ST_TYPE, ELF_EI_CLASS, elf_shared, ELF_SHN_ABS, ELF_SHN_COMMON, ELF_SHN_UNDEF, ELF_STB_GLOBAL, ELF_STB_LOCAL, ELF_STB_WEAK, ELF_STT_FILE, ELF_STT_FUNC, ELF_STT_NOTYPE, ELF_STT_OBJECT, ELF_STT_SECTION, ELF_SYMBOL32_struct, ELF_SYMBOL64_struct, ELFCLASS32, fgetstrz(), file, FILEOFS, Analyser::getSymbolByName(), ht_snprintf(), ht_elf_shared_data::ident, label_data, label_func, make_valid_name(), Analyser::pushAddress(), random_permutation(), ht_stream::read(), scvalid, ht_streamfile::seek(), ELF_SECTION_HEADER64::sh_link, ELF_SECTION_HEADER32::sh_link, ELF_SECTION_HEADER64::sh_offset, ELF_SECTION_HEADER32::sh_offset, ELF_SECTION_HEADER64::sh_size, ELF_SECTION_HEADER32::sh_size, ht_elf_shared_data::sheaders, elf_section_headers::sheaders32, elf_section_headers::sheaders64, ht_elf_shared_data::shrelocs, ELF_SYMBOL64::st_info, ELF_SYMBOL32::st_info, ELF_SYMBOL64::st_name, ELF_SYMBOL32::st_name, ELF_SYMBOL64::st_shndx, ELF_SYMBOL32::st_shndx, ELF_SYMBOL64::st_size, ELF_SYMBOL32::st_size, ELF_SYMBOL64::st_value, ELF_SYMBOL32::st_value, uint, and validAddress().

Referenced by beginAnalysis().

void ElfAnalyser::initUnasm  )  [virtual]
 

Implements Analyser.

Definition at line 599 of file elf_analy.cc.

References ANALYX86DISASSEMBLER_FLAGS_FLAT64, DPRINTF, ELF_HEADER::e_ident, ELF_HEADER64::e_machine, ELF_HEADER32::e_machine, ELF_EI_CLASS, ELF_EM_386, ELF_EM_IA_64, ELF_EM_PPC, ELF_EM_PPC64, elf_shared, ELFCLASS32, ELFCLASS64, errorbox, ht_elf_shared_data::header32, ht_elf_shared_data::header64, ht_elf_shared_data::ident, and warnbox.

int ElfAnalyser::load ht_object_stream f  )  [virtual]
 

loads object from object stream.

Returns:
ht_stream errorcode

Reimplemented from Analyser.

Definition at line 434 of file elf_analy.cc.

References GET_OBJECT, Analyser::load(), and validarea.

void ElfAnalyser::log const char *  msg  )  [virtual]
 

Reimplemented from Analyser.

Definition at line 649 of file elf_analy.cc.

Address * ElfAnalyser::nextValid Address Addr  )  [virtual]
 

Implements Analyser.

Definition at line 662 of file elf_analy.cc.

References Area::findNext(), and validarea.

OBJECT_ID ElfAnalyser::object_id  )  const [virtual]
 

Returns:
unique object id.

Reimplemented from Object.

Definition at line 450 of file elf_analy.cc.

References ATOM_ELF_ANALYSER.

int ElfAnalyser::queryConfig int  mode  )  [virtual]
 

Reimplemented from Analyser.

Definition at line 679 of file elf_analy.cc.

References Q_DO_ANALYSIS, Q_ENGAGE_CODE_ANALYSER, and Q_ENGAGE_DATA_ANALYSER.

void ElfAnalyser::store ht_object_stream f  )  [virtual]
 

stores object.

Reimplemented from Analyser.

Definition at line 670 of file elf_analy.cc.

References PUT_OBJECT, Analyser::store(), and validarea.

bool ElfAnalyser::validAddress Address Addr,
tsectype  action
[virtual]
 

Implements Analyser.

Definition at line 711 of file elf_analy.cc.

References byte, convertAddressToELFAddress(), ELF_HEADER::e_ident, elf_addr_to_section(), ELF_EI_CLASS, elf_shared, ELF_SHF_EXECINSTR, ELF_SHF_WRITE, ELF_SHT_PROGBITS, ELFCLASS32, ELFCLASS64, ht_elf_shared_data::ident, sccode, scinitialized, scread, screadwrite, scvalid, scwrite, ELF_SECTION_HEADER64::sh_flags, ELF_SECTION_HEADER32::sh_flags, ELF_SECTION_HEADER64::sh_type, ELF_SECTION_HEADER32::sh_type, ht_elf_shared_data::sheaders, elf_section_headers::sheaders32, and elf_section_headers::sheaders64.

Referenced by addressToFileofs(), beginAnalysis(), and initInsertSymbols().


Member Data Documentation

ht_elf_shared_data* ElfAnalyser::elf_shared
 

Definition at line 32 of file elf_analy.h.

Referenced by addressToFileofs(), beginAnalysis(), createAddress(), createAddress32(), createAssembler(), fileofsToAddress(), getSegmentNameByAddress(), init(), initInsertFakeSymbols(), initInsertSymbols(), initUnasm(), and validAddress().

ht_streamfile* ElfAnalyser::file
 

Definition at line 33 of file elf_analy.h.

Referenced by bufPtr(), getName(), init(), initInsertFakeSymbols(), and initInsertSymbols().

Area* ElfAnalyser::validarea
 

Definition at line 34 of file elf_analy.h.

Referenced by beginAnalysis(), done(), init(), load(), nextValid(), and store().


The documentation for this class was generated from the following files:
Generated on Fri May 7 21:15:55 2004 by doxygen 1.3.5