* dwarf2read.c (create_addrmap_from_index): Complain about bad CU
authorDoug Evans <dje@google.com>
Fri, 29 Mar 2013 00:18:32 +0000 (00:18 +0000)
committerDoug Evans <dje@google.com>
Fri, 29 Mar 2013 00:18:32 +0000 (00:18 +0000)
index numbers.

gdb/ChangeLog
gdb/dwarf2read.c

index 043093e01a86af531377af2c57ac5d86d441be86..2838b3c9847d4904243c69648d4c5b84bbb2c25f 100644 (file)
@@ -1,5 +1,8 @@
 2013-03-28  Doug Evans  <dje@google.com>
 
+       * dwarf2read.c (create_addrmap_from_index): Complain about bad CU
+       index numbers.
+
        * dwarf2read.c (dw2_get_file_names): Delete arg "objfile".
        All callers updated.
        (dw2_print_stats): Print #read CUs too.
index 2062448acf50491d2e2c1b5a05bfe7cb01a66796..a3e68cd0613c4f3fc0061966b5c28b745b55773c 100644 (file)
@@ -2530,9 +2530,18 @@ create_addrmap_from_index (struct objfile *objfile, struct mapped_index *index)
       iter += 8;
       cu_index = extract_unsigned_integer (iter, 4, BFD_ENDIAN_LITTLE);
       iter += 4;
-      
-      addrmap_set_empty (mutable_map, lo + baseaddr, hi + baseaddr - 1,
-                        dw2_get_cu (cu_index));
+
+      if (cu_index < dwarf2_per_objfile->n_comp_units)
+       {
+         addrmap_set_empty (mutable_map, lo + baseaddr, hi + baseaddr - 1,
+                            dw2_get_cu (cu_index));
+       }
+      else
+       {
+         complaint (&symfile_complaints,
+                    _(".gdb_index address table has invalid CU number %u"),
+                    (unsigned) cu_index);
+       }
     }
 
   objfile->psymtabs_addrmap = addrmap_create_fixed (mutable_map,