ARMv7 decoder reworked (needs more testing / fixes / optimisations). TODO: implement new ARMv7 disassembler (currently ARMv7DisAsm fully disabled), add 0x0 opcodes group.

This commit is contained in:
Oil 2014-12-01 23:20:27 +04:00
parent b736b8616b
commit c3696f7897
10 changed files with 3628 additions and 1805 deletions

View file

@ -10,14 +10,19 @@ namespace loader
{
for (auto i : m_handlers)
{
if (i->init(stream) == handler::ok)
i->set_status(i->init(stream));
if (i->get_status() == handler::ok)
{
if (i->load() == handler::ok)
i->set_status(i->load());
if (i->get_status() == handler::ok)
{
return true;
}
LOG_ERROR(LOADER, "loader::load() failed: %s", i->get_error_code().c_str());
}
LOG_ERROR(LOADER, "loader::init() failed: %s", i->get_error_code().c_str());
stream.Seek(i->get_stream_offset());
}

View file

@ -15,7 +15,7 @@ enum Elf_Machine
MACHINE_MIPS = 0x08,
MACHINE_PPC64 = 0x15,
MACHINE_SPU = 0x17,
MACHINE_ARM = 0x28,
MACHINE_ARM = 0x28
};
enum ShdrType
@ -31,7 +31,7 @@ enum ShdrType
SHT_NOBITS,
SHT_REL,
SHT_SHLIB,
SHT_DYNSYM,
SHT_DYNSYM
};
enum ShdrFlag
@ -39,7 +39,7 @@ enum ShdrFlag
SHF_WRITE = 0x1,
SHF_ALLOC = 0x2,
SHF_EXECINSTR = 0x4,
SHF_MASKPROC = 0xf0000000,
SHF_MASKPROC = 0xf0000000
};
const std::string Ehdr_DataToString(const u8 data);
@ -117,7 +117,7 @@ namespace loader
broken_file = -3,
loading_error = -4,
bad_relocation_type = -5,
ok = 0,
ok = 0
};
virtual ~handler() = default;
@ -128,6 +128,34 @@ namespace loader
{
return m_stream_offset;
}
void set_status(const error_code& code)
{
m_status = code;
}
error_code get_status() const
{
return m_status;
}
const std::string get_error_code() const
{
switch (m_status)
{
case bad_version: return "Bad version";
case bad_file: return "Bad file";
case broken_file: return "Broken file";
case loading_error: return "Loading error";
case bad_relocation_type: return "Bad relocation type";
case ok: return "Ok";
default: return "Unknown error code";
}
}
protected:
error_code m_status;
};
class loader