Optibootl apparently gets about 14 bytes bigger with the gcc 7.3.0 compiler that Arduino is distributing...
Hmmph.
For the sake of analysis, I created an ASM macro:
#define TICK(name) asm(".global " #name "\n .equ " #name ", .-1b\n1:\n")
I can sprinkle statements like:
if (cmd == FOO) { TICK(FOO_START); // some code TICK(FOO_END); } else if (cmd == BAR) { // more code TICK(FOO_END) }
throughout the code, and the elf file will contain nice absolute symbols who value is the distance between "ticks", and it should give me an idea where things have gotten bigger.
It seems to work pretty well:
avr-nm -S optiboot_atmega328.elf | grep A : 0000000c A set_device_size 00000024 A size_getparameter 0000007e A size_init 0000001a A size_loadaddress 0000002a A size_readPage 0000001c A size_readSign 0000000c A size_setdevext 00000012 A size_universal 0000006c A size_writePage
EXCEPT that the use of the macro changes the size of the executable. Even though it produces no actual code, doesn't have any clobbers specified, and is not volatile (which in theory gives gcc free reign to move it around for the sake of optimization.)
This is less than ideal (though still useful, probably.) Does anyone have ideas one how I can make my empty asm() statements have LESS impact on code generation?