From efe59e0249c7f71068f1b30ba2e80ca8870e814b Mon Sep 17 00:00:00 2001 From: TibixDev Date: Thu, 8 Oct 2026 01:39:37 +0300 Subject: [PATCH] test(libc): resolve the library address in the TLS destructor test Use dlsym to avoid identifying the executable PLT entry as the shared-library function in non-PIE builds. Fedora 44 Release guest_force_tls_destructor passes. Written with AI assistance. --- core/libs/prx/libSceLibcInternal/CMakeLists.txt | 2 +- core/libs/tests/GuestForceTlsDestructor.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/libs/prx/libSceLibcInternal/CMakeLists.txt b/core/libs/prx/libSceLibcInternal/CMakeLists.txt index 6443b72c5..2c0060756 100644 --- a/core/libs/prx/libSceLibcInternal/CMakeLists.txt +++ b/core/libs/prx/libSceLibcInternal/CMakeLists.txt @@ -17,7 +17,7 @@ if(BUILD_TESTING) if(NOT WIN32) add_test_executable(guest_force_tls_destructor_tests ${LIBS_INCLUDE_DIR}/tests/GuestForceTlsDestructor.cpp) target_include_directories(guest_force_tls_destructor_tests PRIVATE ${LIBS_INCLUDE_DIR}) - target_link_libraries(guest_force_tls_destructor_tests PRIVATE libSceLibcInternal libkernel libc) + target_link_libraries(guest_force_tls_destructor_tests PRIVATE libSceLibcInternal libkernel libc ${CMAKE_DL_LIBS}) add_test(NAME guest_force_tls_destructor COMMAND guest_force_tls_destructor_tests) set_tests_properties(guest_force_tls_destructor PROPERTIES TIMEOUT 20) endif() diff --git a/core/libs/tests/GuestForceTlsDestructor.cpp b/core/libs/tests/GuestForceTlsDestructor.cpp index 991538f24..49264c929 100644 --- a/core/libs/tests/GuestForceTlsDestructor.cpp +++ b/core/libs/tests/GuestForceTlsDestructor.cpp @@ -1,6 +1,7 @@ #include "SceTypes.hpp" #include #include +#include #include #include @@ -68,7 +69,8 @@ bool ForceThrows(KernelModule handle) { int main() { self = ModuleOf(&dsoHandle); - void* otherDso = reinterpret_cast(&_sceLibcInternalThreadDtors_nid_postfix); + void* otherDso = dlsym(RTLD_NEXT, "_sceLibcInternalThreadDtors_nid_postfix"); + Require(otherDso != nullptr); const KernelModule other = ModuleOf(otherDso); Require(other != self && other != 0); int local = 0;