]> git.alrj.org Git - bold.git/commitdiff
Correct stupid bug, use a simple hash function.
authorAmand Tihon <amand.tihon@alrj.org>
Mon, 3 Aug 2009 19:44:09 +0000 (21:44 +0200)
committerAmand Tihon <amand.tihon@alrj.org>
Mon, 3 Aug 2009 19:44:09 +0000 (21:44 +0200)
Bold/linker.py
data/bold_ibh-x86_64.asm

index 8bc170a293c2f0b944ae3527232094399b13242c..8549066805cd43843416c529edba77cb3bad5a60 100644 (file)
@@ -26,7 +26,7 @@ def hash_name(name):
   """Caculate the hash of the function name."""
   h = 0
   for c in name:
-    h = (ord(c) - h + (h << 6) + (h << 16) & 0xffffffff)
+    h = ((h * 0x21) ^ ord(c)) & 0xffffffff
   return h
 
 class BoldLinker(object):
index 555555192544030d376e200bd14e5424549b9fec..42a25b49c27c54e951206aea7c2e46be59c1024a 100644 (file)
@@ -36,8 +36,8 @@ _bold__ibh:
   mov rbx, [rbx + 24]                   ; skip the first two link_map entries
   mov rbx, [rbx + 24]
 
-  mov esi, [rel _bold__functions_hash]        ; Implicitly zero-extended
-  mov edi, [rel _bold__functions_pointers]    ; ditto
+  mov esi, _bold__functions_hash        ; Implicitly zero-extended
+  mov edi, _bold__functions_pointers    ; ditto
   mov ecx, _bold__functions_count
 
   ; Load all the symbols
@@ -87,18 +87,13 @@ _bold__ibh:
 
         ; Compute the hash
         xor edx, edx
+        xor eax, eax
         .hash_loop:                       ; over each char
-          xor eax, eax
+          imul edx, edx, byte 0x21
+          xor edx, eax
           lodsb
           test al, al
-          jz .hash_end
-
-          sub eax, edx
-          shl edx, 6
-          add eax, edx
-          shl edx, 10
-          add edx, eax
-          jmp short .hash_loop
+          jnz short .hash_loop
 
         .hash_end:
         cmp edx, r15d                     ; Compare with stored hash