I use a file_enum.h header in my projects, which uses the linker to enumerate my source files. I use this to identify assertion failures on platforms which may only have numeric output (ie. a product using 7-seg displays).
My file_enum.h contains:
static volatile uint8_t __attribute__((section(".file_enum"))) file_number;
#define FILE_ENUM ((uint8_t)(intptr_t)(&file_number))
This works fine, and I can see which file = which number in my .map output. Recently after upgrading to Buster I now have avr-gcc (GCC) 5.4.0, which for some reason uses 2 byte alignment for uint8_t (despite being an 8-bit platform).
This means I can now only enumerate 128 files, also my FILE_ENUM equates to the address shown in the map file +1 due to endianess.
I have tried, without success:
static volatile uint8_t __attribute__((section(".file_enum"),aligned(1))) file_number;
Is there a way to force 1-byte alignment for uint8_t, or, is there a better way to enumerate source files?