Cortex-M0 Thumb alignment
Hi everybody,
I am using STM32F042G6 MCU for an automotive project and since It doesn't have mush FLASH (32kB) I am trying to reduce code size as much as possible.
Lookign at the linker file generated by STM32CubeMX, I see that instructions are aligned to 4 bytes. Since M0 architecture uses Thumb instruction set which is 16 bit wide, I was wondering wether instructions can be aligned to 2 bytes, saving some flash. Since I am not very experienced in this area of MCU I would like to know from you if this is correct or if I am missing something. I will link part of the linker script. I definitely understand why isr_vector is aligned to 4 bytes but I quite don't why .text is.
Thank you in advence!
SECTIONS
{
/* The startup code into "FLASH" Rom type memory */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
/* The program code and other data into "FLASH" Rom type memory */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH
...
