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().
MEMORY
{
CCRAM : ORIGIN = 0x10000000, LENGTH = 8K
FLASH : ORIGIN = 0x08000000, LENGTH = 256K
RAM : ORIGIN = 0x20000000, LENGTH = 40K
}
ENTRY(_reset)
SECTIONS
{
.text ORIGIN(FLASH) :
{
/* Vector table */
LONG(ORIGIN(RAM) + LENGTH(RAM));
LONG(_reset + 1);
KEEP(*(.rodata._EXCEPTIONS));
_eexceptions = .;
/* Entry point: reset handler */
_reset = .;
*(.text._reset);
*(.text.*);
*(.rodata.*);
} > FLASH
/DISCARD/ :
{
*(.ARM.exidx.*)
*(.bss.*)
*(.data.*)
}
}
/* HACK to make these symbols overrideable by _dependencies_ (they were
already overridable by the top crate), we declare them as undefined
(EXTERN) here. */
EXTERN(__aeabi_memclr4);
EXTERN(_default_exception_handler);
EXTERN(_init);
/* Exceptions */
PROVIDE(_nmi = _default_exception_handler);
PROVIDE(_hard_fault = _default_exception_handler);
PROVIDE(_memmanage_fault = _default_exception_handler);
PROVIDE(_bus_fault = _default_exception_handler);
PROVIDE(_usage_fault = _default_exception_handler);
PROVIDE(_svcall = _default_exception_handler);
PROVIDE(_pendsv = _default_exception_handler);
PROVIDE(_systick = _default_exception_handler);
ASSERT(_eexceptions - ORIGIN(FLASH) == 0x40, "exceptions not linked where expected");
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.