Hi, The attached patch adds a note section to gcrt1.S containing device info (name, flash, SRAM and EEPROM sizes). The device information is picked up from the device header file and compiler builtin macros.
The gcrt1.S file is already being rebuilt for each device, and rather than hardcoding this device information elsewhere (size.c in binutils, for example), I figured it's easier and less error-prone to embed this information here and then consume it everywhere else. I have a patch for binutils, for example, that uses the information in the note section to print percentage of memory used - like what the WinAVR port of avr-size does, but without the hardcoding. Does this look ok? If yes, could someone commit please? I don't have commit access. Regards Senthil 2014-08-11 Senthil Kumar Selvaraj <senthil_kumar.selva...@atmel.com> * crt1/gcrt1.S: Add a note section that embeds device info. diff --git avr-libc/crt1/gcrt1.S avr-libc/crt1/gcrt1.S index 2d341a4..80ff6f6 100644 --- avr-libc/crt1/gcrt1.S +++ avr-libc/crt1/gcrt1.S @@ -304,3 +304,45 @@ __do_copy_data: #endif /* __AVR_ASM_ONLY__ */ ; .endfunc + .section .note.gnu.avr.deviceinfo, "", @note +#define NOTE_NAME "AVR" +#ifdef __AVR_DEVICE_NAME__ + #define DEVICE_NAME STR(__AVR_DEVICE_NAME__) +#else + #define DEVICE_NAME "" +#endif + .long .L__note_name_end - .L__note_name_start + .long .L__desc_end - .L__desc_start + .long 1 ; Type 1 - this is the only known note type for AVR. +.L__note_name_start: + .asciz NOTE_NAME +.L__note_name_end: +.L__desc_start: + .long .L__device_name_end - .L__device_name_start +.L__device_name_start: + .asciz DEVICE_NAME +.L__device_name_end: +#ifdef PROGMEM_SIZE + .long PROGMEM_SIZE +#elif FLASHEND > 0 + .long FLASHEND + 1 +#else + .long FLASHEND +#endif +#ifdef RAMSIZE + .long RAMSIZE +#elif RAMEND > 0 + .long RAMEND - RAMSTART + 1 +#else + .long RAMEND +#endif +#ifdef EEPROM_SIZE + .long EEPROM_SIZE +#elif E2END > 0 + .long E2END + 1 +#else + .long E2END +#endif +.L__desc_end: + .balign 4 + _______________________________________________ AVR-libc-dev mailing list AVR-libc-dev@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-libc-dev