rust-embedded / rust-embedded/cortex-m
"Extra Sections" example is potentially unsound
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 202
- Avg merge
- 6d 2h
- Merged PRs (30d)
- 2
Description
In the cortex-m-rt docs, the extra sections example shows the definition of a zero-initialized static mut array in a section outside of RAM.
I believe this to be unsound, and difficult, if not impossible, to use totally soundly.
The CRT is required to initialize all statics, either to their default value (in .data), or to zero (in .bss). cortex-m-rt explicitly only performs initialization for data and bss sections in the RAM region, meaning the CCRAM must be considered to be uninitialized in the example as currently written.
At the very least if we include an example like this, we should discuss this deficiency, and state that pre_init must be used to guarantee that the static is initialized at the start of the program.
I personally am of the opionion that we cannot soundly perform this initialization in a pre_init in Rust, as that means that Rust code is running without all statics initialized, which violates the agreement the language makes with the platform environment.
This argument is part of why we switched to an assembly CRT, rather than the previously Rust-based init sequence.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the linked cortex-m-rt Extra Sections example and compare its initialization claims with the CRT behavior described in the issue. Decide whether the example should be removed or revised, and document the CCRAM initialization, pre_init caveat, and soundness concern. Done means the docs no longer present an unqualified potentially unsound example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation, embedded-iot
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100