* dcrt0.cc (dll_crt0_0): Check for wincap.wow64_has_secondary_stack
rather than for wincap.is_wow64. Accommodate name change from wow64_has_64bit_parent to wow64_needs_stack_adjustment. Align comment. (_dll_crt0): Ditto. * wincap.h (wincaps::wow64_has_secondary_stack): New element. * wincap.cc: Implement above element throughout. (wincapc::init): Set wow64_has_secondary_stack to false on non-64 bit systems. * wow64.cc (wow64_needs_stack_adjustment): Rename (hopefully the last time) from wow64_has_64bit_parent. (wow64_eval_expected_main_stack): Fix comment to reflect real life. (wow64_test_for_64bit_parent): Fix comment. * wow64.h (wow64_needs_stack_adjustment): Accommodate new name.
This commit is contained in:
parent
93a61a6fe3
commit
f08bc85858
@ -1,3 +1,19 @@
|
|||||||
|
2011-12-19 Corinna Vinschen <vinschen@redhat.com>
|
||||||
|
|
||||||
|
* dcrt0.cc (dll_crt0_0): Check for wincap.wow64_has_secondary_stack
|
||||||
|
rather than for wincap.is_wow64. Accommodate name change from
|
||||||
|
wow64_has_64bit_parent to wow64_needs_stack_adjustment. Align comment.
|
||||||
|
(_dll_crt0): Ditto.
|
||||||
|
* wincap.h (wincaps::wow64_has_secondary_stack): New element.
|
||||||
|
* wincap.cc: Implement above element throughout.
|
||||||
|
(wincapc::init): Set wow64_has_secondary_stack to false on non-64 bit
|
||||||
|
systems.
|
||||||
|
* wow64.cc (wow64_needs_stack_adjustment): Rename (hopefully the last
|
||||||
|
time) from wow64_has_64bit_parent.
|
||||||
|
(wow64_eval_expected_main_stack): Fix comment to reflect real life.
|
||||||
|
(wow64_test_for_64bit_parent): Fix comment.
|
||||||
|
* wow64.h (wow64_needs_stack_adjustment): Accommodate new name.
|
||||||
|
|
||||||
2011-12-17 Christopher Faylor <me.cygwin2011@cgf.cx>
|
2011-12-17 Christopher Faylor <me.cygwin2011@cgf.cx>
|
||||||
|
|
||||||
* fhandler.cc (fhandler_base::close): Move setting isclosed() from here
|
* fhandler.cc (fhandler_base::close): Move setting isclosed() from here
|
||||||
|
@ -705,11 +705,12 @@ dll_crt0_0 ()
|
|||||||
if (!child_proc_info)
|
if (!child_proc_info)
|
||||||
{
|
{
|
||||||
memory_init (true);
|
memory_init (true);
|
||||||
/* WOW64 process? Check if we have been started from 64 bit process
|
/* WOW64 process on XP/64 or Server 2003/64? Check if we have been
|
||||||
and if our stack is at an unusual address. Set wow64_has_64bit_parent
|
started from 64 bit process and if our stack is at an unusual
|
||||||
if so. Problem description in wow64_test_for_64bit_parent. */
|
address. Set wow64_needs_stack_adjustment if so. Problem
|
||||||
if (wincap.is_wow64 ())
|
description in wow64_test_for_64bit_parent. */
|
||||||
wow64_has_64bit_parent = wow64_test_for_64bit_parent ();
|
if (wincap.wow64_has_secondary_stack ())
|
||||||
|
wow64_needs_stack_adjustment = wow64_test_for_64bit_parent ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -945,9 +946,10 @@ __cygwin_exit_return: \n\
|
|||||||
extern "C" void __stdcall
|
extern "C" void __stdcall
|
||||||
_dll_crt0 ()
|
_dll_crt0 ()
|
||||||
{
|
{
|
||||||
/* Handle WOW64 process started from native 64 bit process. See comment
|
/* Handle WOW64 process on XP/2K3 which has been started from native 64 bit
|
||||||
in wow64_test_for_64bit_parent for a full problem description. */
|
process. See comment in wow64_test_for_64bit_parent for a full problem
|
||||||
if (wow64_has_64bit_parent && !dynamically_loaded)
|
description. */
|
||||||
|
if (wow64_needs_stack_adjustment && !dynamically_loaded)
|
||||||
{
|
{
|
||||||
/* Must be static since it's referenced after the stack pointers have
|
/* Must be static since it's referenced after the stack pointers have
|
||||||
been moved. */
|
been moved. */
|
||||||
|
@ -52,6 +52,7 @@ wincaps wincap_2000 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
|||||||
use_dont_resolve_hack:false,
|
use_dont_resolve_hack:false,
|
||||||
has_stack_size_param_is_a_reservation:false,
|
has_stack_size_param_is_a_reservation:false,
|
||||||
has_console_logon_sid:false,
|
has_console_logon_sid:false,
|
||||||
|
wow64_has_secondary_stack:false,
|
||||||
};
|
};
|
||||||
|
|
||||||
wincaps wincap_2000sp4 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
wincaps wincap_2000sp4 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
@ -83,6 +84,7 @@ wincaps wincap_2000sp4 __attribute__((section (".cygwin_dll_common"), shared)) =
|
|||||||
use_dont_resolve_hack:false,
|
use_dont_resolve_hack:false,
|
||||||
has_stack_size_param_is_a_reservation:false,
|
has_stack_size_param_is_a_reservation:false,
|
||||||
has_console_logon_sid:false,
|
has_console_logon_sid:false,
|
||||||
|
wow64_has_secondary_stack:false,
|
||||||
};
|
};
|
||||||
|
|
||||||
wincaps wincap_xp __attribute__((section (".cygwin_dll_common"), shared)) = {
|
wincaps wincap_xp __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
@ -114,6 +116,7 @@ wincaps wincap_xp __attribute__((section (".cygwin_dll_common"), shared)) = {
|
|||||||
use_dont_resolve_hack:true,
|
use_dont_resolve_hack:true,
|
||||||
has_stack_size_param_is_a_reservation:true,
|
has_stack_size_param_is_a_reservation:true,
|
||||||
has_console_logon_sid:false,
|
has_console_logon_sid:false,
|
||||||
|
wow64_has_secondary_stack:false,
|
||||||
};
|
};
|
||||||
|
|
||||||
wincaps wincap_xpsp1 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
wincaps wincap_xpsp1 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
@ -145,6 +148,7 @@ wincaps wincap_xpsp1 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
|||||||
use_dont_resolve_hack:true,
|
use_dont_resolve_hack:true,
|
||||||
has_stack_size_param_is_a_reservation:true,
|
has_stack_size_param_is_a_reservation:true,
|
||||||
has_console_logon_sid:false,
|
has_console_logon_sid:false,
|
||||||
|
wow64_has_secondary_stack:false,
|
||||||
};
|
};
|
||||||
|
|
||||||
wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
@ -176,6 +180,7 @@ wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
|||||||
use_dont_resolve_hack:true,
|
use_dont_resolve_hack:true,
|
||||||
has_stack_size_param_is_a_reservation:true,
|
has_stack_size_param_is_a_reservation:true,
|
||||||
has_console_logon_sid:false,
|
has_console_logon_sid:false,
|
||||||
|
wow64_has_secondary_stack:false,
|
||||||
};
|
};
|
||||||
|
|
||||||
wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
@ -207,6 +212,7 @@ wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
|||||||
use_dont_resolve_hack:true,
|
use_dont_resolve_hack:true,
|
||||||
has_stack_size_param_is_a_reservation:true,
|
has_stack_size_param_is_a_reservation:true,
|
||||||
has_console_logon_sid:false,
|
has_console_logon_sid:false,
|
||||||
|
wow64_has_secondary_stack:true,
|
||||||
};
|
};
|
||||||
|
|
||||||
wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
|
wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
@ -238,6 +244,7 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
|
|||||||
use_dont_resolve_hack:false,
|
use_dont_resolve_hack:false,
|
||||||
has_stack_size_param_is_a_reservation:true,
|
has_stack_size_param_is_a_reservation:true,
|
||||||
has_console_logon_sid:false,
|
has_console_logon_sid:false,
|
||||||
|
wow64_has_secondary_stack:false,
|
||||||
};
|
};
|
||||||
|
|
||||||
wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
@ -269,6 +276,7 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
|||||||
use_dont_resolve_hack:false,
|
use_dont_resolve_hack:false,
|
||||||
has_stack_size_param_is_a_reservation:true,
|
has_stack_size_param_is_a_reservation:true,
|
||||||
has_console_logon_sid:true,
|
has_console_logon_sid:true,
|
||||||
|
wow64_has_secondary_stack:false,
|
||||||
};
|
};
|
||||||
|
|
||||||
wincapc wincap __attribute__((section (".cygwin_dll_common"), shared));
|
wincapc wincap __attribute__((section (".cygwin_dll_common"), shared));
|
||||||
@ -356,6 +364,7 @@ wincapc::init ()
|
|||||||
{
|
{
|
||||||
((wincaps *)caps)->needs_count_in_si_lpres2 = false;
|
((wincaps *)caps)->needs_count_in_si_lpres2 = false;
|
||||||
((wincaps *)caps)->has_restricted_stack_args = false;
|
((wincaps *)caps)->has_restricted_stack_args = false;
|
||||||
|
((wincaps *)caps)->wow64_has_secondary_stack = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
__small_sprintf (osnam, "NT-%d.%d", version.dwMajorVersion,
|
__small_sprintf (osnam, "NT-%d.%d", version.dwMajorVersion,
|
||||||
|
@ -42,6 +42,7 @@ struct wincaps
|
|||||||
unsigned use_dont_resolve_hack : 1;
|
unsigned use_dont_resolve_hack : 1;
|
||||||
unsigned has_stack_size_param_is_a_reservation : 1;
|
unsigned has_stack_size_param_is_a_reservation : 1;
|
||||||
unsigned has_console_logon_sid : 1;
|
unsigned has_console_logon_sid : 1;
|
||||||
|
unsigned wow64_has_secondary_stack : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
class wincapc
|
class wincapc
|
||||||
@ -92,6 +93,7 @@ public:
|
|||||||
bool IMPLEMENT (use_dont_resolve_hack)
|
bool IMPLEMENT (use_dont_resolve_hack)
|
||||||
bool IMPLEMENT (has_stack_size_param_is_a_reservation)
|
bool IMPLEMENT (has_stack_size_param_is_a_reservation)
|
||||||
bool IMPLEMENT (has_console_logon_sid)
|
bool IMPLEMENT (has_console_logon_sid)
|
||||||
|
bool IMPLEMENT (wow64_has_secondary_stack)
|
||||||
|
|
||||||
#undef IMPLEMENT
|
#undef IMPLEMENT
|
||||||
};
|
};
|
||||||
|
@ -15,7 +15,7 @@ details. */
|
|||||||
|
|
||||||
#define PTR_ADD(p,o) ((PVOID)((PBYTE)(p)+(o)))
|
#define PTR_ADD(p,o) ((PVOID)((PBYTE)(p)+(o)))
|
||||||
|
|
||||||
bool NO_COPY wow64_has_64bit_parent = false;
|
bool NO_COPY wow64_needs_stack_adjustment = false;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wow64_eval_expected_main_stack (PVOID &allocbase, PVOID &stackbase)
|
wow64_eval_expected_main_stack (PVOID &allocbase, PVOID &stackbase)
|
||||||
@ -27,10 +27,17 @@ wow64_eval_expected_main_stack (PVOID &allocbase, PVOID &stackbase)
|
|||||||
dosheader = (PIMAGE_DOS_HEADER) GetModuleHandle (NULL);
|
dosheader = (PIMAGE_DOS_HEADER) GetModuleHandle (NULL);
|
||||||
ntheader = (PIMAGE_NT_HEADERS32) ((PBYTE) dosheader + dosheader->e_lfanew);
|
ntheader = (PIMAGE_NT_HEADERS32) ((PBYTE) dosheader + dosheader->e_lfanew);
|
||||||
/* The main thread stack is expected to be located at 0x30000, which is the
|
/* The main thread stack is expected to be located at 0x30000, which is the
|
||||||
case for all observed NT systems to date, unless the stacksize requested
|
case for all observed NT systems up to Server 2003 R2, unless the
|
||||||
by the StackReserve field in the PE/COFF header is so big that the stack
|
stacksize requested by the StackReserve field in the PE/COFF header is
|
||||||
doesn't fit in the area between 0x30000 and the start of the image. In
|
so big that the stack doesn't fit in the area between 0x30000 and the
|
||||||
case of a conflict, the OS allocates the stack right after the image. */
|
start of the image. In case of a conflict, the OS allocates the stack
|
||||||
|
right after the image.
|
||||||
|
Sidenote: While post-2K3 32 bit systems continue to have the default
|
||||||
|
main thread stack address located at 0x30000, the default main thread
|
||||||
|
stack address on Vista/2008 64 bit is 0x80000 and on W7/2K8R2 64 bit
|
||||||
|
it is 0x90000. However, this is no problem because the system sticks
|
||||||
|
to that address for all WOW64 processes, not only for the first one
|
||||||
|
started from a 64 bit parent. */
|
||||||
allocbase = (PVOID) 0x30000;
|
allocbase = (PVOID) 0x30000;
|
||||||
/* Stack size. The OS always rounds the size up to allocation granularity
|
/* Stack size. The OS always rounds the size up to allocation granularity
|
||||||
and it never allocates less than 256K. */
|
and it never allocates less than 256K. */
|
||||||
@ -62,9 +69,9 @@ wow64_test_for_64bit_parent ()
|
|||||||
else in the child process.
|
else in the child process.
|
||||||
What we do here is to check if the current stack is the excpected main
|
What we do here is to check if the current stack is the excpected main
|
||||||
thread stack and if not, if we really have been started from a 64 bit
|
thread stack and if not, if we really have been started from a 64 bit
|
||||||
process here. If so, we note this fact in wow64_has_64bit_parent so we
|
process here. If so, we note this fact in wow64_needs_stack_adjustment
|
||||||
can workaround the stack problem in _dll_crt0. See there for how we go
|
so we can workaround the stack problem in _dll_crt0. See there for how
|
||||||
along. */
|
we go along. */
|
||||||
NTSTATUS ret;
|
NTSTATUS ret;
|
||||||
PROCESS_BASIC_INFORMATION pbi;
|
PROCESS_BASIC_INFORMATION pbi;
|
||||||
HANDLE parent;
|
HANDLE parent;
|
||||||
|
@ -8,7 +8,7 @@ This software is a copyrighted work licensed under the terms of the
|
|||||||
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
||||||
details. */
|
details. */
|
||||||
|
|
||||||
extern bool NO_COPY wow64_has_64bit_parent;
|
extern bool NO_COPY wow64_needs_stack_adjustment;
|
||||||
|
|
||||||
extern bool wow64_test_for_64bit_parent ();
|
extern bool wow64_test_for_64bit_parent ();
|
||||||
extern PVOID wow64_revert_to_original_stack (PVOID &allocationbase);
|
extern PVOID wow64_revert_to_original_stack (PVOID &allocationbase);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user