From 114f06d3f2dd6041cb90f87fd76be520bfc831c6 Mon Sep 17 00:00:00 2001 From: IndecisiveTurtle <47210458+raphaelthegreat@users.noreply.github.com> Date: Sat, 29 Jun 2024 16:12:04 +0300 Subject: [PATCH] tls: Fix linux crash --- src/core/tls.cpp | 4 ++-- src/emulator.cpp | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/tls.cpp b/src/core/tls.cpp index 6fbcdc41..5999cfe7 100644 --- a/src/core/tls.cpp +++ b/src/core/tls.cpp @@ -124,9 +124,9 @@ static void PatchFsAccess(u8* code, const TLSPattern& tls_pattern, Xbyak::CodeGe const u32 idx1st = slot / PthreadKeySecondLevelSize; const u32 idx2nd = slot % PthreadKeySecondLevelSize; const auto target_reg = Xbyak::Reg64(tls_pattern.target_reg); + c.mov(target_reg, PthreadSpecificOffset); c.putSeg(fs); - c.mov(target_reg, - qword[PthreadSpecificOffset + idx1st * 8]); // Load first level specific array. + c.mov(target_reg, qword[target_reg + idx1st * 8]); // Load first level specific array. c.mov(target_reg, qword[target_reg + idx2nd * 16 + 8]); // Load data member of pthread_key_data our slot specifies. c.jmp(code + total_size); // Return to the instruction right after the mov. diff --git a/src/emulator.cpp b/src/emulator.cpp index 0530c6bb..b38df0c3 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -139,7 +139,6 @@ void Emulator::Run(const std::filesystem::path& file) { } void Emulator::LoadSystemModules(const std::filesystem::path& file) { - constexpr std::array ModulesToLoad{ {{"libSceNgs2.sprx", nullptr}, {"libSceLibcInternal.sprx", &Libraries::LibcInternal::RegisterlibSceLibcInternal},