[PATCH] Fix compute_bucket_count
Jakub Jelinek
jakub@redhat.com
Fri Jun 23 16:27:00 GMT 2006
Hi!
I believe this hasn't been updated since (most of) 64-bit targets
started using 4 byte .hash sh_entsize (as required by ELF).
Certainly max = (2 + nsyms) * (bed->s->arch_size / 8);
looks very much like an attempt to compute the size of the .hash
section except the nbuckets part. But
1) on most 64-bit targets .hash entsize is not 8
2) the chains part of .hash section is really dynsymcount entries large
(corresponds 1:1 to .dymsym entries), while nsyms can be smaller number
(STT_SECTION symbols, symbol 0)
On the other side, when not optimizing, compute_bucket_count was looking
at dynsymcount, but in that case the interesting number really is the number
of dynamic symbols that are entered into the .hash table.
What do you think about this?
2006-06-23 Jakub Jelinek <jakub@redhat.com>
* elflink.c (compute_bucket_count): Use bed->s->sizeof_hash_entry
instead of bed->s->arch_size / 8. Fix .hash size estimation.
When not optimizing, use the number of hashed symbols rather than
dynsymcount.
--- bfd/elflink.c.jj 2006-06-20 18:34:53.000000000 +0200
+++ bfd/elflink.c 2006-06-23 17:48:01.000000000 +0200
@@ -4913,9 +4913,9 @@ compute_bucket_count (struct bfd_link_in
# define BFD_TARGET_PAGESIZE (4096)
# endif
- /* We in any case need 2 + NSYMS entries for the size values and
- the chains. */
- max = (2 + nsyms) * (bed->s->arch_size / 8);
+ /* We in any case need 2 + DYNSYMCOUNTS entries for the size values
+ and the chains. */
+ max = (2 + dynsymcount) * bed->s->sizeof_hash_entry;
# if 1
/* Variant 1: optimize for short chains. We add the squares
@@ -4925,7 +4925,7 @@ compute_bucket_count (struct bfd_link_in
max += counts[j] * counts[j];
/* This adds penalties for the overall size of the table. */
- fact = i / (BFD_TARGET_PAGESIZE / (bed->s->arch_size / 8)) + 1;
+ fact = i / (BFD_TARGET_PAGESIZE / bed->s->sizeof_hash_entry) + 1;
max *= fact * fact;
# else
/* Variant 2: Optimize a lot more for small table. Here we
@@ -4936,7 +4936,7 @@ compute_bucket_count (struct bfd_link_in
/* The overall size of the table is considered, but not as
strong as in variant 1, where it is squared. */
- fact = i / (BFD_TARGET_PAGESIZE / (bed->s->arch_size / 8)) + 1;
+ fact = i / (BFD_TARGET_PAGESIZE / bed->s->sizeof_hash_entry) + 1;
max *= fact;
# endif
@@ -4959,7 +4959,7 @@ compute_bucket_count (struct bfd_link_in
for (i = 0; elf_buckets[i] != 0; i++)
{
best_size = elf_buckets[i];
- if (dynsymcount < elf_buckets[i + 1])
+ if ((hashcodesp - hashcodes) < elf_buckets[i + 1])
break;
}
}
Jakub
More information about the Binutils
mailing list