The `firmware` crate in which we developed our advanced workshop solutions (i.e. `advanced/firmware`) uses our open-source [`flip-link`] tool for zero-cost stack overflow protection.
This means that your application will warn you by crashing if you accidentally overreach the boundaries of your application's stack instead of running into *undefined behavior* and behaving erratically in irreproducible ways. This memory protection mechanism comes at no additional computational or memory-usage cost.
🔎 For a detailed description of how `flip-link` and Stack Overflows in bare metal Rust in general work, please refer to the [`flip-link` README].
You can see this in action in the `stack_overflow.rs` file that can be found in `advanced/firmware/src/bin/`:
There, we've configured `flip-link` as the linker to be used for all ARM targets.
If you'd like to use `flip-link` in your own projects, this is all you need to add!
🔎 Note: if you try to run `stack_overflow.rs`*without*`flip-link` enabled, you might see varying behavior depending on the `rustc` version you're using, timing and pure chance. This is because undefined behavior triggered by the program may change between `rustc` releases.