So here is what happened....I have a project compiled to give about 180KB code (+32KB bootloader)...for a 256K ATSAM21 32 bit chip.
Surprisingly the compiler warned me that one of the strucs did not align properly. So I checked the map file, and sure enough the structure was placed at an odd number boundary (address end with 7). This was the ONLY struct that was showing this.
A lot of my other structs start with COMPILER_PACK(1) set which I think is equivalent to __attribute__((packed(1)))...? COMPILER_PACK() is a AtmelStudio macro.
Anyways so I then force this particular struct to be __attribute__((aligned(4))) by adding it at the end of it before the terminating ; mark.
And then I do this for a lot of the other structs that I had originally had COMPILER_PACK(1) set on. I must note that whenever I do structs on these ARM chips I make sure they are properly padded with bytes to make sure the full size is always a multiple of 32bits.
Then after changing a lot of my previous structs from COMPILER_PACK(1) to __attribute__((aligned(4))) I noticed something truly surprising... my application code went from 180KB to ~150KB. That's like 15% space saving??? What the??
Can anyone explain? I was always using optimise for size.