From 20b2d3260d4a1878ca2a37cee6ee335a21a12d0f Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 21 Jun 2022 19:22:28 -0700 Subject: [PATCH] [lld-macho] Work around odr-use of const non-inline static data member to fix -O0 build after D128298 ``` ld.lld: error: undefined symbol: lld::macho::CodeSignatureSection::blockSize >>> referenced by SyntheticSections.cpp:1253 (/home/maskray/llvm/lld/MachO/SyntheticSections.cpp:1253) >>> tools/lld/MachO/CMakeFiles/lldMachO.dir/SyntheticSections.cpp.o:(lld::macho::CodeSignatureSection::writeHashes(unsigned char*) const::$_7::operator()(unsigned long) const) ``` --- lld/MachO/SyntheticSections.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp index 4d7256e..dabe158 100644 --- a/lld/MachO/SyntheticSections.cpp +++ b/lld/MachO/SyntheticSections.cpp @@ -1250,7 +1250,8 @@ void CodeSignatureSection::writeHashes(uint8_t *buf) const { uint8_t *hashes = buf + fileOff + allHeadersSize; parallelFor(0, getBlockCount(), [&](size_t i) { sha256(buf + i * blockSize, - std::min(static_cast(fileOff - i * blockSize), blockSize), + std::min(static_cast(fileOff - i * blockSize), + static_cast(blockSize)), hashes + i * hashSize); }); #if defined(__APPLE__) -- 2.7.4