Czy wolisz polską wersję strony elektroda?
Nie, dziękuję Przekieruj mnie tam_jta_ wrote:Of course, in the code above, this is redundant
This is not redundant, on the contrary, it is necessary if the name is to be used to generate the 32-bit address of the function - the fact that the processor has only Thumb instructions does not mean that you can load an even address into the PC with impunity - it freezes the processor, I checked.
I used this construction, and it worked:
Code: ARM assemblerLog in, to see the code
- all functions defined by _func had odd addresses.
However, the problem with (non)parity of the address only manifests itself when the instruction uses a 32-bit address - instructions containing a relative address do not encode the lowest bit of the address and preserve the lowest PC bit.
TL;DR: Enabling -O3 without -ffreestanding on bare-metal STM32 almost doubles code size (+100 %) and breaks builds, while “The -g option produces debugging information GDB can use” [Elektroda, lazor, #17571595; #17571519].
Why it matters: Correct startup, flags, and linker settings decide whether your Cortex-M even reaches main().
• Reset vector lives at 0x00000004; initial SP at 0x00000000 [Elektroda, lazor, post #17568319] • Example flash region: 0x0800 0000, length 0x1000 (4 KB) [Elektroda, lazor, post #17568319] • Example SRAM region: 0x2000 0000, length 12 KB [Elektroda, lazor, post #17568319] • -ffreestanding stops GCC auto-calling memset/memcpy under -O3 [Elektroda, lazor, post #17571595] • NUCLEO-L432KC with on-board ST-Link ≈ PLN 49 [Elektroda, lazor, post #17612659]