4 ms·
Several of these items are very relevant for the embedded world (custom registries, custom allocators, unsafe code guidelines, etc.). They just didn’t use the w
by cornstalks 7y ago
Several of these items are very relevant for the embedded world (custom registries, custom allocators, unsafe code guidelines, etc.). They just didn’t use the word “embed” in this short post.
- burfog 7y agoDo you know how difficult it is to write a position-independent blob that runs all by itself? Consider something like a boot loader or kernel, starting from a random location in memory. Can it run without needing assembly language? For example, C can often do this. You ask the linker to put a particular function first and to make everything position-independent. There can be some problems with the GNU toolchain stubbornly insisting on making a GOT, but the language is otherwise fully capable.
- thenewwazoo 7y agoIt's very easy, in fact. Because you don't use the stdlib, it requires handling some language items (the equivalent of having to write your own _start routine, for example). You set up vector tables just like normal, and you decorate things to tell the linker where to put them. The canonical example is https://github.com/rust-embedded/cortex-m-rt https://github.com/rust-embedded/cortex-m-rt if you want to get into the guts of how it works. For a more user-focused overview, check out https://github.com/rust-embedded/cortex-m-quickstart https://github.com/rust-embedded/cortex-m-quickstart, which is a good starting point from which to drill down.