|
Boost : |
Subject: [boost] [context] Windows x64 fiber local storage GS offset
From: Elbert Mai (edmai_at_[hidden])
Date: 2017-04-24 05:18:39
The Windows x64 implementation of Boost.Context saves fiber local storage
from GS:[0x18]. For example, in jump_x86_64_ms_pe_masm.asm:
; load NT_TIB
mov r10, gs:[030h]
; save fiber local storage
mov rax, [r10+018h]
mov [rsp+0b0h], rax
However, this is the NT_TIB struct as defined in winnt.h
typedef struct _NT_TIB {
struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
PVOID StackBase;
PVOID StackLimit;
PVOID SubSystemTib;
union {
PVOID FiberData;
DWORD Version;
};
PVOID ArbitraryUserPointer;
struct _NT_TIB *Self;
} NT_TIB;
This implies that fiber local storage is found in GS:[0x20], not GS:[0x18].
The Windows x86 implementation uses FS:[0x10], which is consistent with the
NT_TIB struct.
Am I missing something, or does Boost.Context save/restore fiber local
storage at the wrong address in Windows x64?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk