avr-libc-commit
[Top][All Lists]
Advanced

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

[avr-libc-commit] [2459] Add a note section containing device info to th


From: Senthil Kumar Selvaraj
Subject: [avr-libc-commit] [2459] Add a note section containing device info to the crt file.
Date: Fri, 21 Nov 2014 05:32:40 +0000

Revision: 2459
          http://svn.sv.gnu.org/viewvc/?view=rev&root=avr-libc&revision=2459
Author:   saaadhu
Date:     2014-11-21 05:32:39 +0000 (Fri, 21 Nov 2014)
Log Message:
-----------
Add a note section containing device info to the crt file.

Modified Paths:
--------------
    trunk/avr-libc/ChangeLog
    trunk/avr-libc/crt1/gcrt1.S
    trunk/avr-libc/doc/api/sections.dox

Modified: trunk/avr-libc/ChangeLog
===================================================================
--- trunk/avr-libc/ChangeLog    2014-11-20 07:36:20 UTC (rev 2458)
+++ trunk/avr-libc/ChangeLog    2014-11-21 05:32:39 UTC (rev 2459)
@@ -1,3 +1,8 @@
+2014-11-21  Senthil Kumar Selvaraj <address@hidden>
+
+    * crt1/gcrt1.S: Add a note section embedding device info.
+    * doc/api/sections.dox: Document it.
+
 2014-11-20  Senthil Kumar Selvaraj <address@hidden>
 
        * include/avr/sleep.h (set_sleep_mode): Branch on presence of 

Modified: trunk/avr-libc/crt1/gcrt1.S
===================================================================
--- trunk/avr-libc/crt1/gcrt1.S 2014-11-20 07:36:20 UTC (rev 2458)
+++ trunk/avr-libc/crt1/gcrt1.S 2014-11-21 05:32:39 UTC (rev 2459)
@@ -304,3 +304,71 @@
 #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
+    .balign 4
+.L__note_name_end:
+.L__desc_start:
+#ifdef FLASHSTART
+    .long FLASHSTART
+#else
+    .long 0
+#endif
+#ifdef PROGMEM_SIZE
+    .long PROGMEM_SIZE
+#elif FLASHEND > 0
+    .long FLASHEND + 1
+#else
+    .long FLASHEND
+#endif
+    .long RAMSTART
+#ifdef RAMSIZE
+    .long RAMSIZE
+#elif RAMEND > 0
+    .long RAMEND - RAMSTART + 1
+#else
+    .long RAMEND
+#endif
+#ifdef E2START
+    .long E2START
+#else
+    .long 0
+#endif
+#ifdef EEPROM_SIZE
+    .long EEPROM_SIZE
+#elif E2END > 0
+    .long E2END + 1
+#else
+    .long E2END
+#endif
+    /* String offsets table.
+    Index 0 - Size of offset table in bytes
+    Index 1 - Device name byte offset
+    */
+.L__stroffsettab_start:
+.long .L__stroffsettab_end - .L__stroffsettab_start /* Size of index table in 
bytes */
+.long .L__device_name_start - .L__strtab_start /* Byte offset of device name */
+.L__stroffsettab_end:
+    /* String table for storing arbitrary strings.
+    Offsets are stored in the string offset table above */
+.L__strtab_start:
+    .byte 0
+.L__device_name_start:
+    .asciz DEVICE_NAME
+.L__device_name_end:
+    .byte 0
+.L__strtab_end:
+.L__desc_end:
+    .balign 4
+

Modified: trunk/avr-libc/doc/api/sections.dox
===================================================================
--- trunk/avr-libc/doc/api/sections.dox 2014-11-20 07:36:20 UTC (rev 2458)
+++ trunk/avr-libc/doc/api/sections.dox 2014-11-21 05:32:39 UTC (rev 2459)
@@ -207,6 +207,51 @@
 Goes into an infinite loop after program termination and completion of any
 _exit() code (execution of code in the .fini9 -> .fini1 sections).
 
+\section sec_dot_note The .note.gnu.avr.deviceinfo Section
+
+This section contains device specific information picked up from the device
+header file and compiler builtin macros. The layout conforms to the standard 
ELF
+note section layout 
(http://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-18048.html).
+
+The section contents are laid out as below.
+
+\code
+#define __NOTE_NAME_LEN 4
+struct __note_gnu_avr_deviceinfo
+{
+    struct
+    {
+        uint32_t namesz;          /* = __NOTE_NAME_LEN */
+        uint32_t descsz;          /* =  size of avr_desc */
+        uint32_t type;            /* = 1 - no other AVR note types exist */
+        char note_name[__NOTE_NAME_LEN]; /* = "AVR\0" */
+    }
+    note_header;
+    struct
+    {
+        uint32_t flash_start;
+        uint32_t flash_size;
+        uint32_t sram_start;
+        uint32_t sram_size;
+        uint32_t eeprom_start;
+        uint32_t eeprom_size;
+        uint32_t offset_table_size;
+        uint32_t offset_table[1];  /* Offset table containing byte offsets into
+                                      string table that immediately follows it.
+                                      index 0: Device name byte offset
+                                    */
+        char str_table [2 +
+          strlen(__AVR_DEVICE_NAME__)]; /* Standard ELF string table.
+                                           index 0 : NULL
+                                           index 1 : Device name
+                                           index 2 : NULL
+                                        */
+    }
+    avr_desc;
+};
+\endcode
+
+
 \section asm_sections Using Sections in Assembler Code
 
 Example:




reply via email to

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