This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
RE: [PATCH v3] gold: Fix non-deterministic behaviour of Mips gold.
- From: Vladimir Radosavljevic <Vladimir dot Radosavljevic at imgtec dot com>
- To: Cary Coutant <ccoutant at gmail dot com>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>, Petar Jovanovic <Petar dot Jovanovic at imgtec dot com>
- Date: Wed, 30 Mar 2016 16:43:07 +0000
- Subject: RE: [PATCH v3] gold: Fix non-deterministic behaviour of Mips gold.
- Authentication-results: sourceware.org; auth=none
- References: <3060420525346945A0ADBD567348A91723740CBE at BADAG02 dot ba dot imgtec dot org>,<CAJimCsFUEXT1D6-WWvTtvARteOqRwV_EPkuBk+U5YYDaXTZ_DA at mail dot gmail dot com>
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