#ifndef liblldb_ObjectFileELF_h_
#define liblldb_ObjectFileELF_h_
#include <stdint.h>
#include <vector>
#include "lldb/lldb-private.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Symbol/ObjectFile.h"
#include "ELFHeader.h"
class ObjectFileELF :
public lldb_private::ObjectFile
{
public:
static void
Initialize();
static void
Terminate();
static const char *
GetPluginNameStatic();
static const char *
GetPluginDescriptionStatic();
static lldb_private::ObjectFile *
CreateInstance(const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& dataSP,
const lldb_private::FileSpec* file,
lldb::addr_t offset,
lldb::addr_t length);
static lldb_private::ObjectFile *
CreateMemoryInstance (const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& data_sp,
const lldb::ProcessSP &process_sp,
lldb::addr_t header_addr);
virtual const char *
GetPluginName();
virtual const char *
GetShortPluginName();
virtual uint32_t
GetPluginVersion();
virtual
~ObjectFileELF();
virtual bool
ParseHeader();
virtual lldb::ByteOrder
GetByteOrder() const;
virtual bool
IsExecutable () const;
virtual size_t
GetAddressByteSize() const;
virtual lldb_private::Symtab *
GetSymtab();
virtual lldb_private::SectionList *
GetSectionList();
virtual void
Dump(lldb_private::Stream *s);
virtual bool
GetArchitecture (lldb_private::ArchSpec &arch);
virtual bool
GetUUID(lldb_private::UUID* uuid);
virtual uint32_t
GetDependentModules(lldb_private::FileSpecList& files);
virtual lldb_private::Address
GetImageInfoAddress();
virtual lldb_private::Address
GetEntryPointAddress ();
virtual ObjectFile::Type
CalculateType();
virtual ObjectFile::Strata
CalculateStrata();
private:
ObjectFileELF(const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& dataSP,
const lldb_private::FileSpec* file,
lldb::addr_t offset,
lldb::addr_t length);
typedef std::vector<elf::ELFProgramHeader> ProgramHeaderColl;
typedef ProgramHeaderColl::iterator ProgramHeaderCollIter;
typedef ProgramHeaderColl::const_iterator ProgramHeaderCollConstIter;
typedef std::vector<elf::ELFSectionHeader> SectionHeaderColl;
typedef SectionHeaderColl::iterator SectionHeaderCollIter;
typedef SectionHeaderColl::const_iterator SectionHeaderCollConstIter;
typedef std::vector<elf::ELFDynamic> DynamicSymbolColl;
typedef DynamicSymbolColl::iterator DynamicSymbolCollIter;
typedef DynamicSymbolColl::const_iterator DynamicSymbolCollConstIter;
static const uint32_t m_plugin_version = 1;
elf::ELFHeader m_header;
ProgramHeaderColl m_program_headers;
SectionHeaderColl m_section_headers;
DynamicSymbolColl m_dynamic_symbols;
mutable std::auto_ptr<lldb_private::SectionList> m_sections_ap;
mutable std::auto_ptr<lldb_private::Symtab> m_symtab_ap;
mutable std::auto_ptr<lldb_private::FileSpecList> m_filespec_ap;
lldb_private::DataExtractor m_shstr_data;
lldb_private::Address m_entry_point_address;
unsigned
SectionIndex(const SectionHeaderCollIter &I);
unsigned
SectionIndex(const SectionHeaderCollConstIter &I) const;
size_t
ParseProgramHeaders();
size_t
ParseSectionHeaders();
size_t
ParseDependentModules();
size_t
ParseDynamicSymbols();
unsigned
ParseSymbolTable(lldb_private::Symtab *symbol_table,
lldb::user_id_t start_id,
const elf::ELFSectionHeader *symtab_section,
lldb::user_id_t symtab_id);
unsigned
ParseTrampolineSymbols(lldb_private::Symtab *symbol_table,
lldb::user_id_t start_id,
const elf::ELFSectionHeader *rela_hdr,
lldb::user_id_t section_id);
size_t
GetSectionHeaderStringTable();
lldb::user_id_t
GetSectionIndexByName(const char *name);
lldb::user_id_t
GetSectionIndexByType(unsigned type);
const elf::ELFSectionHeader *
GetSectionHeaderByIndex(lldb::user_id_t id);
static void
DumpELFHeader(lldb_private::Stream *s, const elf::ELFHeader& header);
static void
DumpELFHeader_e_ident_EI_DATA(lldb_private::Stream *s,
unsigned char ei_data);
static void
DumpELFHeader_e_type(lldb_private::Stream *s, elf::elf_half e_type);
void
DumpELFProgramHeaders(lldb_private::Stream *s);
static void
DumpELFProgramHeader(lldb_private::Stream *s,
const elf::ELFProgramHeader &ph);
static void
DumpELFProgramHeader_p_type(lldb_private::Stream *s, elf::elf_word p_type);
static void
DumpELFProgramHeader_p_flags(lldb_private::Stream *s,
elf::elf_word p_flags);
void
DumpELFSectionHeaders(lldb_private::Stream *s);
static void
DumpELFSectionHeader(lldb_private::Stream *s,
const elf::ELFSectionHeader& sh);
static void
DumpELFSectionHeader_sh_type(lldb_private::Stream *s,
elf::elf_word sh_type);
static void
DumpELFSectionHeader_sh_flags(lldb_private::Stream *s,
elf::elf_word sh_flags);
void
DumpDependentModules(lldb_private::Stream *s);
const elf::ELFDynamic *
FindDynamicSymbol(unsigned tag);
lldb_private::Section *
PLTSection();
unsigned
PLTRelocationType();
};
#endif // #ifndef liblldb_ObjectFileELF_h_