You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Zeroing of section .bss is now conditional on .bss start & end being defined rather than .data start & end being defined (this was likely a copy-pasta error when re-purposing code from the .data section above it to make the .bss piece). Also, the pointer jumps forward 4 bytes at a time now rather than one byte, given that pSrc and pDest are pointers to a uint32_t, meaning memory is written 4 bytes at a time.
A bunch of processor architectures (especially the simple ones) can only write int32 values to a memory address aligned at a 4-byte boundary, and int16 values aligned at a 2-byte boundary. If one writes C/C++ code not taking this into account, the compiler is forced to generate all sorts of shifts and tricks to make that code work, which is very suboptimal code by every measure. (In this case suboptimal means having every byte but the first and last three written 4 or more times over and some extra space in flash memory for the tricks.)
If one were to do have written the init of .data and .bss in assembly (meaning the compiler not saves your ass by inserting shifts & tricks to your doing it per-byte) this would have been a HardFault on most Cortex CPUs due to the alignment requirement.
0 commit comments