[PATCH v3] gold: Fix non-deterministic behaviour of Mips gold.
Vladimir Radosavljevic
Vladimir.Radosavljevic@imgtec.com
Wed Mar 30 16:43:00 GMT 2016
Thanks for review.
> This hash strategy might produce more collisions than you would like,
> as small symndx values may cancel out small addends. One approach
> would be to shift one or more terms so cancellations are less likely
> (see Reloc_stub::hash_value() in aarch64.cc, for example). Another
> would be to use iterative_hash() from libiberty.
I could use hash algorithm like in Reloc_stub::hash_value(), but what do you think about using FNV-1a hash algorithm ?
It would be look like this:
+ size_t name_hash_value = gold::string_hash<char>(
+ (this->symndx_ != -1U)
+ ? this->d.object->name().c_str()
+ : this->d.sym->name());
+
+ uint64_t h = 14695981039346656037ULL; // FNV offset basis.
+ uint64_t prime = 1099511628211ULL;
+ h = (h ^ static_cast<uint64_t>(name_hash_value)) * prime;
+ h = (h ^ static_cast<uint64_t>(this->symndx_)) * prime;
+ h = (h ^ static_cast<uint64_t>(this->addend_)) * prime;
+ return h;
If you are ok with this, do I need to add case for sizeof(size_t) == 4 ?
Regards,
Vladimir
More information about the Binutils
mailing list