Comments (7)
First up thanks for all the great embedded rust work you've done.
❤️
I've been working though the process to create a crate f0 akin to this one but for Cortex-M0 generated by svd2rust
Awesome!
LLVM ERROR: unsupported relocation on symbol
Interesting. Just to confirm, are you using the built-in thumbv6m-none-eabi
target? Or are you supplying your own target using a .json
file. If the later, make sure you are setting relocation-model
to static
.
It's triggered by default_handler_entry_point, specifically the branch instruction.
The assembly in that function is using the b
instruction. The Cortex-M4 (F3) and the Cortex-M0 (F0) have different architectures. The Cortex-M4 can jump in the range (−16 MB to +16 MB) using the B
instruction whereas the Cortex-M0 can only jump in the range (−2KB to +2KB) using the same instruction. So, you could try the bl
instruction in your f0
crate, with that instruction it's possible to jump in the (-16MB to +16MB) range just like the Cortex-M4 does.
Is there any linker script magic that can be done that might work around the issue?
Yes. This should work, I think:
/* Entry point: reset handler */
_reset = .;
KEEP(*(.text._reset));
+ KEEP(*(.text._default_exception_handler));
+ KEEP(*(.text._default_exception_handler_impl));
*(.text.*);
*(.rodata.*);
That should put the impl
symbol right next to the _default_exception_handler
symbol.
from f3.
I expect that this will take a while to trickle down to rustc.
I expect we'll do a LLVM up (from 3.9 to 4.0) in November. If not, you could request backporting the patch if you confirm that it indeed solves the problem you are seeing.
from f3.
Just to confirm, are you using the built-in thumbv6m-none-eabi target? Or are you supplying your own target using a .json file. If the later, make sure you are setting relocation-model to static.
I did see a mention that the thumbv6 target was supposed to be built in now but when I ran rustc --print target-list
I didn't see it so I stuck with a custom one. That one does have relocation-model set to static. I updated my nightly compiler yesterday when I ran into this issue and I note that the thumb targets are now listed.
So, you could try the bl instruction in your f0 crate
Using the long branch does seem to fix it (it compiles now). The error still happened when using b
with _default_exception_handler_impl
and _default_exception_handler
added to the linker script. So I think I'll just stick with bl
and do some more testing.
Thank you so much for your help.
from f3.
Using the long branch does seem to fix it (it compiles now).
Awesome!
The error still happened when using b with _default_exception_handler_impl and _default_exception_handler added to the linker script.
Weird. Are the symbols one next to the other when you look at the disassemble (objdump -Cd
)? Oh, wait I guess there's nothing to disassemble if this hits an LLVM error -- not even a foo.o
is generated.
Yeah, I guess this needs to be fixed in LLVM proper. Or rather we need to update our LLVM fork.
Thank you so much for your help.
You are welcome!
from f3.
I've fallen over the same issue, working on support for the Freescale Kinetis KE06Z.
from f3.
I expect we'll do a LLVM up (from 3.9 to 4.0) in November.
Hahaha ha ... (me being naive)
@thejpster Could you open an issue in the rust-lang/rust repo with a small repro file. Seems like the patch @wezm linked shouldn't be too hard to backport. Then I can take it from there.
from f3.
I'll take a look later.
For now, I just replaced my b with a bl in my hardfault handler code and it's OK.
from f3.
Related Issues (20)
- impl Iterator for Leds
- Building fails with: error[E0557]: feature has been removed HOT 4
- Use board as USB device
- Examples fail to build
- run example: error[E0432]: unresolved import `cortex_m_0_6::peripheral::itm` HOT 2
- remove aliased mutable borrows HOT 10
- review ABI of "extern" functions
- My board uses STlinkV2, not 2-1 HOT 4
- main function not linked to the binary HOT 7
- Board support crate naming could be more specific? HOT 3
- No lsm303dlhc module in master HOT 2
- implement the embedded-hal traits and ... HOT 17
- upgrade to RTFM v0.2 HOT 8
- OpenOCD and GDB keep failing randomly during debug sessions HOT 5
- Version 0.5.0 not release to Crates.io HOT 3
- Binary size and flashing with st-flash HOT 3
- Question: How to handle `EXTI` interrupts HOT 1
- Unable to run madgwick/viz demo HOT 4
- Link in docs is dead HOT 2
- Example failing to link with 1.30.0-nightly (2018-09-13) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from f3.