Commit Graph

528 Commits

Author SHA1 Message Date
Corinna Vinschen 30add3e6b3 Cygwin: exec: don't access cygheap before it's initialized
This is a long-standing thinko.

When you exec a process, dll_crt0_0 in the child process calls
child_info_spawn::handle_spawn().  handle_spawn() initialises the
cygheap.

Now consider calling strace.  Strace is a non-Cygwin process dynamically
loading cygwin1.dll via LoadLibrary.  This in turn initializes the DLL:

- dll_crt0_0 finds that the process it attaches to has been exec'd, so
  child_info_spawn::handle_spawn() is called.

- If the DLL is being dynamically loaded, handle_spawn() calls
  child_info_spawn::get_parent_handle().  This in turn tries to set
  the moreinfo->myself_pinfo value inside the cygheap to NULL.

- However, at this time, the cygheap has not yet been initialized.  This
  only occurs in the cygheap_fixup_in_child() call after get_parent_handle()
  returns.

--> SEGV

This thinko never had a negative side effect, because the cygheap was
pre-allocated at DLL load time until commit 2f9b8ff00c ("Cygwin:
decouple cygheap from Cygwin DLL").  With 2f9b8ff00c, the cygheap
actually doesn't exist until after the call to cygheap_fixup_in_child().

Fix this problem by moving the assignment after the call to
cygheap_fixup_in_child().

Fixes: 3de7be4c1d ("* DevNotes: Add entry cgf-000007. [...]")
Fixes: 2f9b8ff00c ("Cygwin: decouple cygheap from Cygwin DLL")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-01 22:34:53 +01:00
Corinna Vinschen e358f8d12f Cygwin: multiple_cygwin_problem: drop obsolete check for "cygheap"
After decoupling cygheap from the DLL loading address, the check
for a different _cygheap_start has gone.  So the matching string
check in multiple_cygwin_problem is obsolete now.

Fixes: 2f9b8ff00c ("Cygwin: decouple cygheap from Cygwin DLL")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-01 21:20:53 +01:00
Corinna Vinschen 2f9b8ff00c Cygwin: decouple cygheap from Cygwin DLL
One reason that ASLR is tricky is the fact that the cygheap
is placed at the end of the DLL and especially that it's expected
to be growable.  To support ASLR, this construct must go.

Define dedicated cygheap memory region and reserve entire region.
Commit 3 Megs, as was the default size of the cygheap before.

Fix linker script accordingly, drop a now useless version check
in get_cygwin_startup_info().
2022-10-28 16:26:53 +02:00
Corinna Vinschen 48a210a457 Cygwin: debugging: convert muto to SRWLOCK
this avoids having to call debug_init, because the SRWLOCK
is statically initialized.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-22 14:38:49 +02:00
Corinna Vinschen 782ef53619 Cygwin: rename CygwinCreateThread to create_posix_thread
Rename CygwinCreateThread to create_posix_thread and move
from miscfuncs.cc to create_posix_thread.cc, inbcluding all
related functions.  Analogue for the prototypes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-10 18:06:28 +02:00
Corinna Vinschen 7073ef4e8f Cygwin: drop __stdcall usage
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 20:54:09 +02:00
Corinna Vinschen 7ad791c1ee Cygwin: drop macro and code for CYGWIN_VERSION_DLL_EPOCH
fix a comment in check_sanity_and_sync() on the way

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 16:16:14 +02:00
Corinna Vinschen 7f42498be6 Cygwin: rename __cygwin_environ and drop env redirection via cur_environ()
Back in early Cygwin development a function based access to the
environment was exported, the internal environ in Cygwin was called
__cygwin_environ and cur_environ() was used to access the environment
indirectly .  The history of that necessity is not documented,
but kept in i686 for backward compatibility.

The x86_64 port eventually used __cygwin_environ directly and exported
it as DATA under the usual name environ.

We don't need the i686 workaround anymore, so just rename
__cygwin_environ to environ, drop the cur_environ() macro and
simply export environ under its own name.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-28 22:00:40 +02:00
Corinna Vinschen 5192d5ea51 Cygwin: _dll_crt0: minimize target-specific conditional code
Only the assembler snippet is really x86_64-specific, so minimize the
conditional code block to this snippet.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-14 20:08:58 +02:00
Matt Joyce f89ce35d83 Add _REENT_CLEANUP(ptr)
Add a _REENT_CLEANUP() macro to encapsulate access to the
__cleanup member of struct reent. This will help to replace the
struct member with a thread-local storage object in a follow up
patch.
2022-07-13 06:55:46 +02:00
Ken Brown ddce45112d Cygwin: restore one more '#ifdef __x86_64__' 2022-06-11 08:56:08 -04:00
Ken Brown 07cf763095 Cygwin: restore two instances of __stdcall
In the previous commit, __stdcall was removed from _dll_crt0 in
winsup.h and dcrt0.cc but not in lib/cygwin_crt0.c.  For consistency,
restore the first two occurrences of __stdcall.  We could instead
remove it from the declaration in lib/cygwin_crt0.c, but this might
appear to affect binary compatibility, even though it really doesn't.
2022-06-07 13:46:31 -04:00
Ken Brown 30c5411d07 Cygwin: remove most occurrences of __stdcall and __cdecl
These have no effect on x86_64.  Retain a few occurrences of __cdecl
in files imported from other sources.

Also retain all occurrences of WINAPI, even though the latter is
simply a macro that expands to __stdcall.  Most of these occurrences
are associated with Windows API functions, and removing them might
make the code confusing instead of simpler.
2022-06-06 12:00:45 -04:00
Ken Brown e1ce752a1d Cygwin: remove miscellaneous 32-bit code 2022-05-29 17:54:32 -04:00
Ken Brown f6bb8bfaa0 Cygwin: remove some 32-bit only environment code 2022-05-29 17:45:52 -04:00
Ken Brown 2126f966ae Cygwin: remove regparm.h
This file defines the macros __reg1, __reg2, and __reg3, which are
defined to be empty on 64-bit Cygwin.  Remove all occurrences of these
macros.
2022-05-29 17:45:52 -04:00
Corinna Vinschen 24363cffef Cygwin: drop system_wow64_directory and related code
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 14:28:49 +02:00
Corinna Vinschen d4fa3b4abb Cygwin: config.h: stop including auto-generated tlsoffsets.h file
This was a hack to begin with.  Clean this mess up:

- Move definition of CYGTLS_PADSIZE to cygwin/config.h and drop
  local cygtls_padsize.h
- Rename CYGTLS_PADSIZE to __CYGTLS_PADSIZE__ to keep namespace
  clean.  Redefine as macro, rather than as const.
- Move struct _reent first in struct _cygtls to allow using
  __CYGTLS_PADSIZE__ as offset in __getreent().

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 13:58:39 +02:00
Corinna Vinschen d02421e7f7 Cygwin: switch to _REENT_GLOBAL_STDIO_STREAMS
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 13:41:13 +02:00
Sebastian Huber ad51d0006a Remove _global_impure_ptr indirection
Remove the pointer indirection through the read-only _global_impure_ptr and
directly use a externally visible _impure_data object of type struct _reent.
This enables the static initialization of global data structures in a follow up
patch.  In addition, we get rid of a machine-specific file.
2022-05-04 17:31:04 +02:00
Corinna Vinschen 5a6de512ab Cygwin: always add sigmask to child info
Even after fork, we might need the parent sigmask without having
access to the real _main_tls. There's a short time at process startup,
when _main_tls points to the system-allocated stack, but wait_sig is
already running. If we can't lock _main_tls, because find_tls can't
find it yet, we now access the parent's sigmask via child_info.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-03 15:16:18 +02:00
Corinna Vinschen b827d4d36a Cygwin: simplify create_new_main_thread_stack
Originally the function was designed to be used in forked
processes as well, but it has never been used this way. Drop
the parameter only required for forkees.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-03 14:39:28 +02:00
Matt Joyce 44b60f0c4b Make __sdidinit unused
Remove dependency on __sdidinit member of struct _reent to check
object initialization. Like __sdidinit, the __cleanup member of
struct _reent is initialized in the __sinit() function. Checking
initialization against __cleanup serves the same purpose and will
reduce overhead in the __sfp() function in a follow up patch.
2022-02-22 12:38:46 +01:00
Corinna Vinschen 44a79a6eca Cygwin: convert malloc lock to SRWLOCK
Per https://cygwin.com/pipermail/cygwin-developers/2021-October/012429.html,
we may encounter a crash when starting multiple threads during process
startup (here: fhandler_fifo::fixup_after_{fork,exec}) which in turn
allocate memory via malloc.

The problem is concurrent usage of malloc before the malloc muto has
been initialized.

To fix this issue, convert the muto to a SRWLOCK and make sure it is
statically initalized.  Thus, malloc can be called as early as necessary
and malloc_init is only required to check for user space provided malloc.

Note that this requires to implement a __malloc_trylock macro to be
called from fork.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-10-26 18:47:22 +02:00
Corinna Vinschen 44eb416323 Cygwin: fetch Windows directory on all platforms and use throughout
Rather than fetching the system Windows directory at dll init time
only on 32 bit, fetch it on all platforms.  Store as WCHAR and
UNICODE_STRING.  Use where appropriate to simplify code.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-05-07 23:05:24 +02:00
Corinna Vinschen 13fd26ecf5 Cygwin: skip native symlink check in Windows dir under WOW64
Commit 456c3a4638 added a workaround when handling paths with native
symlinks as inner path components.  This patch introduced a problem for
paths handled by the WOW64 File System Redirector (FSR).

Fix this problem by not performing the new code from commit 456c3a4638
for paths under the Windows directory.  Only do this in WOW64.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-21 17:41:08 +02:00
Corinna Vinschen 81137c50d1 Cygwin: fix fenv.h includes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-13 12:55:34 +02:00
Corinna Vinschen cc19109af9 Cygwin: don't export _feinitialise from newlib
Use the more official fesetenv(FE_DFL_ENV) from _dll_crt0, thus
allowing to drop the _feinitialise declaration from fenv.h.

Provide a no-op _feinitialise in Cygwin as exportable symbol for really
old applications when _feinitialise was called from mainCRTStartup in
crt0.o.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-13 12:55:34 +02:00
Corinna Vinschen 50ad198085 Cygwin: Add 'fallthrough' pseudo keyword for switch/case use
This patch has been inspired by the Linux kernel patch

  294f69e662d1 compiler_attributes.h: Add 'fallthrough' pseudo keyword for switch/case use

written by Joe Perches <joe AT perches DOT com> based on an idea from
Dan Carpenter <dan DOT carpenter AT oracle DOT com>.  The following text
is from the original log message:

Reserve the pseudo keyword 'fallthrough' for the ability to convert the
various case block /* fallthrough */ style comments to appear to be an
actual reserved word with the same gcc case block missing fallthrough
warning capability.

All switch/case blocks now should end in one of:

	break;
	fallthrough;
	goto <label>;
	return [expression];
	continue;

In C mode, GCC supports the __fallthrough__ attribute since 7.1,
the same time the warning and the comment parsing were introduced.

Cygwin-only: add an explicit -Wimplicit-fallthrough=5 to the build
flags.
2020-08-05 21:58:22 +02:00
Corinna Vinschen 3bb346d593 Cygwin: fix formatting: collapse whitespace-only lines
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-03-11 13:45:58 +01:00
Corinna Vinschen 3a72edc124 Cygwin: Fix the address of myself
Introducing an independent Cygwin PID introduced a regression:

The expectation is that the myself pinfo pointer always points to a
specific address right in front of the loaded Cygwin DLL.

However, the independent Cygwin PID changes broke this.  To create
myself at the right address requires to call init with h0 set to
INVALID_HANDLE_VALUE or an existing address:

void
pinfo::init (pid_t n, DWORD flag, HANDLE h0)
{
  [...]
  if (!h0 || myself.h)
    [...]
  else
    {
      shloc = SH_MYSELF;
      if (h0 == INVALID_HANDLE_VALUE)       <-- !!!
        h0 = NULL;
    }

The aforementioned commits changed that so h0 was always NULL, this way
creating myself at an arbitrary address.

This patch makes sure to set the handle to INVALID_HANDLE_VALUE again
when creating a new process, so init knows that myself has to be created
in the right spot.  While at it, fix a potential uninitialized handle
value in child_info_spawn::handle_spawn.

Fixes: b5e1003722 ("Cygwin: processes: use dedicated Cygwin PID rather than Windows PID")
Fixes: 88605243a1 ("Cygwin: fix child getting another pid after spawnve")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-07-25 10:45:52 +02:00
Michael Haubenwallner 023c107a22 Cygwin: fork: reserve dynloaded dll areas earlier
In dll_crt0_0, both threadinterface->Init and sigproc_init allocate
windows object handles using unpredictable memory regions, which may
collide with dynamically loaded dlls when they were relocated.
2019-03-28 10:09:53 +01:00
Corinna Vinschen 88605243a1 Cygwin: fix child getting another pid after spawnve
When calling spawnve, in contrast to execve, the parent has
to create the pid for the child.  With the old technique
this was simply the Windows pid, but now we have to inform
the child about its new pid.

Add a cygpid member to class child_info_spawn.  Set it in
child_info_spawn::worker, just prior to calling CreateProcess
rather than afterwards.  Overwrite cygheap->pid in
child_info_spawn::handle_spawn before calling pinfo::thisproc.
Make sure pinfo::thisproc knows the pid is already set by
setting the handle argument to INVALID_HANDLE_VALUE.

Also set procinfo->dwProcessId to myself_initial.dwProcessId
instead of to myself_initial.pid for clarity.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-08 15:49:47 +01:00
Michael Haubenwallner ece7282f32 forkables: On fork failure, retry with hardlinks.
To support in-cygwin package managers, the fork() implementation must
not rely on .exe and .dll files to stay in their original location, as
the package manager's job is to replace these files.  Instead, when the
first fork try fails, and we have NTFS, we use hardlinks to the original
binaries in /var/run/cygfork/ to create the child process during the
second fork try, along the main.exe.local file to enable the "DotLocal
Dll Redirection" feature for the dlls.

The (probably few) users that need an update-safe fork manually have to
create the /var/run/cygfork/ directory for now, using:
mkdir --mode=a=rwxt /var/run/cygfork

	* child_info.h: Bump CURR_CHILD_INFO_MAGIC.
	(enum child_status): Add _CI_SILENTFAIL flag.
	(struct child_info): Add silentfail setter and getter.
	* winsup.h (child_copy): Add bool silentfail parameter.
	* cygheap.cc: Pass silentfail parameter to child_copy.
	* dcrt0.cc: Ditto.
	* dll_init.h (struct dll): Define public inline method forkedntname.
	(struct dll_list): Declare private method find_by_forkedntname.
	* dll_init.cc (struct dll_list): Implement find_by_forkedntname.
	(dll_list::alloc): Use find_by_forkedntname when in load after fork.
	(dll_list::load_after_fork_impl): Load dlls using dll::forkedntname.
	* fork.cc (frok::parent): Set silentfail child info flag.  Pass
	silentfail parameter to child_copy.  Use forkedntname of
	dlls.main_executable.
	(fork): When first dofork run failed and did not use forkables,
	run dofork again with_forkables set to true.
	(child_copy): Use debug_printf if silentfail is true,
	system_printf otherwise.
2019-02-07 15:58:02 +01:00
Corinna Vinschen b5e1003722 Cygwin: processes: use dedicated Cygwin PID rather than Windows PID
Using the Windows PID as Cygwin PID has a few drawbacks:

- the PIDs on Windows get reused quickly.  Some POSIX applications choke
  on that, so we need extra code to avoid too quick PID reuse.

- The code to avoid PID reuse keeps parent process handles and
  (depending on a build option) child processes open unnecessarily.

- After an execve, the process has a split personality:  Its Windows PID
  is a new PID, while its Cygwin PID is the PID of the execve caller
  process.  This requires to keep two procinfo shared sections open, the
  second just to redirect process info requests to the first, correct
  one.

This patch changes the way Cygwin PIDs are generated:

- Cygwin PIDs are generated independently of the Windows PID, in a way
  expected by POSIX processes.  The PIDs are created incrementally in
  the range between 2 and 65535, round-robin.

- On startup of the first Cygwin process, choose a semi-random start PID
  for the first process in the lower PID range to make the PIDs slightly
  unpredictable.  This may not be necessary but it seems kind of inviting
  to know that the first Cygwin process always starts with PID 2.

- Every process not only creates the shared procinfo section, but also a
  symlink in the NT namespace, symlinking the Windows PID to the Cygwin
  PID.  This drops the need for the extra procinfo section after execve.

- Don't keep other process handles around unnecessarily.

- Simplify the code creating/opening the shared procinfo section and
  make a clear distinction between interfaces getting a Cygwin PID and
  interfaces getting a Windows PID.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-01 20:06:47 +01:00
Corinna Vinschen 4d738e0f62 Cygwin: execve: reduce parent handle to non-inheritable SYNCHRONIZE
Keeping an inheritable handle open results in that handle being
spilled over into grandchild processes, which is not desired.
Duplicate original parent handle into a non-inheritable one with
minimal SYNCHRONIZE permissions and close the original handle.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-29 20:37:00 +01:00
Corinna Vinschen 3b21333172 Cygwin: spawn: revert incorrect restriction of permissions
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-27 22:42:41 +01:00
Corinna Vinschen 69cc7a0686 Cygwin: fork: restrict parent handle perms and drop handle after use
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-27 13:15:31 +01:00
Corinna Vinschen 76f06705be cygwin: convert most #ifndef __x86_64__ to #ifdef __i386__
Address the real offender

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-27 14:36:06 +01:00
Corinna Vinschen 35d344babe _dll_crt0: Drop incorrect check for being started from parent main thread
This test was broken from the start.  It leads to creating a completely
new stack for the main thread of the child process when started from
the main thread of the parent.  However, the main thread of a process
can easily running on a completely different stack, if the parent's main
thread was created by calling fork() from a pthread.  For an example,
see https://cygwin.com/ml/cygwin/2017-03/msg00113.html

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-10 20:28:09 +01:00
Jon Turney 9e0f9ec7ae Send thread names to debugger
GDB since commit 24cdb46e [1] can report and use these names.

Add utility function SetThreadName(), which sends a thread name to the
debugger.

Use that:
- to set the default thread name for main thread and newly created pthreads.
- in pthread_setname_np() for user thread names.
- for helper thread names in cygthread::create()
- for helper threads which are created directly with CreateThread.

Note that there can still be anonymous threads, created by system or
injected DLLs.

[1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=24cdb46e9f0a694b4fbc11085e094857f08c0419
2016-08-23 15:07:42 +01:00
Corinna Vinschen a68ca43b90 Redefine locale info in struct _reent for per-thread locales
The _reent members _current_category and _current_locale are not
used at all.  _current_locale is set to "C" in various points of
the code but its value is just as unused as _current_category.

This patch redefines these members without changing the size of the
structure to allow for an implementation of per-thread locales per
POSIX-1.2008 (i.e. uselocale and usage of the per-thread locale in
subsequent function calls).

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-07-06 15:41:35 +02:00
Corinna Vinschen 23a556f2c5 Drop has_set_thread_stack_guarantee flag 2016-06-24 16:02:40 +02:00
Corinna Vinschen bd4339e2a2 Drop wow64_has_secondary_stack flag 2016-06-24 15:49:45 +02:00
Corinna Vinschen 6e623e9320 Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option
Bump GPLv2+ to GPLv3+ for some files, clarify BSD 2-clause.

Everything else stays under GPLv3+.

New Linking Exception exempts resulting executables from LGPLv3 section 4.

Add CONTRIBUTORS file to keep track of licensing.

Remove 'Copyright Red Hat Inc' comments.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-23 10:09:17 +02:00
Corinna Vinschen 8e732f7f7f Remove MALLOC_CHECK and calls to it entirely
MALLOC_CHECK got useless with commit b259af5.  Remove it throughout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-01 14:04:09 +02:00
Peter Foley b259af51b8 Remove remnants of never-defined MALLOC_DEBUG and NEWVFORK
MALLOC_DEBUG and NEWVFORK haven't been defined since 2008 (4616253751).
Remove all references to tem.

winsup/cygwin/ChangeLog:
acconfig.h: delete
dcrt0.cc (dll_crt0_1): remove NEWVFORK code.
dcrt0.cc (do_exit): ditto.
debug.h: ditto.
dtable.h: ditto.
winsup.h: ditto.
globals.cc: ditto.
malloc_wrapper.cc: ditto.
malloc_wrapper.cc (malloc_init): ditto.
spawn.cc (spawnve): ditto.
syscalls.cc (setsid): ditto.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-04-01 13:53:25 +02:00
Johannes Schindelin e0d4e3fec7 Do not treat the command line or environment like paths
* dcrt0.cc (dll_crt0_1), environ.cc (environ_init, getwinenveq,
	build_env), strfuncs.cc (sys_wcstombs, sys_wcstombs_alloc),
	wchar.c (sys_wcstombs, sys_wcstombs_alloc): avoid mis-conversions
	of text that does not, actually, refer to a path or file name

Detailed explanation:

Our WCS -> UTF conversion handles the private Unicode page specially
to allow for otherwise invalid file names. However, this handling makes
no sense for command-lines, nor environment variables, which we would
rather convert verbatim.

As a stop-gap solution, let's just introduce a version of the
sys_wcstombs() function that specifically excludes that file name
conversion magic.

The proper solution is to change sys_wcstombs() to assume that it is not
a path that wants to be converted, and introduce sys_wcstombs_path()
that does, but that is a bigger task which we leave for another patch.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-01-08 15:17:52 +01:00
Corinna Vinschen 87db9e0680 Fix minor style issue in _dll_crt0.
Fix missing space.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-07 18:41:15 +01:00
Corinna Vinschen e753e4129a Always allocate main thread stack from pthread stack area on x86_64.
* dcrt0.cc: Semi-revert commit 12743c2d5d.
        (dll_crt0_0): Drop setting wow64_needs_stack_adjustment on 64 bit.
        (_dll_crt0): Split out 64 bit code again and always create new main
        thread stack, unless forked off from the non main thread in the parent.
        Call create_new_main_thread_stack with parent stack commitsize if
        started from the parent's main thread.
        Only call child_info_fork::alloc_stack for the latter case on 64 bit.
        Slightly rearrange moving rsp and rbp to new stack and document how.
        Revert 32 bit wow64 handling to its former self.
        * miscfunc.cc (create_new_main_thread_stack): Take a commitsize
        parameter and use it if it's not 0.  Don't set _main_tls here, it's
        done in the caller _dll_crt0 anyway.  Return stackbase - 16 bytes,
        rather than stacklimit (which was very wrong anyway).
        * miscfuncs.h (create_new_main_thread_stack): Accommodate declaration
        to aforementioned change.
        * wincap.h (wincaps::has_3264_stack_broken): Remove element.
        * wincap.cc: Ditto, throughout.
        * wow64.cc: Semi-revert to pre-12743c2d5d2721f3a80b4d7671a349be03c1f520
        but keep architecture-agnostic type changes intact.  Fix formatting.
        * wow64.h: Revert to pre-12743c2d5d2721f3a80b4d7671a349be03c1f520.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-07 16:10:55 +01:00