-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
main function not linked to the binary #75
Comments
Your #[no_mangle]
pub fn main() -> ! {
loop {}
} or the linker will drop it. This is because the entry point, That being said, there's a bug where
That sounds weird. Maybe the functions are being inlined and that's why it seems that they are not being called. Maybe try adding |
My main.rs is taken from the book:
And I compile debug version. My whole project is at: But now I understand how main is called. So no need for ENTRY in *.ld file. |
Also this is how the _reset function looks like:
Looks like _init was inlined, but there is no call to main (If I understand it correctly) |
That does look like rust-lang/rust#39253 but I can't repro
With
|
I'm not sure if it is related to this issue. I would rather guess that the problem is with the core library. I can make the program running by putting all the code into init() function. #[export_name = "_init"]
pub fn init() {
unsafe {
f3::delay::init();
f3::led::init();
}
loop {
LEDS[0].on();
LEDS[1].off();
delay::ms(500);
LEDS[0].off();
LEDS[1].on();
delay::ms(500);
}
} But if I add this declaration: pub fn init() {
...
let leds = LEDS.iter();
...
} Then it doesn't (It is necessary to use iter(). The debugger doesn't event start in _init() function. Maybe the problem is with arm toolchain? arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 6.2.1 20161205 (release) [ARM/embedded-6-branch revision 243739] Any ideas, how can I better debug this problem? |
@klangner are you using a mac? Does the gcc you are using come from the gcc-arm-embedded tap/cask? Someone reported (rust-embedded/discovery#34) that that gcc has some bug like the one you reported here. Could you try the gcc from the px4/px4 tap? (Sorry, I don't have the exact instructions to do that as I don't access to a mac) |
No. I'm on Linux (Ubuntu). But I will try to upgrade my GCC. It looks like this should help. |
Hello. I'm new to this low level stuff and Rust, but thanks to your very good book Discovery, I hope to learn it.
I try to follow this book, and everything was ok until I tried to set the break point on function main() (Chapter 5).
My problem is that the gdb says that there is no main() function in my code. And obj-dump confirms that there is no such function.
I guess that since there is no reference to this function it was simply omitted.
I would expect that the file stm32f3discovery.ld will contain declaration with the main() but there is only _init().
Here is the contents of my stm32f3discovery.ld:
If I add EXTERN(main); after _init, then main() is executed but _init() doesn't.
Shouldn't this script contain main() function?
Or any tips what I'm missing here?
My system: Ubuntu 16.10, Rust 1.17.0, board STM32F3Discovery.
Thank you for your great work!
The text was updated successfully, but these errors were encountered: