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

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 12 16:39:43 PDT 2024


================
@@ -904,6 +908,18 @@ uint64_t MachObjectWriter::writeObject(MCAssembler &Asm) {
     unsigned Flags = Sec.getTypeAndAttributes();
     if (Sec.hasInstructions())
       Flags |= MachO::S_ATTR_SOME_INSTRUCTIONS;
+    if (!cast<MCSectionMachO>(Sec).isVirtualSection() &&
+        !isUInt<32>(SectionStart)) {
+      Asm.getContext().reportError(
+          SMLoc(), "Cannot encode offset of section; object file too large");
----------------
MaskRay wrote:

`reportError` messages are generally not capitalized per https://llvm.org/docs/CodingStandards.html#error-and-warning-messages

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


More information about the llvm-commits mailing list