rust-embedded / cortex-m-rt

Minimal startup / runtime for Cortex-M microcontrollers
https://rust-embedded.github.io/cortex-m-rt/
Apache License 2.0
358 stars 85 forks source link

Position Independent Code #322

Closed noonien closed 3 years ago

noonien commented 3 years ago

Hello!

From what I can gather, cortex-m-rt doesn't currently support being compiled with position independent code.

I would like to have multiple applications on the flash, and have the bootloader chooses which one to run by just changing the VTOR.

Is it possible to have this work?

adamgreig commented 3 years ago

Unfortunately Rust doesn't really support this for the thumb targets yet; there's some more info here:

It might work for some limited applications if vtables and perhaps statics weren't used, but in general it's not currently supported. You could possibly imagine the bootloader doing some runtime patching or moving code around to make it work, but it wouldn't be simple.

noonien commented 3 years ago

I see, thanks for the links! I'll follow rust-lang/rust#54431.