From 4f807a669c6e72c6effe210a80987b594e8bd28a Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Thu, 4 Jun 2015 16:20:52 -0500 Subject: [PATCH] Fix TLS copying (size may still be wrong though) --- src/xenia/kernel/objects/xthread.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/xenia/kernel/objects/xthread.cc b/src/xenia/kernel/objects/xthread.cc index 289f6e482..29df45f16 100644 --- a/src/xenia/kernel/objects/xthread.cc +++ b/src/xenia/kernel/objects/xthread.cc @@ -176,7 +176,9 @@ X_STATUS XThread::Create() { uint32_t tls_size = 32; // Default 32 (is this OK?) if (module && module->xex_header()) { const xe_xex2_header_t* header = module->xex_header(); - tls_size = header->tls_info.slot_count * header->tls_info.data_size; + + // FIXME: Is this correct? + tls_size = header->tls_info.data_size; } tls_address_ = memory()->SystemHeapAlloc(tls_size); @@ -190,8 +192,7 @@ X_STATUS XThread::Create() { const xe_xex2_header_t* header = module->xex_header(); // Copy in default TLS info. - // TODO(benvanik): is this correct? - memory()->Copy(tls_address_, header->tls_info.raw_data_address, tls_size); + memory()->Copy(tls_address_, header->tls_info.raw_data_address, header->tls_info.data_size); } else { memory()->Fill(tls_address_, tls_size, 0); }