[llvm] [MachO] Detect overflow in section offset. (PR #98685)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 12 15:25:00 PDT 2024


================
@@ -277,6 +277,8 @@ void MachObjectWriter::writeSection(const MCAssembler &Asm,
     W.write<uint32_t>(VMAddr);      // address
     W.write<uint32_t>(SectionSize); // size
   }
+  if (!isUInt<32>(FileOffset))
+    report_fatal_error("Cannot encode offset of section");
   W.write<uint32_t>(FileOffset);
 
   W.write<uint32_t>(Log2(Section.getAlign()));
----------------
efriedma-quic wrote:

The point of the early return would be to avoid duplicate error messages?  That makes sense, I guess.

https://github.com/llvm/llvm-project/pull/98685


More information about the llvm-commits mailing list