From: Yuxuan Shui <yshui@codeweavers.com> --- configure | 2 ++ configure.ac | 1 + dlls/winecrtend/Makefile.in | 4 ++++ dlls/winecrtend/initterm.c | 18 ++++++++++++++++++ dlls/winecrtend/initterm_e.c | 16 ++++++++++++++++ tools/makedep.c | 2 ++ tools/winegcc/winegcc.c | 1 + 7 files changed, 44 insertions(+) create mode 100644 dlls/winecrtend/Makefile.in create mode 100644 dlls/winecrtend/initterm.c create mode 100644 dlls/winecrtend/initterm_e.c diff --git a/configure b/configure index a6fb235e2ed..6201d7eabc9 100755 --- a/configure +++ b/configure @@ -1541,6 +1541,7 @@ enable_winebth_sys enable_winebus_sys enable_winecoreaudio_drv enable_winecrt0 +enable_winecrtend enable_wined3d enable_winedmo enable_winegstreamer @@ -23217,6 +23218,7 @@ wine_fn_config_makefile dlls/winebth.sys enable_winebth_sys wine_fn_config_makefile dlls/winebus.sys enable_winebus_sys wine_fn_config_makefile dlls/winecoreaudio.drv enable_winecoreaudio_drv wine_fn_config_makefile dlls/winecrt0 enable_winecrt0 +wine_fn_config_makefile dlls/winecrtend enable_winecrtend wine_fn_config_makefile dlls/wined3d enable_wined3d wine_fn_config_makefile dlls/winedmo enable_winedmo wine_fn_config_makefile dlls/winegstreamer enable_winegstreamer diff --git a/configure.ac b/configure.ac index b8ae3db64a0..8c3cbad16f9 100644 --- a/configure.ac +++ b/configure.ac @@ -3359,6 +3359,7 @@ WINE_CONFIG_MAKEFILE(dlls/winebth.sys) WINE_CONFIG_MAKEFILE(dlls/winebus.sys) WINE_CONFIG_MAKEFILE(dlls/winecoreaudio.drv) WINE_CONFIG_MAKEFILE(dlls/winecrt0) +WINE_CONFIG_MAKEFILE(dlls/winecrtend) WINE_CONFIG_MAKEFILE(dlls/wined3d) WINE_CONFIG_MAKEFILE(dlls/winedmo) WINE_CONFIG_MAKEFILE(dlls/winegstreamer) diff --git a/dlls/winecrtend/Makefile.in b/dlls/winecrtend/Makefile.in new file mode 100644 index 00000000000..d0f04e50baa --- /dev/null +++ b/dlls/winecrtend/Makefile.in @@ -0,0 +1,4 @@ +STATICLIB = libwinecrtend.a +SOURCES = \ + initterm.c \ + initterm_e.c diff --git a/dlls/winecrtend/initterm.c b/dlls/winecrtend/initterm.c new file mode 100644 index 00000000000..448456e0f9f --- /dev/null +++ b/dlls/winecrtend/initterm.c @@ -0,0 +1,18 @@ +#include <process.h> +#include "minwindef.h" + +/* This is a fallback version of msvcrt's _initterm. Since _initterm is used in winecrt0, + * if the final object is linked with a version of msvcrt without the _initterm function, this + * version will be used. */ +void CDECL _initterm( _PVFV *start,_PVFV *end ) +{ + _PVFV* current = start; + + while (current<end) + { + if (*current) + (**current)(); + current++; + } +} + diff --git a/dlls/winecrtend/initterm_e.c b/dlls/winecrtend/initterm_e.c new file mode 100644 index 00000000000..f1d9ee65a61 --- /dev/null +++ b/dlls/winecrtend/initterm_e.c @@ -0,0 +1,16 @@ +typedef int (__cdecl *_PIFV)(void); + +/* This is a fallback version of msvcrt's _initterm_e. Since _initterm_e is used in winecrt0, + * if the final object is linked with a version of msvcrt without the _initterm_e function, this + * version will be used. */ +int __cdecl _initterm_e(_PIFV *table, _PIFV *end) +{ + int res = 0; + + while (!res && table < end) { + if (*table) + res = (**table)(); + table++; + } + return res; +} diff --git a/tools/makedep.c b/tools/makedep.c index efc7517f0c8..f491ecf1930 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -2279,6 +2279,7 @@ static struct strarray get_default_imports( const struct makefile *make, struct STRARRAY_FOR_EACH( imp, &imports ) if (!strcmp( imp, "winecrt0" )) return ret; strarray_add( &ret, "winecrt0" ); if (compiler_rt) strarray_add( &ret, compiler_rt ); + strarray_add( &ret, "winecrtend" ); return ret; } @@ -2293,6 +2294,7 @@ static struct strarray get_default_imports( const struct makefile *make, struct strarray_add( &ret, "kernel32" ); strarray_add( &ret, "ntdll" ); + strarray_add( &ret, "winecrtend" ); return ret; } diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index f5eb2a81d83..b1f36a29a67 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -1337,6 +1337,7 @@ static void build(struct strarray input_files, const char *output) if (is_win16_app) add_library(lib_dirs, &files, "kernel"); add_library(lib_dirs, &files, "kernel32"); add_library(lib_dirs, &files, "ntdll"); + add_library(lib_dirs, &files, "winecrtend"); } /* set default entry point, if needed */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9265