avr/objdump: Support dumping .avr.prop section.

Add support to objdump for dumping the .avr.prop section in a structured
way.

binutils/ChangeLog:

	* od-elf32_avr.c: Add elf32-avr.h include.
	(OPT_AVRPROP): Define.
	(options[]): Add 'avr-prop' entry.
	(elf32_avr_help): Add avr-prop help text.
	(elf32_avr_dump_avr_prop): New function.
	(elf32_avr_dump): Add check for avr-prop.

bfd/ChangeLog:

	* elf32-avr.h (struct avr_property_header): New strucure.
	(avr_elf32_load_property_records): Declare.
	(avr_elf32_property_record_name): Declare.
	* elf32-avr.c: Add bfd_stdint.h include.
	(retrieve_local_syms): New function.
	(get_elf_r_symndx_section): New function.
	(get_elf_r_symndx_offset): New function.
	(internal_reloc_compare): New function.
	(struct avr_find_section_data): New structure.
	(avr_is_section_for_address): New function.
	(avr_find_section_for_address): New function.
	(avr_elf32_load_records_from_section): New function.
	(avr_elf32_load_property_records): New function.
	(avr_elf32_property_record_name): New function.

gas/testsuite/ChangeLog:

	* gas/avr/avr-prop-1.d: New file.
	* gas/avr/avr-prop-1.s: New file.
This commit is contained in:
Andrew Burgess
2015-01-08 21:55:43 +00:00
parent fdd410ac7a
commit 137c83d69f
8 changed files with 611 additions and 0 deletions

View File

@@ -31,14 +31,17 @@
#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
#define OPT_AVRPROP 1
/* List of actions. */
static struct objdump_private_option options[] =
{
{ "mem-usage", 0 },
{ "avr-prop", 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\
avr-prop Display contents of .avr.prop section\n\
"));
}
@@ -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_get_section_vma (abfd, 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.org.fill);
break;
}
}
free (r_list);
}
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 =