[llvm] r177872 - [ELF] add elf_hash function to compute the hash value of a symbol in the dynamic symbol table
Shankar Easwaran
shankare at codeaurora.org
Mon Mar 25 13:22:04 PDT 2013
Thanks for the review. Will fix it.
Shankar Easwaran
On 3/25/2013 3:14 PM, Alex Rosenberg wrote:
> This is calling size() for each iteration.
>
> Sent from my iPad
>
> On Mar 25, 2013, at 9:02 AM, Shankar Easwaran <shankare at codeaurora.org> wrote:
>
>> Author: shankare
>> Date: Mon Mar 25 11:02:10 2013
>> New Revision: 177872
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=177872&view=rev
>> Log:
>> [ELF] add elf_hash function to compute the hash value of a symbol in the dynamic symbol table
>>
>> Modified:
>> llvm/trunk/include/llvm/Object/ELF.h
>>
>> Modified: llvm/trunk/include/llvm/Object/ELF.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=177872&r1=177871&r2=177872&view=diff
>> ==============================================================================
>> --- llvm/trunk/include/llvm/Object/ELF.h (original)
>> +++ llvm/trunk/include/llvm/Object/ELF.h Mon Mar 25 11:02:10 2013
>> @@ -2704,6 +2704,21 @@ static inline error_code GetELFSymbolVer
>> llvm_unreachable("Object passed to GetELFSymbolVersion() is not ELF");
>> }
>>
>> +/// This function returns the hash value for a symbol in the .dynsym section
>> +/// Name of the API remains consistent as specified in the libelf
>> +/// REF : http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx
>> +static inline unsigned elf_hash(StringRef &symbolName) {
>> + unsigned h = 0, g;
>> + for (unsigned i = 0; i < symbolName.size(); i++) {
>> + h = (h << 4) + symbolName[i];
>> + g = h & 0xf0000000L;
>> + if (g != 0)
>> + h ^= g >> 24;
>> + h &= ~g;
>> + }
>> + return h;
>> +}
>> +
>> }
>> }
>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation
More information about the llvm-commits
mailing list