From 5547f9acd7431a52efab1ec299b9d05391c7de8e Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Mon, 20 Apr 2026 22:17:16 +0200 Subject: [PATCH] Assert that Mach-O section_flags_mut is 0 To ensure we don't unintentionally overwrite default flags. --- cranelift/object/src/backend.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cranelift/object/src/backend.rs b/cranelift/object/src/backend.rs index 5d221f7b41f6..c25369d90283 100644 --- a/cranelift/object/src/backend.rs +++ b/cranelift/object/src/backend.rs @@ -518,6 +518,13 @@ impl Module for ObjectModule { match self.object.section_flags_mut(section) { SectionFlags::MachO { flags } => { + // There are no default flags for the `SectionKind`s that + // we've specified above, so it's fine to override. + // + // (If we don't want to override, we'll have to be careful + // with how we set these, to ensure we set the section + // type properly). + assert_eq!(*flags, 0); *flags = *macho_flags; } _ => {