summaryrefslogtreecommitdiff
path: root/src/core/arm/arm_interface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/arm/arm_interface.cpp')
-rw-r--r--src/core/arm/arm_interface.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/core/arm/arm_interface.cpp b/src/core/arm/arm_interface.cpp
index dea192869..7e846ddd5 100644
--- a/src/core/arm/arm_interface.cpp
+++ b/src/core/arm/arm_interface.cpp
@@ -60,15 +60,15 @@ static_assert(sizeof(ELFSymbol) == 0x18, "ELFSymbol has incorrect size.");
60 60
61using Symbols = std::vector<std::pair<ELFSymbol, std::string>>; 61using Symbols = std::vector<std::pair<ELFSymbol, std::string>>;
62 62
63Symbols GetSymbols(VAddr text_offset) { 63Symbols GetSymbols(VAddr text_offset, Memory::Memory& memory) {
64 const auto mod_offset = text_offset + Memory::Read32(text_offset + 4); 64 const auto mod_offset = text_offset + memory.Read32(text_offset + 4);
65 65
66 if (mod_offset < text_offset || (mod_offset & 0b11) != 0 || 66 if (mod_offset < text_offset || (mod_offset & 0b11) != 0 ||
67 Memory::Read32(mod_offset) != Common::MakeMagic('M', 'O', 'D', '0')) { 67 memory.Read32(mod_offset) != Common::MakeMagic('M', 'O', 'D', '0')) {
68 return {}; 68 return {};
69 } 69 }
70 70
71 const auto dynamic_offset = Memory::Read32(mod_offset + 0x4) + mod_offset; 71 const auto dynamic_offset = memory.Read32(mod_offset + 0x4) + mod_offset;
72 72
73 VAddr string_table_offset{}; 73 VAddr string_table_offset{};
74 VAddr symbol_table_offset{}; 74 VAddr symbol_table_offset{};
@@ -76,8 +76,8 @@ Symbols GetSymbols(VAddr text_offset) {
76 76
77 VAddr dynamic_index = dynamic_offset; 77 VAddr dynamic_index = dynamic_offset;
78 while (true) { 78 while (true) {
79 const auto tag = Memory::Read64(dynamic_index); 79 const u64 tag = memory.Read64(dynamic_index);
80 const auto value = Memory::Read64(dynamic_index + 0x8); 80 const u64 value = memory.Read64(dynamic_index + 0x8);
81 dynamic_index += 0x10; 81 dynamic_index += 0x10;
82 82
83 if (tag == ELF_DYNAMIC_TAG_NULL) { 83 if (tag == ELF_DYNAMIC_TAG_NULL) {
@@ -105,11 +105,11 @@ Symbols GetSymbols(VAddr text_offset) {
105 VAddr symbol_index = symbol_table_address; 105 VAddr symbol_index = symbol_table_address;
106 while (symbol_index < string_table_address) { 106 while (symbol_index < string_table_address) {
107 ELFSymbol symbol{}; 107 ELFSymbol symbol{};
108 Memory::ReadBlock(symbol_index, &symbol, sizeof(ELFSymbol)); 108 memory.ReadBlock(symbol_index, &symbol, sizeof(ELFSymbol));
109 109
110 VAddr string_offset = string_table_address + symbol.name_index; 110 VAddr string_offset = string_table_address + symbol.name_index;
111 std::string name; 111 std::string name;
112 for (u8 c = Memory::Read8(string_offset); c != 0; c = Memory::Read8(++string_offset)) { 112 for (u8 c = memory.Read8(string_offset); c != 0; c = memory.Read8(++string_offset)) {
113 name += static_cast<char>(c); 113 name += static_cast<char>(c);
114 } 114 }
115 115
@@ -141,17 +141,17 @@ constexpr u64 SEGMENT_BASE = 0x7100000000ull;
141 141
142std::vector<ARM_Interface::BacktraceEntry> ARM_Interface::GetBacktrace() const { 142std::vector<ARM_Interface::BacktraceEntry> ARM_Interface::GetBacktrace() const {
143 std::vector<BacktraceEntry> out; 143 std::vector<BacktraceEntry> out;
144 auto& memory = system.Memory();
144 145
145 auto fp = GetReg(29); 146 auto fp = GetReg(29);
146 auto lr = GetReg(30); 147 auto lr = GetReg(30);
147
148 while (true) { 148 while (true) {
149 out.push_back({"", 0, lr, 0}); 149 out.push_back({"", 0, lr, 0});
150 if (!fp) { 150 if (!fp) {
151 break; 151 break;
152 } 152 }
153 lr = Memory::Read64(fp + 8) - 4; 153 lr = memory.Read64(fp + 8) - 4;
154 fp = Memory::Read64(fp); 154 fp = memory.Read64(fp);
155 } 155 }
156 156
157 std::map<VAddr, std::string> modules; 157 std::map<VAddr, std::string> modules;
@@ -162,7 +162,7 @@ std::vector<ARM_Interface::BacktraceEntry> ARM_Interface::GetBacktrace() const {
162 162
163 std::map<std::string, Symbols> symbols; 163 std::map<std::string, Symbols> symbols;
164 for (const auto& module : modules) { 164 for (const auto& module : modules) {
165 symbols.insert_or_assign(module.second, GetSymbols(module.first)); 165 symbols.insert_or_assign(module.second, GetSymbols(module.first, memory));
166 } 166 }
167 167
168 for (auto& entry : out) { 168 for (auto& entry : out) {