From 129e60ab4b93ed701528860bfbc1da575d928dd0 Mon Sep 17 00:00:00 2001 From: Bertrand Bellenot Date: Mon, 9 Apr 2018 14:21:32 +0200 Subject: [PATCH] Add comment referencing where the 0x2C value is coming from --- lib/Interpreter/Interpreter.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/Interpreter/Interpreter.cpp b/lib/Interpreter/Interpreter.cpp index b26d7366..0bf52c3e 100644 --- a/lib/Interpreter/Interpreter.cpp +++ b/lib/Interpreter/Interpreter.cpp @@ -502,6 +502,13 @@ namespace cling { m_Executor->addSymbol("__dso_handle", this, true); #ifdef _MSC_VER + // According to the PE Format spec, in "The .tls Section" + // (http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx): + // 2. When a thread is created, the loader communicates the address + // of the thread's TLS array by placing the address of the thread + // environment block (TEB) in the FS register. A pointer to the TLS + // array is at the offset of 0x2C from the beginning of TEB. This + // behavior is Intel x86-specific. static const unsigned long _tls_array = 0x2C; m_Executor->addSymbol("_tls_array", (void *)&_tls_array, true); #endif