]> sourceware.org Git - newlib-cygwin.git/commitdiff
* dcrt0.cc (dll_crt0_0): Remove call to wincap.init.
authorCorinna Vinschen <corinna@vinschen.de>
Tue, 10 Jan 2006 18:11:32 +0000 (18:11 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 10 Jan 2006 18:11:32 +0000 (18:11 +0000)
* init.cc (dll_entry): Rename is_wow64_proc to wow64_test_stack_marker.
Call wincap.init here before doing anything else.  Use wincap.is_wow64
to determine if we're running in a WOW64 emulator.
* mmap.cc (MapViewNT): Don't use AT_ROUND_TO_PAGE in WOW64, it's
apparently not supported.
(mmap64): Don't create mappings beyond EOF, which would need to use
AT_ROUND_TO_PAGE, on WOW64.
* wincap.cc (wincap): Throw into the .cygwin_dll_common section.
(wincapc::init): Determine if running in WOW64 and set wow_64 flag.
* wincap.h (class wincapc): Add wow64 member.
(wincapc::is_wow64): New method.

winsup/cygwin/ChangeLog
winsup/cygwin/dcrt0.cc
winsup/cygwin/init.cc
winsup/cygwin/mmap.cc
winsup/cygwin/wincap.cc
winsup/cygwin/wincap.h

index a2a57cb44c36a3fdb7a854cca0ace49fefecff70..8cbd84b3087a2eababc217b6cf9e2df07f79cb2b 100644 (file)
@@ -1,3 +1,18 @@
+2006-01-10  Corinna Vinschen  <corinna@vinschen.de>
+
+       * dcrt0.cc (dll_crt0_0): Remove call to wincap.init.
+       * init.cc (dll_entry): Rename is_wow64_proc to wow64_test_stack_marker.
+       Call wincap.init here before doing anything else.  Use wincap.is_wow64
+       to determine if we're running in a WOW64 emulator.
+       * mmap.cc (MapViewNT): Don't use AT_ROUND_TO_PAGE in WOW64, it's
+       apparently not supported.
+       (mmap64): Don't create mappings beyond EOF, which would need to use
+       AT_ROUND_TO_PAGE, on WOW64.
+       * wincap.cc (wincap): Throw into the .cygwin_dll_common section.
+       (wincapc::init): Determine if running in WOW64 and set wow_64 flag.
+       * wincap.h (class wincapc): Add wow64 member.
+       (wincapc::is_wow64): New method.
+
 2006-01-10  Christopher Faylor  <cgf@timesys.com>
 
        * fhandler_proc.cc (format_proc_cpuinfo): Avoid leading whitespace in
index b786dbf75196e5daa359735b54bfc6b5213bf433..3c8a7c8e4daf5afb70d8a80ec32f45f5e4e54a0d 100644 (file)
@@ -680,7 +680,6 @@ dll_crt0_0 ()
   _impure_ptr->_current_locale = "C";
   user_data->impure_ptr = _impure_ptr;
   user_data->impure_ptr_ptr = &_impure_ptr;
-  wincap.init ();
   initial_env ();
   mmap_init ();
 
index 037b6c7958c371e47d566192bb4a603eb84e2259..57faa073c749f01754082c5af2efb32c9e1cc33c 100644 (file)
@@ -143,7 +143,7 @@ HMODULE NO_COPY cygwin_hmodule;
 extern "C" BOOL WINAPI
 dll_entry (HANDLE h, DWORD reason, void *static_load)
 {
-  BOOL is_wow64_proc = FALSE;
+  BOOL wow64_test_stack_marker;
   // _STRACE_ON;
 
   switch (reason)
@@ -152,15 +152,16 @@ dll_entry (HANDLE h, DWORD reason, void *static_load)
       cygwin_hmodule = (HMODULE) h;
       dynamically_loaded = (static_load == NULL);
 
+      wincap.init ();
+
       /* Is the stack at an unusual address?  This is, an address which
         is in the usual space occupied by the process image, but below
         the auto load address of DLLs?
         Check if we're running in WOW64 on a 64 bit machine *and* are
         spawned by a genuine 64 bit process.  If so, respawn. */
-      if (&is_wow64_proc >= (PBOOL) 0x400000
-         && &is_wow64_proc <= (PBOOL) 0x10000000
-         && IsWow64Process (GetCurrentProcess (), &is_wow64_proc)
-         && is_wow64_proc)
+      if (wincap.is_wow64 ()
+         && &wow64_test_stack_marker >= (PBOOL) 0x400000
+         && &wow64_test_stack_marker <= (PBOOL) 0x10000000)
        respawn_wow64_process ();
 
       dll_crt0_0 ();
index 46deea31c96f88205f43d97703f5067832af5016..76d3d5d863ab67793bdb9bb4f29b37b77f2b5af6 100644 (file)
@@ -350,7 +350,7 @@ MapViewNT (HANDLE h, void *addr, size_t len, DWORD openflags,
   void *base = addr;
   ULONG commitsize = attached (prot) ? 0 : len;
   ULONG viewsize = len;
-  ULONG alloc_type = base ? AT_ROUND_TO_PAGE : 0;
+  ULONG alloc_type = base && !wincap.is_wow64 () ? AT_ROUND_TO_PAGE : 0;
 
   /* Try mapping using the given address first, even if it's NULL.
      If it failed, and addr was not NULL and flags is not MAP_FIXED,
@@ -1109,8 +1109,13 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
         anonymous pages.  That's not possible on 9x for two reasons.
         It neither allows to create reserved pages in the shared memory
         area, nor does it allow to create page aligend mappings (in
-        contrast to granularity aligned mappings). */
+        contrast to granularity aligned mappings).
+        
+        Note that this isn't done in WOW64 environments since apparently
+        WOW64 does not support the AT_ROUND_TO_PAGE flag which is required
+        to get this right.  Too bad. */
       if (wincap.virtual_protect_works_on_shared_pages ()
+         && !wincap.is_wow64 ()
          && ((len > fsiz && !autogrow (flags))
              || len < pagesize))
        orig_len = len;
@@ -1177,9 +1182,9 @@ go_ahead:
         protection as the file's pages, then as much pages as necessary
         to accomodate the requested length, but as reserved pages which
         raise a SIGBUS when trying to access them.  AT_ROUND_TO_PAGE
-        and page protection on shared pages is only supported by NT, so
-        don't even try on 9x.  This is accomplished by not setting
-        orig_len on 9x above. */
+        and page protection on shared pages is only supported by 32 bit NT,
+        so don't even try on 9x and in WOW64.  This is accomplished by not
+        setting orig_len on 9x and in WOW64 above. */
       orig_len = roundup2 (orig_len, pagesize);
       len = roundup2 (len, getsystempagesize ());
       if (orig_len - len)
index 898f098c6ca845063f21f5ebec74e46ce2da57b3..329cfec695e96ec534983a70eb80c8c071773cab 100644 (file)
@@ -713,7 +713,7 @@ static NO_COPY wincaps wincap_vista = {
   has_working_virtual_lock:true
 };
 
-wincapc wincap;
+wincapc wincap __attribute__((section (".cygwin_dll_common"), shared));
 
 void
 wincapc::init ()
@@ -820,6 +820,10 @@ wincapc::init ()
        ((wincaps *)this->caps)->is_server = true;
     }
 
+  BOOL is_wow64_proc = FALSE;
+  if (IsWow64Process (GetCurrentProcess (), &is_wow64_proc))
+    wow64 = is_wow64_proc;
+
   __small_sprintf (osnam, "%s-%d.%d", os, version.dwMajorVersion,
                   version.dwMinorVersion);
 }
index 31f2c82a7fc9dd566ae95689a4de51892be73eb8..8d3fd2343c74c5237c1655b36609326a5bc50571 100644 (file)
@@ -70,6 +70,7 @@ class wincapc
 {
   OSVERSIONINFOEX  version;
   char             osnam[40];
+  bool             wow64;
   void             *caps;
 
 public:
@@ -78,6 +79,7 @@ public:
   void set_chunksize (DWORD nchunksize);
 
   const char *osname () const { return osnam; }
+  const bool is_wow64 () const { return wow64; }
 
 #define IMPLEMENT(cap) cap() const { return ((wincaps *) this->caps)->cap; }
 
This page took 0.041709 seconds and 5 git commands to generate.