KernelState should handle module launching
This commit is contained in:
@@ -53,6 +53,11 @@ struct elf32_phdr {
|
||||
xe::be<uint32_t> p_align;
|
||||
};
|
||||
|
||||
bool ElfModule::is_executable() const {
|
||||
auto hdr = reinterpret_cast<const elf32_ehdr*>(elf_header_mem_.data());
|
||||
return hdr->e_entry != 0;
|
||||
}
|
||||
|
||||
bool ElfModule::Load(const std::string& name, const std::string& path,
|
||||
const void* elf_addr, size_t elf_length) {
|
||||
name_ = name;
|
||||
|
||||
@@ -31,6 +31,7 @@ class ElfModule : public xe::cpu::Module {
|
||||
bool loaded() const { return loaded_; }
|
||||
uint32_t entry_point() const { return entry_point_; }
|
||||
const std::string& name() const override { return name_; }
|
||||
bool is_executable() const override;
|
||||
const std::string& path() const { return path_; }
|
||||
|
||||
bool Load(const std::string& name, const std::string& path,
|
||||
|
||||
@@ -34,6 +34,7 @@ class Module {
|
||||
Memory* memory() const { return memory_; }
|
||||
|
||||
virtual const std::string& name() const = 0;
|
||||
virtual bool is_executable() const = 0;
|
||||
|
||||
virtual bool ContainsAddress(uint32_t address);
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ class BuiltinModule : public Module {
|
||||
: Module(processor), name_("builtin") {}
|
||||
|
||||
const std::string& name() const override { return name_; }
|
||||
bool is_executable() const override { return false; }
|
||||
|
||||
bool ContainsAddress(uint32_t address) override {
|
||||
return (address & 0xFFFFFFF0) == 0xFFFFFFF0;
|
||||
|
||||
@@ -29,7 +29,9 @@ class RawModule : public Module {
|
||||
void SetAddressRange(uint32_t base_address, uint32_t size);
|
||||
|
||||
const std::string& name() const override { return name_; }
|
||||
bool is_executable() const override { return is_executable_; }
|
||||
void set_name(const std::string& name) { name_ = name; }
|
||||
void set_executable(bool is_executable) { is_executable_ = is_executable; }
|
||||
|
||||
bool ContainsAddress(uint32_t address) override;
|
||||
|
||||
@@ -38,6 +40,7 @@ class RawModule : public Module {
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
bool is_executable_ = false;
|
||||
uint32_t base_address_;
|
||||
uint32_t low_address_;
|
||||
uint32_t high_address_;
|
||||
|
||||
@@ -30,6 +30,7 @@ class TestModule : public Module {
|
||||
~TestModule() override;
|
||||
|
||||
const std::string& name() const override { return name_; }
|
||||
bool is_executable() const override { return false; }
|
||||
|
||||
bool ContainsAddress(uint32_t address) override;
|
||||
|
||||
|
||||
@@ -75,6 +75,9 @@ class XexModule : public xe::cpu::Module {
|
||||
bool Unload();
|
||||
|
||||
const std::string& name() const override { return name_; }
|
||||
bool is_executable() const override {
|
||||
return (xex_header()->module_flags & XEX_MODULE_TITLE) != 0;
|
||||
}
|
||||
|
||||
bool ContainsAddress(uint32_t address) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user