[lld] 20b2d32 - [lld-macho] Work around odr-use of const non-inline static data member to fix -O0 build after D128298

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 21 19:22:34 PDT 2022


Author: Fangrui Song
Date: 2022-06-21T19:22:28-07:00
New Revision: 20b2d3260d4a1878ca2a37cee6ee335a21a12d0f

URL: https://github.com/llvm/llvm-project/commit/20b2d3260d4a1878ca2a37cee6ee335a21a12d0f
DIFF: https://github.com/llvm/llvm-project/commit/20b2d3260d4a1878ca2a37cee6ee335a21a12d0f.diff

LOG: [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)
```

Added: 
    

Modified: 
    lld/MachO/SyntheticSections.cpp

Removed: 
    


################################################################################
diff  --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index 4d7256e847fa..dabe158d97f5 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<size_t>(fileOff - i * blockSize), blockSize),
+           std::min(static_cast<size_t>(fileOff - i * blockSize),
+                    static_cast<size_t>(blockSize)),
            hashes + i * hashSize);
   });
 #if defined(__APPLE__)


        


More information about the llvm-commits mailing list