[PATCH] D139184: [LLD][Windows]Feature "checksum" for Windows PE

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 2 12:32:32 PST 2022


mstorsjo added inline comments.


================
Comment at: lld/COFF/Writer.cpp:617
+      (pe32_header *)((uint8_t *)coffHeader + sizeof(coff_file_header));
+  uint32_t oldCheckSum = peHeader->CheckSum;
+
----------------
What is `oldChecksum` initialized to here, practically?


================
Comment at: lld/COFF/Writer.cpp:633
+
+  checkSum = CalcCheckSum(0, buf, (size + 1) / sizeof(uint16_t));
+  if ((checkSum & 0xffff) >= (oldCheckSum & 0xffff)) {
----------------
Is `size + 1` here meant for rounding up? Shouldn’t it then be `sizeof(uint16_t)-1` (even though that’s literally equal to 1)?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139184/new/

https://reviews.llvm.org/D139184



More information about the llvm-commits mailing list