]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Check for duplicate abbreviation codes
authorPetr Machata <pmachata@redhat.com>
Fri, 24 Jul 2009 16:53:37 +0000 (18:53 +0200)
committerPetr Machata <pmachata@redhat.com>
Tue, 4 Aug 2009 14:01:51 +0000 (16:01 +0200)
src/dwarflint.c
src/dwarflint.h

index 6298a0df3b7ca32652a20c91aefaf8bde1938c21..533f5889dfa9d802feb6d14d56e7f00f87fdec9a 100644 (file)
@@ -1534,9 +1534,24 @@ abbrev_table_load (struct read_ctx *ctx)
          where_reset_1 (&where, abbr_off);
          where_reset_2 (&where, abbr_off);
        }
-      REALLOC (section, abbr);
 
-      struct abbrev *cur = section->abbr + section->size++;
+      struct abbrev *original = abbrev_table_find_abbrev (section, abbr_code);
+      if (unlikely (original != NULL))
+       {
+         char *site1 = strdup (where_fmt (&original->where, NULL));
+         wr_error (&where, ": duplicate abbrev code %" PRId64
+                   "; already defined at %s.\n", abbr_code, site1);
+         free (site1);
+       }
+
+      REALLOC (section, abbr);
+      struct abbrev fake;
+      struct abbrev *cur;
+      /* Don't actually save this abbrev if it's duplicate.  */
+      if (likely (original == NULL))
+       cur = section->abbr + section->size++;
+      else
+       cur = &fake;
       WIPE (*cur);
 
       cur->code = abbr_code;
index 9ecc4f71d5f9d8e5874bd6438651b51061259d19..4de91e92437eaf2a165f045e37aa8f5b27d78878 100644 (file)
@@ -36,7 +36,7 @@ extern "C"
   SEC (mac)               \
   SEC (ranges)
 
-    enum section_id
+  enum section_id
   {
     sec_invalid = 0,