From c46093266ed30ed6120fa735246830af7979c46f Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 24 Feb 2013 11:45:16 -0800 Subject: [PATCH] Tracking code low/high addresses per module. --- src/xenia/cpu/exec_module.cc | 19 +++++++++++++++++++ src/xenia/cpu/exec_module.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/src/xenia/cpu/exec_module.cc b/src/xenia/cpu/exec_module.cc index 4df0da014..7fe5c397a 100644 --- a/src/xenia/cpu/exec_module.cc +++ b/src/xenia/cpu/exec_module.cc @@ -73,6 +73,22 @@ int ExecModule::PrepareXex(xe_xex2_ref xex) { sdb_ = shared_ptr( new sdb::XexSymbolDatabase(memory_, export_resolver_.get(), xex)); + code_addr_low_ = 0; + code_addr_high_ = 0; + const xe_xex2_header_t* header = xe_xex2_get_header(xex); + for (size_t n = 0, i = 0; n < header->section_count; n++) { + const xe_xex2_section_t* section = &header->sections[n]; + const size_t start_address = + header->exe_address + (i * xe_xex2_section_length); + const size_t end_address = + start_address + (section->info.page_count * xe_xex2_section_length); + if (section->info.type == XEX_SECTION_CODE) { + code_addr_low_ = MIN(code_addr_low_, start_address); + code_addr_high_ = MAX(code_addr_high_, end_address); + } + i += section->info.page_count; + } + int result_code = Prepare(); if (result_code) { return result_code; @@ -89,6 +105,9 @@ int ExecModule::PrepareRawBinary(uint32_t start_address, uint32_t end_address) { new sdb::RawSymbolDatabase(memory_, export_resolver_.get(), start_address, end_address)); + code_addr_low_ = start_address; + code_addr_high_ = end_address; + return Prepare(); } diff --git a/src/xenia/cpu/exec_module.h b/src/xenia/cpu/exec_module.h index 364807cd0..40023485c 100644 --- a/src/xenia/cpu/exec_module.h +++ b/src/xenia/cpu/exec_module.h @@ -72,6 +72,8 @@ private: shared_ptr gen_module_; auto_ptr codegen_; + uint32_t code_addr_low_; + uint32_t code_addr_high_; FunctionMap fns_; };