[PATCH 0/1] MR11113: imagehlp/tests: Accept zero checksum if the compiler emitted a zero checksum.
Clang (llvm-mingw) emits binaries with a CheckSum of zero in the OptionalHeader. But in this test the call to CheckSumMappedFile with a byte count of 0 relies on the OptionalHeader->CheckSum having some non-zero value. $ llvm-objdump -x dlls/imagehlp/tests/i386-windows/imagehlp_test.exe | grep -E "^CheckSum " CheckSum 00000000 This is observable back to at least llvm-mingw 10.0.0. CC: @mstorsjo -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11113
From: Bernhard Übelacker <bernhardu@mailbox.org> Clang (llvm-mingw) emits binaries with a CheckSum of zero in the OptionalHeader. But in this test the call to CheckSumMappedFile with a byte count of 0 relies on the OptionalHeader->CheckSum having some non-zero value. $ llvm-objdump -x dlls/imagehlp/tests/i386-windows/imagehlp_test.exe | grep -E "^CheckSum " CheckSum 00000000 This is observable back to at least llvm-mingw 10.0.0. --- dlls/imagehlp/tests/integrity.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dlls/imagehlp/tests/integrity.c b/dlls/imagehlp/tests/integrity.c index 4081fa2f6d7..e817176012f 100644 --- a/dlls/imagehlp/tests/integrity.c +++ b/dlls/imagehlp/tests/integrity.c @@ -356,7 +356,10 @@ static void test_pe_checksum(void) ret = CheckSumMappedFile(modinfo.lpBaseOfDll, 0, &checksum_orig, &checksum_new); ok(!ret || (ret == nt_header), "Expected CheckSumMappedFile to fail, got %p\n", ret); ok((checksum_orig == 0xdeadbeef) || (checksum_orig == checksum_correct), "Expected %lx, got %lx\n", checksum_correct, checksum_orig); - ok((checksum_new == 0xdeadbeef) || (checksum_new != 0 && checksum_new != 0xdeadbeef), "Got unexpected value %lx\n", checksum_new); + ok((checksum_new == 0xdeadbeef) || + (checksum_new != 0 && checksum_new != 0xdeadbeef) || + (ret && ret->OptionalHeader.CheckSum == 0 && checksum_new == 0), /* llvm-mingw creates binaries with zero CheckSum */ + "Got unexpected value %lx\n", checksum_new); checksum_orig = checksum_new = 0xdeadbeef; ret = CheckSumMappedFile((char *)modinfo.lpBaseOfDll + 1, 0, -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11113
FWIW, LLD did get the checksum field implemented in https://github.com/llvm/llvm-project/commit/3f55853edf93e1bb2e3c9b38fedfb7b8... (available since LLD 16), but it is only filled in if the lld-link parameter `/release` is passed. If linking through `ld.lld`, there's currently no proper flag for doing this, but one can pass `-Xlink=-release` to pass the flag through to the nested `lld-link` interface. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11113#note_142664
participants (3)
-
Bernhard Übelacker -
Bernhard Übelacker (@bernhardu) -
Martin Storsjö (@mstorsjo)