mirror of
https://github.com/mirror/tinycc.git
synced 2026-08-22 11:23:27 +08:00
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:
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user