Re: Add section caches to coff_data_type
authorAlan Modra <amodra@gmail.com>
Thu, 18 May 2023 08:13:14 +0000 (17:43 +0930)
committerAlan Modra <amodra@gmail.com>
Thu, 18 May 2023 08:31:49 +0000 (18:01 +0930)
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.

bfd/coffcode.h
bfd/xcofflink.c

index 777515e82e173941aaa072553a1cd48175057b49..2d4298288220d5aabd0f96ec31dab95104ea2ba7 100644 (file)
@@ -3067,6 +3067,9 @@ coff_compute_section_file_positions (bfd * abfd)
       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
index b57ed21afb9071611b4cbbc98ad5df8adfb17db8..a27721301dd8436165e2eb4fb3117dced43996b5 100644 (file)
@@ -7076,6 +7076,8 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
 
          /* 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)
            {