From: Petr Machata Date: Fri, 24 Jul 2009 16:53:37 +0000 (+0200) Subject: dwarflint: Check for duplicate abbreviation codes X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ab8a3a729371c029efd66f03fa792732d6599835;p=thirdparty%2Felfutils.git dwarflint: Check for duplicate abbreviation codes --- diff --git a/src/dwarflint.c b/src/dwarflint.c index 6298a0df3..533f5889d 100644 --- a/src/dwarflint.c +++ b/src/dwarflint.c @@ -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; diff --git a/src/dwarflint.h b/src/dwarflint.h index 9ecc4f71d..4de91e924 100644 --- a/src/dwarflint.h +++ b/src/dwarflint.h @@ -36,7 +36,7 @@ extern "C" SEC (mac) \ SEC (ranges) - enum section_id + enum section_id { sec_invalid = 0,