+/* Iterate over the property records in R_LIST, and copy each record into
+ the list of records within the relaxation information for the section to
+ which the record applies. */
+
+static void
+avr_elf32_assign_records_to_sections (struct avr_property_record_list *r_list)
+{
+ unsigned int i;
+
+ for (i = 0; i < r_list->record_count; ++i)
+ {
+ struct avr_relax_info *relax_info;
+
+ relax_info = get_avr_relax_info (r_list->records [i].section);
+ BFD_ASSERT (relax_info != NULL);
+
+ if (relax_info->records.count
+ == relax_info->records.allocated)
+ {
+ /* Allocate more space. */
+ bfd_size_type size;
+
+ relax_info->records.allocated += 10;
+ size = (sizeof (struct avr_property_record)
+ * relax_info->records.allocated);
+ relax_info->records.items
+ = bfd_realloc (relax_info->records.items, size);
+ }
+
+ memcpy (&relax_info->records.items [relax_info->records.count],
+ &r_list->records [i],
+ sizeof (struct avr_property_record));
+ relax_info->records.count++;
+ }
+}
+
+/* Compare two STRUCT AVR_PROPERTY_RECORD in AP and BP, used as the
+ ordering callback from QSORT. */
+
+static int
+avr_property_record_compare (const void *ap, const void *bp)
+{
+ const struct avr_property_record *a
+ = (struct avr_property_record *) ap;
+ const struct avr_property_record *b
+ = (struct avr_property_record *) bp;
+
+ if (a->offset != b->offset)
+ return (a->offset - b->offset);
+
+ if (a->section != b->section)
+ return bfd_section_vma (a->section) - bfd_section_vma (b->section);
+
+ return (a->type - b->type);
+}
+
+/* Load all of the avr property sections from all of the bfd objects
+ referenced from LINK_INFO. All of the records within each property
+ section are assigned to the STRUCT AVR_RELAX_INFO within the section
+ specific data of the appropriate section. */
+
+static void
+avr_load_all_property_sections (struct bfd_link_info *link_info)
+{
+ bfd *abfd;
+ asection *sec;
+
+ /* Initialize the per-section relaxation info. */
+ for (abfd = link_info->input_bfds; abfd != NULL; abfd = abfd->link.next)
+ for (sec = abfd->sections; sec != NULL; sec = sec->next)
+ {
+ init_avr_relax_info (sec);
+ }
+
+ /* Load the descriptor tables from .avr.prop sections. */
+ for (abfd = link_info->input_bfds; abfd != NULL; abfd = abfd->link.next)
+ {
+ struct avr_property_record_list *r_list;
+
+ r_list = avr_elf32_load_property_records (abfd);
+ if (r_list != NULL)
+ avr_elf32_assign_records_to_sections (r_list);
+
+ free (r_list);
+ }
+
+ /* Now, for every section, ensure that the descriptor list in the
+ relaxation data is sorted by ascending offset within the section. */
+ for (abfd = link_info->input_bfds; abfd != NULL; abfd = abfd->link.next)
+ for (sec = abfd->sections; sec != NULL; sec = sec->next)
+ {
+ struct avr_relax_info *relax_info = get_avr_relax_info (sec);
+ if (relax_info && relax_info->records.count > 0)
+ {
+ unsigned int i;
+
+ qsort (relax_info->records.items,
+ relax_info->records.count,
+ sizeof (struct avr_property_record),
+ avr_property_record_compare);
+
+ /* For debug purposes, list all the descriptors. */
+ for (i = 0; i < relax_info->records.count; ++i)
+ {
+ switch (relax_info->records.items [i].type)
+ {
+ case RECORD_ORG:
+ break;
+ case RECORD_ORG_AND_FILL:
+ break;
+ case RECORD_ALIGN:
+ break;
+ case RECORD_ALIGN_AND_FILL:
+ break;
+ };
+ }
+ }
+ }
+}
+