+2005-09-28 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR binutils/1321
+ * elf-bfd.h (_bfd_elf_setup_group_pointers): Renamed to ...
+ (_bfd_elf_setup_sections): This.
+ * elf.c: Likewise.
+ * elfcode.h (elf_object_p): Likewise.
+
+ * elf.c (_bfd_elf_setup_sections): Process SHF_LINK_ORDER.
+ (_bfd_elf_copy_private_section_data): Likewise.
+
2005-09-28 H.J. Lu <hongjiu.lu@intel.com>
* elflink.c (elf_fixup_link_order): Report locations for mixed
}
bfd_boolean
-_bfd_elf_setup_group_pointers (bfd *abfd)
+_bfd_elf_setup_sections (bfd *abfd)
{
unsigned int i;
unsigned int num_group = elf_tdata (abfd)->num_group;
bfd_boolean result = TRUE;
+ asection *s;
+
+ /* Process SHF_LINK_ORDER. */
+ for (s = abfd->sections; s != NULL; s = s->next)
+ {
+ Elf_Internal_Shdr *this_hdr = &elf_section_data (s)->this_hdr;
+ if ((this_hdr->sh_flags & SHF_LINK_ORDER) != 0)
+ {
+ unsigned int elfsec = this_hdr->sh_link;
+ /* FIXME: The old Intel compiler and old strip/objcopy may
+ not set the sh_link or sh_info fields. Hence we could
+ get the situation where elfsec is 0. */
+ if (elfsec == 0)
+ {
+ const struct elf_backend_data *bed
+ = get_elf_backend_data (abfd);
+ if (bed->link_order_error_handler)
+ bed->link_order_error_handler
+ (_("%B: warning: sh_link not set for section `%A'"),
+ abfd, s);
+ }
+ else
+ {
+ this_hdr = elf_elfsections (abfd)[elfsec];
+ elf_linked_to_section (s) = this_hdr->bfd_section;
+ }
+ }
+ }
+ /* Process section groups. */
if (num_group == (unsigned) -1)
return result;
/* Set things up for objcopy. The output SHT_GROUP section will
have its elf_next_in_group pointing back to the input group
members. Ignore linker created group section. See
- elfNN_ia64_object_p in elfxx-ia64.c. */
+ elfNN_ia64_object_p in elfxx-ia64.c. We also need to handle
+ elf_linked_to_section for SHF_LINK_ORDER. */
+
+ if ((ihdr->sh_flags & SHF_LINK_ORDER) != 0
+ && elf_linked_to_section (isec) != 0)
+ elf_linked_to_section (osec)
+ = elf_linked_to_section (isec)->output_section;
+
if (elf_sec_group (isec) == NULL
|| (elf_sec_group (isec)->flags & SEC_LINKER_CREATED) == 0)
{
shindex += SHN_HIRESERVE + 1 - SHN_LORESERVE;
}
- /* Set up group pointers. */
- if (! _bfd_elf_setup_group_pointers (abfd))
+ /* Set up ELF sections for SHF_GROUP and SHF_LINK_ORDER. */
+ if (! _bfd_elf_setup_sections (abfd))
goto got_wrong_format_error;
}