-
Notifications
You must be signed in to change notification settings - Fork 83
default_handler! doesn't work #58
Comments
Fixes rust-embedded#58 This is a breaking change for projects that are using custom linker scripts.
I did some investigation into this issue, and I think this is a hard limitation of a GNU linker. main.c void _start() {}
void DEFAULT_HANDLER() {
*((int*)0x10) = 5;
} cortex_m_rt.c __attribute__((weak)) void DEFAULT_HANDLER() {
*((int*)0x10) = 1;
}
__attribute__((weak, alias("DEFAULT_HANDLER"))) void HARD_FAULT();
__attribute__((weak, alias("DEFAULT_HANDLER"))) void BUS_FAULT();
void (*VECTORS[])() = {
HARD_FAULT,
BUS_FAULT,
}; arm-none-eabi-gcc -Os -o main.o -c main.c
arm-none-eabi-gcc -Os -o cortex_m_rt.o -c cortex_m_rt.c
arm-none-eabi-ld main.o cortex_m_rt.o
There are two ways to fix it, either by introducing a DH_TRAMPOLINE as we did in svd2rust, but much much better solution would be to use linker script to create such weak symbols. And since we are going to do this for moving on stable compiler anyway, it will also fix this issue. |
I believe this was fixed after we moved to using PROVIDE in linker scripts. |
The
default_handler!
doesn't work in this example code. This was tested with rust-1.26.0-nightly-2018-02-27-29f5c699b:Debug Build:
Release Build:
The text was updated successfully, but these errors were encountered: