Based on mingw-w64.
System modules on Windows have load config available. In fact, all applications using the default MSVC for crt have it. mingw-w64 provides the load config, but it also requires linker to use it and currently only LLD supports it. This MR does the same in winecrt0. We will need it on both ARM64 and ARM64EC targets to support ARM64X (which requires LLD for other reasons anyway).
From: Jacek Caban jacek@codeweavers.com
Based on mingw-w64. --- dlls/winecrt0/Makefile.in | 1 + dlls/winecrt0/arm64ec.c | 24 +-------- dlls/winecrt0/load_config.c | 98 +++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 23 deletions(-) create mode 100644 dlls/winecrt0/load_config.c
diff --git a/dlls/winecrt0/Makefile.in b/dlls/winecrt0/Makefile.in index 863e5ed4190..d129a009400 100644 --- a/dlls/winecrt0/Makefile.in +++ b/dlls/winecrt0/Makefile.in @@ -17,6 +17,7 @@ SOURCES = \ exe_main.c \ exe_wentry.c \ exe_wmain.c \ + load_config.c \ register.c \ setjmp.c \ stub.c \ diff --git a/dlls/winecrt0/arm64ec.c b/dlls/winecrt0/arm64ec.c index 949de0a4e0c..e4250e78de2 100644 --- a/dlls/winecrt0/arm64ec.c +++ b/dlls/winecrt0/arm64ec.c @@ -102,26 +102,4 @@ asm( "\t.section .rdata,"dr"\n" "\t.rva __os_arm64x_helper7\n" "\t.rva __os_arm64x_helper8\n" );
-asm( "\t.section .rdata,"dr"\n" - "\t.globl _load_config_used\n" - "\t.balign 8\n" - "_load_config_used:\n" - "\t.word 0x140\n" - "\t.fill 0x54, 1, 0\n" - "\t.xword 0\n" /* FIXME: __security_cookie */ - "\t.fill 0x10, 1, 0\n" - "\t.xword __guard_check_icall_fptr\n" - "\t.xword __guard_dispatch_icall_fptr\n" - "\t.xword __guard_fids_table\n" - "\t.xword __guard_fids_count\n" - "\t.xword __guard_flags\n" - "\t.xword 0\n" - "\t.xword __guard_iat_table\n" - "\t.xword __guard_iat_count\n" - "\t.xword __guard_longjmp_table\n" - "\t.xword __guard_longjmp_count\n" - "\t.xword 0\n" - "\t.xword __chpe_metadata\n" - "\t.fill 0x78, 1, 0\n" ); - -#endif /* __arm64ec__ */ +#endif diff --git a/dlls/winecrt0/load_config.c b/dlls/winecrt0/load_config.c new file mode 100644 index 00000000000..0d9e60c9eed --- /dev/null +++ b/dlls/winecrt0/load_config.c @@ -0,0 +1,98 @@ +/* + * Load config support + * + * Copyright 2024 Jacek Caban 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 + */ + +#ifdef __WINE_PE_BUILD + +#include "wine/asm.h" + +#ifdef _WIN64 +#define PTR ".8byte" +#else +#define PTR ".4byte" +#endif + +asm( "\t.section .rdata,"dr"\n" + "\t.globl " __ASM_NAME("_load_config_used") "\n" + "\t.balign 8\n" + __ASM_NAME("_load_config_used") ":\n" + "\t.4byte " __ASM_NAME("_load_config_used_end") "-" __ASM_NAME("_load_config_used") "\n" /* Size */ + "\t.4byte 0\n" /* TimeDateStamp */ + "\t.2byte 0\n" /* MajorVersion */ + "\t.2byte 0\n" /* MinorVersion */ + "\t.4byte 0\n" /* GlobalFlagsClear */ + "\t.4byte 0\n" /* GlobalFlagsSet */ + "\t.4byte 0\n" /* CriticalSectionDefaultTimeout */ + "\t"PTR" 0\n" /* DeCommitFreeBlockThreshold */ + "\t"PTR" 0\n" /* DeCommitTotalFreeThreshold */ + "\t"PTR" 0\n" /* LockPrefixTable */ + "\t"PTR" 0\n" /* MaximumAllocationSize */ + "\t"PTR" 0\n" /* VirtualMemoryThreshold */ + "\t"PTR" 0\n" /* ProcessAffinityMask */ + "\t.4byte 0\n" /* ProcessHeapFlags */ + "\t.2byte 0\n" /* CSDVersion */ + "\t.2byte 0\n" /* DependentLoadFlags */ + "\t"PTR" 0\n" /* EditList */ + "\t"PTR" 0\n" /* SecurityCookie */ + "\t"PTR" 0\n" /* SEHandlerTable */ + "\t"PTR" 0\n" /* SEHandlerCount */ +#ifdef __arm64ec__ + "\t"PTR" "__ASM_NAME("__guard_check_icall_fptr") "\n" /* GuardCFCheckFunctionPointer */ + "\t"PTR" "__ASM_NAME("__guard_dispatch_icall_fptr") "\n" /* GuardCFDispatchFunctionPointer */ +#else + "\t"PTR" 0\n" /* GuardCFCheckFunctionPointer */ + "\t"PTR " 0\n" /* GuardCFDispatchFunctionPointer */ +#endif + "\t"PTR" "__ASM_NAME("__guard_fids_table") "\n" /* GuardCFFunctionTable */ + "\t"PTR" "__ASM_NAME("__guard_fids_count") "\n" /* GuardCFFunctionCount */ + "\t.4byte "__ASM_NAME("__guard_flags") "\n" /* GuardFlags */ + "\t.2byte 0\n" /* CodeIntegrity.Flags */ + "\t.2byte 0\n" /* CodeIntegrity.Catalog */ + "\t.4byte 0\n" /* CodeIntegrity.CatalogOffset */ + "\t.4byte 0\n" /* CodeIntegrity.Reserved */ + "\t"PTR" "__ASM_NAME("__guard_iat_table") "\n" /* GuardAddressTakenIatEntryTable */ + "\t"PTR" "__ASM_NAME("__guard_iat_count") "\n" /* GuardAddressTakenIatEntryCount */ + "\t"PTR" "__ASM_NAME("__guard_longjmp_table") "\n" /* GuardLongJumpTargetTable */ + "\t"PTR" "__ASM_NAME("__guard_longjmp_count") "\n" /* GuardLongJumpTargetCount */ + "\t"PTR" 0\n" /* DynamicValueRelocTable */ +#ifdef __arm64ec__ + "\t"PTR" "__ASM_NAME("__chpe_metadata") "\n" /* CHPEMetadataPointer */ +#else + "\t"PTR" 0\n" /* CHPEMetadataPointer */ +#endif + "\t"PTR" 0\n" /* GuardRFFailureRoutine */ + "\t"PTR" 0\n" /* GuardRFFailureRoutineFunctionPointer */ + "\t.4byte 0\n" /* DynamicValueRelocTableOffset */ + "\t.2byte 0\n" /* DynamicValueRelocTableSection */ + "\t.2byte 0\n" /* Reserved2 */ + "\t"PTR" 0\n" /* GuardRFVerifyStackPointerFunctionPointer */ + "\t.4byte 0\n" /* HotPatchTableOffset */ + "\t.4byte 0\n" /* Reserved3 */ + "\t"PTR" 0\n" /* EnclaveConfigurationPointer */ + "\t"PTR" 0\n" /* VolatileMetadataPointer */ + "\t"PTR" 0\n" /* GuardEHContinuationTable */ + "\t"PTR" 0\n" /* GuardEHContinuationCount */ + "\t"PTR" 0\n" /* GuardXFGCheckFunctionPointer */ + "\t"PTR" 0\n" /* GuardXFGDispatchFunctionPointer */ + "\t"PTR" 0\n" /* GuardXFGTableDispatchFunctionPointer */ + "\t"PTR" 0\n" /* CastGuardOsDeterminedFailureMode */ + "\t"PTR" 0\n" /* GuardMemcpyFunctionPointer */ + __ASM_NAME("_load_config_used_end") ":\n" ); + +#endif /* __WINE_PE_BUILD */
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=143523
Your paranoid android.
=== debian11 (build log) ===
Task: The win32 Wine build failed
=== debian11b (build log) ===
Task: The wow64 Wine build failed