This is part of the spec for ARM MCUs: the vector table starts at 0x0, and the first two words in it are the initial stack pointer and the entrypoint. We go into this in details (with references) in our earlier post: https://interrupt.memfault.com/blog/zero-to-main-1
Re:From Zero to Main(): Bare Metal Rust
by saagarjha on Tuesday December 17, 2019 @03:00PM
(#21818062)
Ah, I see. Thanks!
Re:From Zero to Main(): Bare Metal Rust
by duskwuff on Tuesday December 17, 2019 @03:19PM
(#21818308)
Also, they've misread the pointer -- the initial SP is 0x2001_0000 (SRAM + 64K), not 0x2010_0000 (SRAM + 1MB).
Ah, you're right! fixed.
No, "bin" explicitly has no format, but it's interpreted by the bootloader/whatever on the board - you can see the linker script setting this up manually here:
https://github.com/ferrous-systems/zero-to-main/blob/master/...
Re:From Zero to Main(): Bare Metal Rust
by duskwuff on Tuesday December 17, 2019 @02:57PM
(#21818022)
FWIW, this is a pretty unusual way of setting up vectors. A more typical approach in C is to declare the vector table entirely in C or assembly, and only use the linker script to position it:
https://github.com/duskwuff/stm32f103-example/blob/master/ld...
Re:From Zero to Main(): Bare Metal Rust
by TickleSteve on Wednesday December 18, 2019 @01:49AM
(#21822476)
...and what you're seeing is after the linker has positioned it. that is the defined format of the ARM vector table as it is laid out in memory.
Re:From Zero to Main(): Bare Metal Rust
by duskwuff on Wednesday December 18, 2019 @03:48AM
(#21823030)
I'm referring to the linker script in kimixa's comment. Explicitly placing each vector table entry in the linker script, as this one does, is unusual.
Re:From Zero to Main(): Bare Metal Rust
by chrisseaton on Tuesday December 17, 2019 @02:45PM
(#21817858)
> objcopy's binary format
There is no file format - it’s just whatever stream of data and instructions the user wrote. It’s a flat file.
I see the pointers in the top line, but is this a standard feature of objcopy's binary format? Are the pointers the stack and entrypoint always at the beginning?