mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-21 05:40:09 +08:00
039e4ec2a4
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).
33 lines
1006 B
C
33 lines
1006 B
C
//+---------------------------------------------------------------------------
|
|
|
|
#include <windows.h>
|
|
|
|
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);
|
|
|
|
BOOL WINAPI DllMain (HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved);
|
|
|
|
BOOL WINAPI _dllstart(HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved)
|
|
{
|
|
BOOL bRet;
|
|
int i;
|
|
|
|
if (dwReason == DLL_PROCESS_ATTACH) { /* ignore DLL_THREAD_ATTACH */
|
|
i = 0;
|
|
while (&__init_array_start[i] != __init_array_end) {
|
|
(*__init_array_start[i++])(0, NULL, NULL);
|
|
}
|
|
}
|
|
if (dwReason == DLL_PROCESS_DETACH) { /* ignore DLL_THREAD_DETACH */
|
|
i = 0;
|
|
while (&__fini_array_end[i] != __fini_array_start) {
|
|
(*__fini_array_end[--i])();
|
|
}
|
|
}
|
|
bRet = DllMain (hDll, dwReason, lpReserved);
|
|
return bRet;
|
|
}
|
|
|