diff options
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/service/jit/jit_context.cpp | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/src/core/hle/service/jit/jit_context.cpp b/src/core/hle/service/jit/jit_context.cpp index 19bd85b6c..4ed3f02e2 100644 --- a/src/core/hle/service/jit/jit_context.cpp +++ b/src/core/hle/service/jit/jit_context.cpp | |||
| @@ -11,10 +11,13 @@ | |||
| 11 | #include "common/alignment.h" | 11 | #include "common/alignment.h" |
| 12 | #include "common/common_funcs.h" | 12 | #include "common/common_funcs.h" |
| 13 | #include "common/div_ceil.h" | 13 | #include "common/div_ceil.h" |
| 14 | #include "common/elf.h" | ||
| 14 | #include "common/logging/log.h" | 15 | #include "common/logging/log.h" |
| 15 | #include "core/hle/service/jit/jit_context.h" | 16 | #include "core/hle/service/jit/jit_context.h" |
| 16 | #include "core/memory.h" | 17 | #include "core/memory.h" |
| 17 | 18 | ||
| 19 | using namespace Common::ELF; | ||
| 20 | |||
| 18 | namespace Service::JIT { | 21 | namespace Service::JIT { |
| 19 | 22 | ||
| 20 | constexpr std::array<u8, 8> SVC0_ARM64 = { | 23 | constexpr std::array<u8, 8> SVC0_ARM64 = { |
| @@ -26,25 +29,6 @@ constexpr std::array HELPER_FUNCTIONS{ | |||
| 26 | "_stop", "_resolve", "_panic", "memcpy", "memmove", "memset", | 29 | "_stop", "_resolve", "_panic", "memcpy", "memmove", "memset", |
| 27 | }; | 30 | }; |
| 28 | 31 | ||
| 29 | struct Elf64_Dyn { | ||
| 30 | u64 d_tag; | ||
| 31 | u64 d_un; | ||
| 32 | }; | ||
| 33 | |||
| 34 | struct Elf64_Rela { | ||
| 35 | u64 r_offset; | ||
| 36 | u64 r_info; | ||
| 37 | s64 r_addend; | ||
| 38 | }; | ||
| 39 | |||
| 40 | static constexpr u32 Elf64_RelaType(const Elf64_Rela* rela) { | ||
| 41 | return static_cast<u32>(rela->r_info); | ||
| 42 | } | ||
| 43 | |||
| 44 | constexpr int DT_RELA = 7; /* Address of Rela relocs */ | ||
| 45 | constexpr int DT_RELASZ = 8; /* Total size of Rela relocs */ | ||
| 46 | constexpr int R_AARCH64_RELATIVE = 1027; /* Adjust by program base. */ | ||
| 47 | |||
| 48 | constexpr size_t STACK_ALIGN = 16; | 32 | constexpr size_t STACK_ALIGN = 16; |
| 49 | 33 | ||
| 50 | class JITContextImpl; | 34 | class JITContextImpl; |
| @@ -206,17 +190,17 @@ public: | |||
| 206 | if (!dyn.d_tag) { | 190 | if (!dyn.d_tag) { |
| 207 | break; | 191 | break; |
| 208 | } | 192 | } |
| 209 | if (dyn.d_tag == DT_RELA) { | 193 | if (dyn.d_tag == ElfDtRela) { |
| 210 | rela_dyn = dyn.d_un; | 194 | rela_dyn = dyn.d_un.d_ptr; |
| 211 | } | 195 | } |
| 212 | if (dyn.d_tag == DT_RELASZ) { | 196 | if (dyn.d_tag == ElfDtRelasz) { |
| 213 | num_rela = dyn.d_un / sizeof(Elf64_Rela); | 197 | num_rela = dyn.d_un.d_val / sizeof(Elf64_Rela); |
| 214 | } | 198 | } |
| 215 | } | 199 | } |
| 216 | 200 | ||
| 217 | for (size_t i = 0; i < num_rela; i++) { | 201 | for (size_t i = 0; i < num_rela; i++) { |
| 218 | const auto rela{callbacks->ReadMemory<Elf64_Rela>(rela_dyn + i * sizeof(Elf64_Rela))}; | 202 | const auto rela{callbacks->ReadMemory<Elf64_Rela>(rela_dyn + i * sizeof(Elf64_Rela))}; |
| 219 | if (Elf64_RelaType(&rela) != R_AARCH64_RELATIVE) { | 203 | if (Elf64RelType(rela.r_info) != ElfAArch64Relative) { |
| 220 | continue; | 204 | continue; |
| 221 | } | 205 | } |
| 222 | const VAddr contents{callbacks->MemoryRead64(rela.r_offset)}; | 206 | const VAddr contents{callbacks->MemoryRead64(rela.r_offset)}; |