Fix ARI text for floatformat_from_double
[deliverable/binutils-gdb.git] / binutils / od-elf32_avr.c
index 7a0a21216cd907edf10ab8ffea0e3c5db2d0153f..4a607d20ee7f981aa50256417f8bdd80debda76a 100644 (file)
@@ -1,5 +1,5 @@
 /* od-avrelf.c -- dump information about an AVR elf object file.
 /* od-avrelf.c -- dump information about an AVR elf object file.
-   Copyright (C) 2011-2014 Free Software Foundation, Inc.
+   Copyright (C) 2011-2019 Free Software Foundation, Inc.
    Written by Senthil Kumar Selvaraj, Atmel.
 
    This file is part of GNU Binutils.
    Written by Senthil Kumar Selvaraj, Atmel.
 
    This file is part of GNU Binutils.
 #include "bfd.h"
 #include "elf/external.h"
 #include "elf/internal.h"
 #include "bfd.h"
 #include "elf/external.h"
 #include "elf/internal.h"
+#include "elf32-avr.h"
 
 /* Index of the options in the options[] array.  */
 #define OPT_MEMUSAGE 0
 
 /* Index of the options in the options[] array.  */
 #define OPT_MEMUSAGE 0
+#define OPT_AVRPROP 1
 
 /* List of actions.  */
 static struct objdump_private_option options[] =
   {
     { "mem-usage", 0 },
 
 /* List of actions.  */
 static struct objdump_private_option options[] =
   {
     { "mem-usage", 0 },
+    { "avr-prop",  0},
     { NULL, 0 }
   };
 
     { NULL, 0 }
   };
 
@@ -50,6 +53,7 @@ elf32_avr_help (FILE *stream)
   fprintf (stream, _("\
 For AVR ELF files:\n\
   mem-usage   Display memory usage\n\
   fprintf (stream, _("\
 For AVR ELF files:\n\
   mem-usage   Display memory usage\n\
+  avr-prop    Display contents of .avr.prop section\n\
 "));
 }
 
 "));
 }
 
@@ -81,7 +85,7 @@ elf32_avr_get_note_section_contents (bfd *abfd, bfd_size_type *size)
   if ((section = bfd_get_section_by_name (abfd, ".note.gnu.avr.deviceinfo")) == NULL)
     return NULL;
 
   if ((section = bfd_get_section_by_name (abfd, ".note.gnu.avr.deviceinfo")) == NULL)
     return NULL;
 
-  *size = bfd_get_section_size (section);
+  *size = bfd_section_size (section);
   char *contents = (char *) xmalloc (*size);
   bfd_get_section_contents (abfd, section, contents, 0, *size);
 
   char *contents = (char *) xmalloc (*size);
   bfd_get_section_contents (abfd, section, contents, 0, *size);
 
@@ -158,17 +162,17 @@ elf32_avr_get_memory_usage (bfd *abfd,
   asection *section;
 
   if ((section = bfd_get_section_by_name (abfd, ".data")) != NULL)
   asection *section;
 
   if ((section = bfd_get_section_by_name (abfd, ".data")) != NULL)
-    avr_datasize = bfd_section_size (abfd, section);
+    avr_datasize = bfd_section_size (section);
   if ((section = bfd_get_section_by_name (abfd, ".text")) != NULL)
   if ((section = bfd_get_section_by_name (abfd, ".text")) != NULL)
-    avr_textsize = bfd_section_size (abfd, section);
+    avr_textsize = bfd_section_size (section);
   if ((section = bfd_get_section_by_name (abfd, ".bss")) != NULL)
   if ((section = bfd_get_section_by_name (abfd, ".bss")) != NULL)
-    avr_bsssize = bfd_section_size (abfd, section);
+    avr_bsssize = bfd_section_size (section);
   if ((section = bfd_get_section_by_name (abfd, ".bootloader")) != NULL)
   if ((section = bfd_get_section_by_name (abfd, ".bootloader")) != NULL)
-    bootloadersize = bfd_section_size (abfd, section);
+    bootloadersize = bfd_section_size (section);
   if ((section = bfd_get_section_by_name (abfd, ".noinit")) != NULL)
   if ((section = bfd_get_section_by_name (abfd, ".noinit")) != NULL)
-    noinitsize = bfd_section_size (abfd, section);
+    noinitsize = bfd_section_size (section);
   if ((section = bfd_get_section_by_name (abfd, ".eeprom")) != NULL)
   if ((section = bfd_get_section_by_name (abfd, ".eeprom")) != NULL)
-    eepromsize = bfd_section_size (abfd, section);
+    eepromsize = bfd_section_size (section);
 
   *text_usage = avr_textsize + avr_datasize + bootloadersize;
   *data_usage = avr_datasize + avr_bsssize + noinitsize;
 
   *text_usage = avr_textsize + avr_datasize + bootloadersize;
   *data_usage = avr_datasize + avr_bsssize + noinitsize;
@@ -181,7 +185,7 @@ elf32_avr_dump_mem_usage (bfd *abfd)
   char *description = NULL;
   bfd_size_type note_section_size = 0;
 
   char *description = NULL;
   bfd_size_type note_section_size = 0;
 
-  deviceinfo device = {0};
+  deviceinfo device = { 0, 0, 0, 0, 0, 0, NULL };
   device.name = "Unknown";
 
   bfd_size_type data_usage = 0;
   device.name = "Unknown";
 
   bfd_size_type data_usage = 0;
@@ -233,11 +237,61 @@ elf32_avr_dump_mem_usage (bfd *abfd)
 
 }
 
 
 }
 
+static void
+elf32_avr_dump_avr_prop (bfd *abfd)
+{
+  struct avr_property_record_list *r_list;
+  unsigned int i;
+
+  r_list = avr_elf32_load_property_records (abfd);
+  if (r_list == NULL)
+    return;
+
+  printf ("\nContents of `%s' section:\n\n", r_list->section->name);
+
+  printf ("  Version: %d\n", r_list->version);
+  printf ("  Flags:   %#x\n\n", r_list->flags);
+
+  for (i = 0; i < r_list->record_count; ++i)
+    {
+      printf ("   %d %s @ %s + %#08lx (%#08lx)\n",
+             i,
+             avr_elf32_property_record_name (&r_list->records [i]),
+             r_list->records [i].section->name,
+             r_list->records [i].offset,
+             (bfd_section_vma (r_list->records [i].section)
+              + r_list->records [i].offset));
+      switch (r_list->records [i].type)
+        {
+        case RECORD_ORG:
+          /* Nothing else to print.  */
+          break;
+        case RECORD_ORG_AND_FILL:
+          printf ("     Fill: %#08lx\n",
+                  r_list->records [i].data.org.fill);
+          break;
+        case RECORD_ALIGN:
+          printf ("     Align: %#08lx\n",
+                  r_list->records [i].data.align.bytes);
+          break;
+        case RECORD_ALIGN_AND_FILL:
+          printf ("     Align: %#08lx, Fill: %#08lx\n",
+                  r_list->records [i].data.align.bytes,
+                  r_list->records [i].data.align.fill);
+          break;
+        }
+    }
+
+  free (r_list);
+}
+
 static void
 elf32_avr_dump (bfd *abfd)
 {
   if (options[OPT_MEMUSAGE].selected)
     elf32_avr_dump_mem_usage (abfd);
 static void
 elf32_avr_dump (bfd *abfd)
 {
   if (options[OPT_MEMUSAGE].selected)
     elf32_avr_dump_mem_usage (abfd);
+  if (options[OPT_AVRPROP].selected)
+    elf32_avr_dump_avr_prop (abfd);
 }
 
 const struct objdump_private_desc objdump_private_desc_elf32_avr =
 }
 
 const struct objdump_private_desc objdump_private_desc_elf32_avr =
This page took 0.03839 seconds and 4 git commands to generate.