+2004-03-31 Andy Chittenden <achittenden@bluearc.com>
+
+ * stabs.c (struct stab_link_includes_totals): Rename field 'total'
+ to 'sum_chars' and add field 'num_chars'.
+ (_bfd_link_section_stabs): When computing the sum of the
+ characters in a B_INCL..B_EINCL range also keep a count of the
+ number of characters. Use this information to help distinguish
+ between include sections when have the same sum but which
+ nevertheless are still unique.
+
2004-03-31 Mattias EngdegÄrd <mattias@virtutech.se>
* stabs.c (_bfd_link_section_stabs): Do not skip N_EXCL stabs.
};
/* A linked list of totals that we have found for a particular header
- file. */
+ file. A total is the sum of all the STABS characters for a particular
+ file and the number of these charactes. It is used to identify
+ duplicate files which can be excluded. XXX: A better method would be to
+ compute an MD5 checksum, but that is coding left for another day.
+ The bfd_vma type is used because it is a very large unsigned type. */
struct stab_link_includes_totals
{
struct stab_link_includes_totals *next;
- bfd_vma total;
+ bfd_vma sum_chars; /* Accumulated sum of STABS characters. */
+ bfd_vma num_chars; /* Number of STABS characters. */
};
/* An entry in the header file hash table. */
first number after an open parenthesis). */
if (type == (int) N_BINCL)
{
- bfd_vma val;
+ bfd_vma sum_chars;
+ bfd_vma num_chars;
int nest;
bfd_byte *incl_sym;
struct stab_link_includes_entry *incl_entry;
struct stab_link_includes_totals *t;
struct stab_excl_list *ne;
- val = 0;
+ sum_chars = num_chars = 0;
nest = 0;
for (incl_sym = sym + STABSIZE;
incl_sym < symend;
+ bfd_get_32 (abfd, incl_sym + STRDXOFF));
for (; *str != '\0'; str++)
{
- val += *str;
+ sum_chars += *str;
+ num_chars ++;
if (*str == '(')
{
/* Skip the file number. */
goto error_return;
for (t = incl_entry->totals; t != NULL; t = t->next)
- if (t->total == val)
+ if (t->sum_chars == sum_chars && t->num_chars == num_chars)
break;
/* Record this symbol, so that we can set the value
if (ne == NULL)
goto error_return;
ne->offset = sym - stabbuf;
- ne->val = val;
+ ne->val = sum_chars;
ne->type = (int) N_BINCL;
ne->next = secinfo->excls;
secinfo->excls = ne;
bfd_hash_allocate (&sinfo->includes.root, sizeof *t));
if (t == NULL)
goto error_return;
- t->total = val;
+ t->sum_chars = sum_chars;
+ t->num_chars = num_chars;
t->next = incl_entry->totals;
incl_entry->totals = t;
}