This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM cortex-M4 16-byte alignment due to printf()

Hi,

I've asked this Q in Stack-Overflow, but no help... ;-(

I've encountered a strange behavior which blocks a sort of journaling file-system flash architecture I'm working on.
I'm trying to position an executable at a specific 8-byte aligned address, by modifying the MEMORY/FLASH/ORIGIN field in my linker-script.
Everything is fine till I add a call to printf() - then the start address is 16-byte aligned.

I'm using the minimal semihost sample application from the gcc-arm-none-eabi toolchain (gcc-arm-none-eabi-9-2020-q2-update-win32).
I changed the MEMORY/FLASH/ORIGIN field in the linker-script to 8.

  • Commenting-out the printf() calls generates a 8-byte alignment.
  • adding the printf() calls generates an 16-byte alignment.

Generating the HEX-file: arm-none-eabi-objcopy.exe -O ihex .\semihost-CM4.axf .\semihost-CM4.hex
Thanks.

One can download the project: https://drive.google.com/file/d/1ODcoypaBeTw38BqWnysbm4PuPgaGIRuw/view?usp=sharing

$ make clean
$ make