-
Notifications
You must be signed in to change notification settings - Fork 83
null dereference before main is called #21
Comments
This code: #![feature(used)]
#![no_std]
extern crate msp430_rt;
fn main() {}
#[used]
#[link_section = ".rodata.interrupts"]
static INTERRUPTS: [u16; 15] = [0; 15]; Gives me this assembly
It looks all right, not reading any memory at all, just infinite loop. |
@pftbest Thanks for checking. I looked at the llvm-ir and I think I see the problem:
IIRC the rustc compiler injects this volatile load of the It'd be great to not have this weird load in the first place but if it must be kept around maybe it would be better to change the load address from 0x0 to something that we are certain will never trigger a hard fault (perhaps 0x0 is OK, IDK). @pftbest that's the disassembly that you got from compiling your program in release mode but without debug information, right? Could you try enabling debuginfo for the release profile in Cargo.toml (see below) and see if the output changes?
|
No. It's done so that you can just run gdb on your ELF file and have gdb load the scripts that imbue gdb with the knowledge of Rust. The debug information itself is completely decoupled from this.
Yeah... any chance you could place it, for example, right at the beginning of .text or .rodata? I think that's the only clean solution I see. |
As a side note: with this linker script we actually don't need the rustc hack, but we can't turn it off either. Welp. |
@japaric , wow, when debug is enabled i can see the load
|
21: note the code of conduct in the README r=japaric a=japaric Testing PR builds Co-authored-by: Jorge Aparicio <[email protected]>
STR
with cortex-m-quickstart v0.1.8 and cortex-m-rt v0.2.4.
Produces:
In this case there's no main to execute but this:
is loading the byte stored at address 0x0. This doesn't crash on Cortex-M devices because that's a valid address (the start of the vector table).
I'm not exactly sure why that's being generated but it doesn't appear if I remove the start lang_item from cortex-m-rt and directly call a the binary crate main function.
cc @pftbest do you see something like this on msp430?
The text was updated successfully, but these errors were encountered: