From 95afbe2d93b4d1339e262007d76f2a991d23df1b Mon Sep 17 00:00:00 2001 From: gibbed Date: Sun, 14 Jun 2015 03:50:45 -0500 Subject: [PATCH] Don't allocate memory for TLS slots, and copy the default TLS data at the start, rather than offset by the TLS slot size, which seems to be more correct. --- src/xenia/kernel/objects/xthread.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/xenia/kernel/objects/xthread.cc b/src/xenia/kernel/objects/xthread.cc index 6192a3456..702e3a36a 100644 --- a/src/xenia/kernel/objects/xthread.cc +++ b/src/xenia/kernel/objects/xthread.cc @@ -191,7 +191,10 @@ X_STATUS XThread::Create() { } // Allocate both the slots and the extended data. - uint32_t tls_slot_size = tls_slots * 4; + // HACK: we're currently not using the extra memory allocated for TLS slots + // and instead relying on native TLS slots, so don't allocate anything for + // the slots. + uint32_t tls_slot_size = 0; // tls_slots * 4; uint32_t tls_total_size = tls_slot_size + tls_extended_size; tls_address_ = memory()->SystemHeapAlloc(tls_total_size); if (!tls_address_) { @@ -205,8 +208,7 @@ X_STATUS XThread::Create() { // If game has extended data, copy in the default values. const xe_xex2_header_t* header = module->xex_header(); assert_not_zero(header->tls_info.raw_data_address); - // TODO(benvanik): verify location relative to slots. - memory()->Copy(tls_address_ + tls_slot_size, + memory()->Copy(tls_address_, header->tls_info.raw_data_address, header->tls_info.raw_data_size); }