Call __bound_main_arg at startup

This uses a glibc feature present since constructor/destructor support was added.

Modify tccrun.c to call constructor with argc, argcv, envp.
In lib/bcheck.c use these values to register them in the splay tree.
Remove HAS_ENVIRON is lib/bcheck.c as it is not needed any more.
Modify win32/lib/crt1.c/win32/lib/dllcrt1.c/win32/lib/wincrt1.c to also
call constructor with argc, argcv, envp.
While implementing I saw that tccrun did nog call main with envp. Fixed it.
Also fix fetch_and_add_arm.S to make it work on armv6 (raspberry pi default).
This commit is contained in:
herman ten brugge
2020-06-22 14:55:27 +02:00
parent 0262f0eb1e
commit 039e4ec2a4
6 changed files with 62 additions and 60 deletions

View File

@@ -34,8 +34,8 @@ int __cdecl __tgetmainargs(int *pargc, _TCHAR ***pargv, _TCHAR ***penv, int glob
void __cdecl __set_app_type(int apptype);
unsigned int __cdecl _controlfp(unsigned int new_value, unsigned int mask);
extern int _tmain(int argc, _TCHAR * argv[], _TCHAR * env[]);
extern void (*__init_array_start[]) (void);
extern void (*__init_array_end[]) (void);
extern void (*__init_array_start[]) (int argc, char **argv, char **envp);
extern void (*__init_array_end[]) (int argc, char **argv, char **envp);
extern void (*__fini_array_start[]) (void);
extern void (*__fini_array_end[]) (void);
@@ -46,7 +46,11 @@ static int do_main (int argc, _TCHAR * argv[], _TCHAR * env[])
i = 0;
while (&__init_array_start[i] != __init_array_end) {
(*__init_array_start[i++])();
#ifdef UNICODE
(*__init_array_start[i++])(0, NULL, NULL);
#else
(*__init_array_start[i++])(argc, argv, env);
#endif
}
retval = _tmain(__argc, __targv, _tenviron);
i = 0;

View File

@@ -2,8 +2,8 @@
#include <windows.h>
extern void (*__init_array_start[]) (void);
extern void (*__init_array_end[]) (void);
extern void (*__init_array_start[]) (int argc, char **argv, char **envp);
extern void (*__init_array_end[]) (int argc, char **argv, char **envp);
extern void (*__fini_array_start[]) (void);
extern void (*__fini_array_end[]) (void);
@@ -17,7 +17,7 @@ BOOL WINAPI _dllstart(HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved)
if (dwReason == DLL_PROCESS_ATTACH) { /* ignore DLL_THREAD_ATTACH */
i = 0;
while (&__init_array_start[i] != __init_array_end) {
(*__init_array_start[i++])();
(*__init_array_start[i++])(0, NULL, NULL);
}
}
if (dwReason == DLL_PROCESS_DETACH) { /* ignore DLL_THREAD_DETACH */

View File

@@ -23,8 +23,8 @@ int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int);
#define _runtwinmain _runwinmain
#endif
extern void (*__init_array_start[]) (void);
extern void (*__init_array_end[]) (void);
extern void (*__init_array_start[]) (int argc, char **argv, char **envp);
extern void (*__init_array_end[]) (int argc, char **argv, char **envp);
extern void (*__fini_array_start[]) (void);
extern void (*__fini_array_end[]) (void);
@@ -57,7 +57,11 @@ static int go_winmain(TCHAR *arg1)
#endif
i = 0;
while (&__init_array_start[i] != __init_array_end) {
(*__init_array_start[i++])();
#ifdef UNICODE
(*__init_array_start[i++])(0, NULL, NULL);
#else
(*__init_array_start[i++])(__argc, __targv, _tenviron);
#endif
}
retval = _tWinMain(GetModuleHandle(NULL), NULL, szCmd, fShow);
i = 0;