Another thing, section target_index is renumbered in
coff_compute_section_file_positions and _bfd_xcoff_bfd_final_link.  I
don't know that there is currently any way that the output bfd
section_by_target_index could be populated before this point but
clear them out so no one need worry about it.
	* coffcode.h (coff_compute_section_file_positions): Clear
	section_by_target_index hash table when changing target_index.
	(_bfd_xcoff_bfd_final_link): Likewise.
       sofar += bfd_coff_scnhsz (abfd);
 #endif
 
+  if (coff_data (abfd)->section_by_target_index)
+    htab_empty (coff_data (abfd)->section_by_target_index);
+
 #ifdef COFF_IMAGE_WITH_PE
   {
     /* PE requires the sections to be in memory order when listed in
 
 
          /* Reset the section indices after inserting the new
             sections.  */
+         if (xcoff_data (abfd)->coff.section_by_target_index)
+           htab_empty (xcoff_data (abfd)->coff.section_by_target_index);
          indx = 0;
          for (o = abfd->sections; o != NULL; o = o->next)
            {