diff options
| author | Davide Italiano <davide@freebsd.org> | 2016-11-07 21:56:56 +0000 |
|---|---|---|
| committer | Davide Italiano <davide@freebsd.org> | 2016-11-07 21:56:56 +0000 |
| commit | e7fd0be1b45c7bcc3066d4c60032a2906d48bd64 (patch) | |
| tree | 54c36abbc4a0b073d33011de551dc3ecd6c20b9a | |
| parent | dacb058fd6f9c5b6bf6b04db98572b5afd5a32c7 (diff) | |
| download | bcm5719-llvm-e7fd0be1b45c7bcc3066d4c60032a2906d48bd64.tar.gz bcm5719-llvm-e7fd0be1b45c7bcc3066d4c60032a2906d48bd64.zip | |
[ELF] Use the SystemV hash in libObject instead of rolling our own.
llvm-svn: 286158
| -rw-r--r-- | lld/ELF/OutputSections.cpp | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index fa39213e2e9..bd3bec0579e 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -504,18 +504,6 @@ HashTableSection<ELFT>::HashTableSection() this->Header.sh_addralign = sizeof(Elf_Word); } -static uint32_t hashSysv(StringRef Name) { - uint32_t H = 0; - for (char C : Name) { - H = (H << 4) + C; - uint32_t G = H & 0xf0000000; - if (G) - H ^= G >> 24; - H &= ~G; - } - return H; -} - template <class ELFT> void HashTableSection<ELFT>::finalize() { this->Header.sh_link = Out<ELFT>::DynSymTab->SectionIndex; @@ -542,7 +530,7 @@ template <class ELFT> void HashTableSection<ELFT>::writeTo(uint8_t *Buf) { SymbolBody *Body = S.Symbol; StringRef Name = Body->getName(); unsigned I = Body->DynsymIndex; - uint32_t Hash = hashSysv(Name) % NumSymbols; + uint32_t Hash = hashSysV(Name) % NumSymbols; Chains[I] = Buckets[Hash]; Buckets[Hash] = I; } @@ -1607,7 +1595,7 @@ void VersionDefinitionSection<ELFT>::writeOne(uint8_t *Buf, uint32_t Index, Verdef->vd_next = sizeof(Elf_Verdef) + sizeof(Elf_Verdaux); Verdef->vd_flags = (Index == 1 ? VER_FLG_BASE : 0); Verdef->vd_ndx = Index; - Verdef->vd_hash = hashSysv(Name); + Verdef->vd_hash = hashSysV(Name); auto *Verdaux = reinterpret_cast<Elf_Verdaux *>(Buf + sizeof(Elf_Verdef)); Verdaux->vda_name = NameOff; |

