Skip to content

Commit f3fa545

Browse files
committed
Change the sentinel value for __pre_init to something other than 1
The sentinel value of 0, while nice, was being optimized out as the compiler assumed that the function pointer would never be 0. Signed-off-by: Gabriel Smith <[email protected]>
1 parent 06ce316 commit f3fa545

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

cortex-m-rt/link.x.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ EXTERN(__INTERRUPTS); /* `static` variable similar to `__EXCEPTIONS` */
5454
/* # Pre-initialization function */
5555
/* If the user overrides this using the `pre_init!` macro or by creating a `__pre_init` function,
5656
then the function this points to will be called before the RAM is initialized. */
57-
PROVIDE(__pre_init = 0);
57+
PROVIDE(__pre_init = 1);
5858

5959
/* # Sections */
6060
SECTIONS

cortex-m-rt/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ pub unsafe extern "C" fn Reset() -> ! {
491491
}
492492

493493
let pre_init: unsafe extern "C" fn() = __pre_init;
494-
if pre_init as usize != 0 {
494+
if pre_init as usize != 1 {
495495
pre_init();
496496
}
497497

0 commit comments

Comments
 (0)