[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] [Patch] Include a device info note section in gcrt1.S

From: Senthil Kumar Selvaraj
Subject: [avr-libc-dev] [Patch] Include a device info note section in gcrt1.S
Date: Mon, 11 Aug 2014 19:24:55 +0530
User-agent: Mutt/1.5.23 (2014-03-12)


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.


2014-08-11  Senthil Kumar Selvaraj  <address@hidden>

        * 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 ""
+    .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.
+    .asciz NOTE_NAME
+    .long .L__device_name_end - .L__device_name_start
+    .asciz DEVICE_NAME
+    .long PROGMEM_SIZE
+#elif FLASHEND > 0
+    .long FLASHEND + 1
+    .long FLASHEND
+#ifdef RAMSIZE
+    .long RAMSIZE
+#elif RAMEND > 0
+    .long RAMEND - RAMSTART + 1
+    .long RAMEND
+    .long EEPROM_SIZE
+#elif E2END > 0
+    .long E2END + 1
+    .long E2END
+    .balign 4

reply via email to

[Prev in Thread] Current Thread [Next in Thread]