From 41193b6a83bd469fb949c53c9ca2af27412e936b Mon Sep 17 00:00:00 2001 From: Niko Date: Wed, 4 Sep 2024 21:50:01 -0400 Subject: [PATCH] linker fixes --- src/core/linker.cpp | 9 ++------- src/core/tls.cpp | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/core/linker.cpp b/src/core/linker.cpp index 3f3b8cb6b..8fada96f4 100644 --- a/src/core/linker.cpp +++ b/src/core/linker.cpp @@ -306,9 +306,8 @@ bool Linker::Resolve(const std::string& name, Loader::SymbolType sym_type, Modul return false; } -void* Linker::TlsGetAddr(u64 module_index, u64 offset) -{ -#ifdef __x86_64__ +void* Linker::TlsGetAddr(u64 module_index, u64 offset) { + std::scoped_lock lk{mutex}; DtvEntry* dtv_table = GetTcbBase()->tcb_dtv; @@ -341,10 +340,6 @@ void* Linker::TlsGetAddr(u64 module_index, u64 offset) dtv_table[module_index + 1].pointer = dest; addr = dest; } - return addr + offset; -#else - return 0; -#endif } void Linker::InitTlsForThread(bool is_primary) { diff --git a/src/core/tls.cpp b/src/core/tls.cpp index fe74cfbe2..c44359f38 100644 --- a/src/core/tls.cpp +++ b/src/core/tls.cpp @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#ifdef __x86_64__ - #include #include "common/assert.h" #include "common/types.h" @@ -42,7 +40,7 @@ Tcb* GetTcbBase() { return reinterpret_cast(TlsGetValue(GetTcbKey())); } -#elif defined(__APPLE__) +#elif defined(__APPLE__) && defined(__x86_64__) // Reserve space in the 32-bit address range for allocating TCB pages. asm(".zerofill TCB_SPACE,TCB_SPACE,__guest_system,0x3FC000"); @@ -134,6 +132,17 @@ Tcb* GetTcbBase() { return tcb; } +#elif defined(__APPLE__) && defined(__aarch64__) + +void SetTcbBase(void* image_address) { + LOG_INFO(Core_Linker, "TODO: SetTcbBase"); +} + +Tcb* GetTcbBase() { + LOG_INFO(Core_Linker, "TODO: GetTcbBase"); + return 0; +} + #else void SetTcbBase(void* image_address) { @@ -149,5 +158,3 @@ Tcb* GetTcbBase() { #endif } // namespace Core - -#endif \ No newline at end of file