[lld/mac] Replace while loop with for loop

No behavior change. In preparation for using a parallelFor() here.

Differential Revision: https://reviews.llvm.org/D128295
This commit is contained in:
Nico Weber 2022-06-21 15:12:02 -04:00
parent 4cbbb35fcb
commit 3ade3d3724
1 changed files with 5 additions and 8 deletions

View File

@ -1253,14 +1253,11 @@ uint64_t CodeSignatureSection::getRawSize() const {
void CodeSignatureSection::writeHashes(uint8_t *buf) const { void CodeSignatureSection::writeHashes(uint8_t *buf) const {
// NOTE: Changes to this functionality should be repeated in llvm-objcopy's // NOTE: Changes to this functionality should be repeated in llvm-objcopy's
// MachOWriter::writeSignatureData. // MachOWriter::writeSignatureData.
uint8_t *code = buf; uint8_t *hashes = buf + fileOff + allHeadersSize;
uint8_t *codeEnd = buf + fileOff; for (uint64_t i = 0; i < getBlockCount(); ++i) {
uint8_t *hashes = codeEnd + allHeadersSize; sha256(buf + i * blockSize,
while (code < codeEnd) { std::min(static_cast<size_t>(fileOff - i * blockSize), blockSize),
sha256(code, std::min(static_cast<size_t>(codeEnd - code), blockSize), hashes + i * hashSize);
hashes);
code += blockSize;
hashes += hashSize;
} }
#if defined(__APPLE__) #if defined(__APPLE__)
// This is macOS-specific work-around and makes no sense for any // This is macOS-specific work-around and makes no sense for any