Skip to content

Commit e117bd3

Browse files
committed
Mark EXCEPTIONS and INTERRUPTS as EXTERN in the linker script
This is required because otherwise the linker finishes as soon as all unresolved symbols are found. If it stumbles upon one of them by accident (because it looked at the file to find other symbols), the symbol is kept. If not, it is discarded. The `EXTERN` declaration tells the linker that it should look for the passed symbol. This also explains why our workaround worked: If the EXCEPTIONS static is alone in a separate module, it wasn't found because the linker didn't look at the module file to find other symbols. For more details, see rust-lang/rust#40289 (comment)
1 parent 5d2fd00 commit e117bd3

File tree

3 files changed

+2
-7
lines changed

3 files changed

+2
-7
lines changed

src/exceptions.rs

-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,3 @@ type Handler = extern "C" fn();
4444
extern "C" fn fault() {
4545
panic!("EXCEPTION: hard fault");
4646
}
47-
48-
// workaround for https://github.com/rust-lang/rust/issues/47384
49-
#[inline(never)]
50-
pub fn hello() {}

src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ pub extern "C" fn panic_fmt(fmt: core::fmt::Arguments, file: &'static str, line:
5454
use core::fmt::Write;
5555
use interrupts::primask_mutex::PrimaskMutex;
5656

57-
// workaround for https://github.com/rust-lang/rust/issues/47384
58-
exceptions::hello();
59-
6057
// Disable all interrupts after panic
6158
let mutex: PrimaskMutex<()> = PrimaskMutex::new(());
6259
mutex.lock(|_| {

stm32f7.ld

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ MEMORY
55
}
66

77
ENTRY(reset)
8+
EXTERN(EXCEPTIONS);
9+
EXTERN(INTERRUPTS);
810

911
__DATA_LOAD = LOADADDR(.data);
1012

0 commit comments

Comments
 (0)