From: Yuxuan Shui <yshui@codeweavers.com> --- dlls/winecrt0/Makefile.in | 2 ++ dlls/winecrt0/initterm.c | 40 +++++++++++++++++++++++++++++++++++++ dlls/winecrt0/initterm_e.c | 41 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 dlls/winecrt0/initterm.c create mode 100644 dlls/winecrt0/initterm_e.c diff --git a/dlls/winecrt0/Makefile.in b/dlls/winecrt0/Makefile.in index 29cd88f8637..e594e532929 100644 --- a/dlls/winecrt0/Makefile.in +++ b/dlls/winecrt0/Makefile.in @@ -18,6 +18,8 @@ SOURCES = \ exe_main.c \ exe_wentry.c \ exe_wmain.c \ + initterm.c \ + initterm_e.c \ register.c \ setjmp.c \ stub.c \ diff --git a/dlls/winecrt0/initterm.c b/dlls/winecrt0/initterm.c new file mode 100644 index 00000000000..fc892e0039e --- /dev/null +++ b/dlls/winecrt0/initterm.c @@ -0,0 +1,40 @@ +/* + * _initterm fallback implementation + * + * Copyright 2025 Yuxuan Shui for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <process.h> +#include "minwindef.h" + +#include "wine/asm.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++; + } +} + +__ASM_GLOBAL_IMPORT(_initterm) diff --git a/dlls/winecrt0/initterm_e.c b/dlls/winecrt0/initterm_e.c new file mode 100644 index 00000000000..829fada3b14 --- /dev/null +++ b/dlls/winecrt0/initterm_e.c @@ -0,0 +1,41 @@ +/* + * _initterm_e fallback implementation + * + * Copyright 2025 Yuxuan Shui for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <process.h> +#include "minwindef.h" + +#include "wine/asm.h" + +/* 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; +} + +__ASM_GLOBAL_IMPORT(_initterm_e) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9265