[PATCH] dwarf: properly update all_comp_units_without_ranges in stash_comp_unit

oltolm oleg.tolmatcev@gmail.com
Thu Sep 18 12:04:25 GMT 2025


 	      each->next_unit_without_ranges = file->all_comp_units_without_ranges;
-	      file->all_comp_units_without_ranges = each->next_unit_without_ranges;

The second line of this code is probably a bug because it does nothing. It
was probably supposed to update "file->all_comp_units_without_ranges" to point
to "each" - the new head of the list.

Signed-off-by: oltolm <oleg.tolmatcev@gmail.com>
---
 bfd/dwarf2.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index a62c952374..ab01958281 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -5635,17 +5635,19 @@ stash_comp_unit (struct dwarf2_debug *stash, struct dwarf2_debug_file *file)
 			     (splay_tree_value)each);
 
 	  if (file->all_comp_units)
-	    file->all_comp_units->prev_unit = each;
+	    {
+	      file->all_comp_units->prev_unit = each;
+	      each->next_unit = file->all_comp_units;
+	    }
 	  else
 	    file->last_comp_unit = each;
 
-	  each->next_unit = file->all_comp_units;
 	  file->all_comp_units = each;
 
 	  if (each->arange.high == 0)
 	    {
 	      each->next_unit_without_ranges = file->all_comp_units_without_ranges;
-	      file->all_comp_units_without_ranges = each->next_unit_without_ranges;
+	      file->all_comp_units_without_ranges = each;
 	    }
 
 	  file->info_ptr += length;
-- 
2.51.0.windows.1



More information about the Binutils mailing list