From 5c5cf2f8e000d1bf4fc12ff20351aa60367cb563 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Thu, 9 Jul 2015 22:52:15 -0300 Subject: Core: Properly configure address space when loading a binary The code now properly configures the process image to match the loaded binary segments (code, rodata, data) instead of just blindly allocating a large chunk of dummy memory. --- src/core/hle/kernel/process.h | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) (limited to 'src/core/hle/kernel/process.h') diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 674f5093..92fa0fa6 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -47,23 +47,51 @@ union ProcessFlags { }; class ResourceLimit; +class VMManager; + +struct CodeSet final : public Object { + static SharedPtr Create(std::string name, u64 program_id); + + std::string GetTypeName() const override { return "CodeSet"; } + std::string GetName() const override { return name; } + + static const HandleType HANDLE_TYPE = HandleType::CodeSet; + HandleType GetHandleType() const override { return HANDLE_TYPE; } + + /// Name of the process + std::string name; + /// Title ID corresponding to the process + u64 program_id; + + std::shared_ptr> memory; + + struct Segment { + size_t offset = 0; + VAddr addr = 0; + u32 size = 0; + }; + + Segment code, rodata, data; + VAddr entrypoint; + +private: + CodeSet(); + ~CodeSet() override; +}; class Process final : public Object { public: - static SharedPtr Create(std::string name, u64 program_id); + static SharedPtr Create(SharedPtr code_set); std::string GetTypeName() const override { return "Process"; } - std::string GetName() const override { return name; } + std::string GetName() const override { return codeset->name; } static const HandleType HANDLE_TYPE = HandleType::Process; HandleType GetHandleType() const override { return HANDLE_TYPE; } static u32 next_process_id; - /// Name of the process - std::string name; - /// Title ID corresponding to the process - u64 program_id; + SharedPtr codeset; /// Resource limit descriptor for this process SharedPtr resource_limit; @@ -81,6 +109,7 @@ public: /// Bitmask of the used TLS slots std::bitset<300> used_tls_slots; + std::unique_ptr address_space; /** * Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them @@ -91,7 +120,7 @@ public: /** * Applies address space changes and launches the process main thread. */ - void Run(VAddr entry_point, s32 main_thread_priority, u32 stack_size); + void Run(s32 main_thread_priority, u32 stack_size); private: Process(); -- cgit v1.2.3