* [patch,avr] PR31704: Let avr-objdump show .note.gnu.avr.deviceinfo
@ 2024-05-06 12:24 Georg-Johann Lay
2024-05-16 15:45 ` [ping 1,patch,avr] " Georg-Johann Lay
2024-05-20 11:13 ` [patch,avr] " Nick Clifton
0 siblings, 2 replies; 3+ messages in thread
From: Georg-Johann Lay @ 2024-05-06 12:24 UTC (permalink / raw)
To: binutils, Nick Clifton
[-- Attachment #1: Type: text/plain, Size: 562 bytes --]
AVR: binutils/31704 - Let avr-objdump show .note.gnu.avr.deviceinfo
This patch supports
avr-objdump -P avr-deviceinfo
which displays the contents of the .note.gnu.avr.deviceinfo section,
which is added by the startup code from AVR-LibC in crt<mcu>.o.
binutils/
PR binutils/31704
* od-elf32_avr.c (OPT_AVRDEVICEINFO): New macro.
(objdump_private_option options): Set [2] to "avr-deviceinfo".
(elf32_avr_help): Help on new -P avr-deviceinfo.
(elf32_avr_dump) [OPT_AVRDEVICEINFO]: Run...
(elf32_avr_dump_avr_deviceinfo): ...this new static function.
[-- Attachment #2: pr31704-deviceinfo.diff --]
[-- Type: text/x-patch, Size: 2925 bytes --]
diff --git a/binutils/od-elf32_avr.c b/binutils/od-elf32_avr.c
index 1e7a8b49935..c495fc973fe 100644
--- a/binutils/od-elf32_avr.c
+++ b/binutils/od-elf32_avr.c
@@ -36,12 +36,14 @@
/* Index of the options in the options[] array. */
#define OPT_MEMUSAGE 0
#define OPT_AVRPROP 1
+#define OPT_AVRDEVICEINFO 2
/* List of actions. */
static struct objdump_private_option options[] =
{
{ "mem-usage", 0 },
{ "avr-prop", 0},
+ { "avr-deviceinfo", 0},
{ NULL, 0 }
};
@@ -52,8 +54,9 @@ elf32_avr_help (FILE *stream)
{
fprintf (stream, _("\
For AVR ELF files:\n\
- mem-usage Display memory usage\n\
- avr-prop Display contents of .avr.prop section\n\
+ mem-usage Display memory usage\n\
+ avr-prop Display contents of .avr.prop section\n\
+ avr-deviceinfo Display contents of .note.gnu.avr.deviceinfo section\n\
"));
}
@@ -323,6 +326,55 @@ elf32_avr_dump_avr_prop (bfd *abfd)
free (r_list);
}
+
+static void
+elf32_avr_dump_avr_deviceinfo (bfd *abfd)
+{
+ char *description = NULL;
+ bfd_size_type sec_size, desc_size;
+
+ deviceinfo dinfo = { 0, 0, 0, 0, 0, 0, NULL };
+ dinfo.name = "Unknown";
+
+ char *contents = elf32_avr_get_note_section_contents (abfd, &sec_size);
+
+ if (contents == NULL)
+ return;
+
+ description = elf32_avr_get_note_desc (abfd, contents, sec_size, &desc_size);
+ elf32_avr_get_device_info (abfd, description, desc_size, &dinfo);
+
+ printf ("AVR Device Info\n"
+ "----------------\n"
+ "Device: %s\n\n", dinfo.name);
+
+ printf ("Memory Start Size Start Size\n");
+
+ printf ("Flash %9" PRIu32 " %9" PRIu32 " %#9" PRIx32 " %#9" PRIx32 "\n",
+ dinfo.flash_start, dinfo.flash_size,
+ dinfo.flash_start, dinfo.flash_size);
+
+ /* FIXME: There are devices like ATtiny11 without RAM, and where the
+ avr/io*.h header has defines like
+ #define RAMSTART 0x60
+ // Last memory addresses
+ #define RAMEND 0x1F
+ which results in a negative RAM size. The correct display would be to
+ show a size of 0, however we also want to show what's actually in the
+ note section as precise as possible. Hence, display the decimal size
+ as %d, not as %u. */
+ printf ("RAM %9" PRIu32 " %9" PRId32 " %#9" PRIx32 " %#9" PRIx32 "\n",
+ dinfo.ram_start, dinfo.ram_size,
+ dinfo.ram_start, dinfo.ram_size);
+
+ printf ("EEPROM %9" PRIu32 " %9" PRIu32 " %#9" PRIx32 " %#9" PRIx32 "\n",
+ dinfo.eeprom_start, dinfo.eeprom_size,
+ dinfo.eeprom_start, dinfo.eeprom_size);
+
+ free (contents);
+}
+
+
static void
elf32_avr_dump (bfd *abfd)
{
@@ -330,6 +382,8 @@ elf32_avr_dump (bfd *abfd)
elf32_avr_dump_mem_usage (abfd);
if (options[OPT_AVRPROP].selected)
elf32_avr_dump_avr_prop (abfd);
+ if (options[OPT_AVRDEVICEINFO].selected)
+ elf32_avr_dump_avr_deviceinfo (abfd);
}
const struct objdump_private_desc objdump_private_desc_elf32_avr =
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ping 1,patch,avr] PR31704: Let avr-objdump show .note.gnu.avr.deviceinfo
2024-05-06 12:24 [patch,avr] PR31704: Let avr-objdump show .note.gnu.avr.deviceinfo Georg-Johann Lay
@ 2024-05-16 15:45 ` Georg-Johann Lay
2024-05-20 11:13 ` [patch,avr] " Nick Clifton
1 sibling, 0 replies; 3+ messages in thread
From: Georg-Johann Lay @ 2024-05-16 15:45 UTC (permalink / raw)
To: binutils, Nick Clifton
Ping #1 for
https://sourceware.org/pipermail/binutils/2024-May/133978.html
Johann
Am 06.05.24 um 14:24 schrieb Georg-Johann Lay:
> AVR: binutils/31704 - Let avr-objdump show .note.gnu.avr.deviceinfo
>
> This patch supports
>
> avr-objdump -P avr-deviceinfo
>
> which displays the contents of the .note.gnu.avr.deviceinfo section,
> which is added by the startup code from AVR-LibC in crt<mcu>.o.
>
> binutils/
> PR binutils/31704
> * od-elf32_avr.c (OPT_AVRDEVICEINFO): New macro.
> (objdump_private_option options): Set [2] to "avr-deviceinfo".
> (elf32_avr_help): Help on new -P avr-deviceinfo.
> (elf32_avr_dump) [OPT_AVRDEVICEINFO]: Run...
> (elf32_avr_dump_avr_deviceinfo): ...this new static function.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch,avr] PR31704: Let avr-objdump show .note.gnu.avr.deviceinfo
2024-05-06 12:24 [patch,avr] PR31704: Let avr-objdump show .note.gnu.avr.deviceinfo Georg-Johann Lay
2024-05-16 15:45 ` [ping 1,patch,avr] " Georg-Johann Lay
@ 2024-05-20 11:13 ` Nick Clifton
1 sibling, 0 replies; 3+ messages in thread
From: Nick Clifton @ 2024-05-20 11:13 UTC (permalink / raw)
To: Georg-Johann Lay, binutils
Hi Georg-Johann,
> AVR: binutils/31704 - Let avr-objdump show .note.gnu.avr.deviceinfo
>
> This patch supports
>
> avr-objdump -P avr-deviceinfo
>
> which displays the contents of the .note.gnu.avr.deviceinfo section,
> which is added by the startup code from AVR-LibC in crt<mcu>.o.
Approved and applied. (Sorry for the delay).
Note - it would be nice to have a test for this functionality.
There is a ld-avr directory in the linker testsuite for example...
Cheers
Nick
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-20 11:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-06 12:24 [patch,avr] PR31704: Let avr-objdump show .note.gnu.avr.deviceinfo Georg-Johann Lay
2024-05-16 15:45 ` [ping 1,patch,avr] " Georg-Johann Lay
2024-05-20 11:13 ` [patch,avr] " Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).