For research purpose, I'm trying to build an image for my cortex-m4 microcontroller with rwpi relocation model. However, during linking stage, lld throws me the error:
rust-lld: error: SBREL relocation to __sbss without static base
Below is an easy way to reproduce this error. This follows the tutorial in The Embedded Rust Book.
cargo install cargo-generateto install an handy tool.cargo generate --git https://github.com/rust-embedded/cortex-m-quickstartto download the example code.cdinto the cloned directory. Modify.cargo/config. Add"-C", "relocation-model=rwpi"torustflags.- Run
cargo build.
The example code in main.rs uses the cortex-m-rt crate, which during compile time will generate a link script for the linker. The generated link script can be found at ./target/thumbv7m-none-eabi/debug/build/cortex-m-rt-xxxxxxxxxxxxxxxx/out/link.x. I suppose that some information is missing for the linker. What should I do to resolve the issue?