Skip to content

F0068 mem-10

Rule: No LOAD segment is writable and executable, and .rodata holds nothing writable.

Code F0068 (stable, never reused)
Id mem-10
Category mem
Source spirit_level
Fix by hand
Needs the firmware's linked ELF (--elf); skipped without a firmware binary

Level per tier

Tier Level Reason
small off
small-workspace off
medium off
big off
ai off
embedded warn bedrock warning: RWX LOAD segment or a writable symbol in .rodata (static mut in a read-only section)
ui off
egui off
units-strict off
units-paranoid off

Why

A LOAD segment in the linked ELF marked both writable and executable, or a static mut symbol that the linker placed inside .rodata (a read-only section) rather than .data/.bss.

A static mut the linker put in .rodata compiles and links without complaint, but any write to it at run time either faults (on an MPU-protected part) or silently does nothing (flash-backed .rodata on others) — neither is the mutable storage the code was written assuming it has.

Example

cnt's _CNT_SIGNATURE: a static that needed checking to confirm it actually landed in writable memory, not folded into .rodata by the linker's section merging.

How to fix

Give the symbol an explicit #[unsafe(link_section = ...)] into a writable NOLOAD/data section if the linker's default placement put it somewhere read-only; split any genuinely RWX segment the linker script produces.

How it is checked

elf easy: read each LOAD segment's flags for the W+X combination, and cross-reference known static mut symbols against which output section they actually linked into.

Source

Ported from embedded_bedrock's firmware check catalogue, MEM-10 (book/checks.md, detail in book/checks/mem.md). Found on: cnt _CNT_SIGNATURE.

Configure

[lints.mem-10]
level = "deny"
reason = "why this project wants it at this level"

Allow one finding in the code with // spirit-level: allow(mem-10) <reason> (waivers); the code works there too, as in [lints.F0068].