[PATCH] D147890: Fix sysvhash function

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 11 22:30:00 PDT 2023


MaskRay added a comment.

> Elf itself does not talk about character sets for symbol names -- they're merely NUL-terminated sequences of bytes.

Elf => ELF

---

Thanks for the patch! The generic ABI code fragment may have an oversight.
When `long` represents a 64-bit integer, elf_hash((const unsigned char *)"\xff\x0f\x0f\x0f\x0f\x0f\x12") returns 0x100000002, larger than UINT32_MAX.
I created a post on https://groups.google.com/g/generic-abi/c/8J_jtjsonrE



================
Comment at: llvm/include/llvm/Object/ELF.h:1245
   }
-  return h;
+  return H & 0xfffffff;
 }
----------------
`return H & 0x0fffffff;`


================
Comment at: llvm/unittests/Object/ELFTest.cpp:275
+
+// Test the sysV and the gnu hash functions, particularly with utf8 unicode
+TEST(ELFTest, Hash) {
----------------
utf8 => UTF-8


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147890/new/

https://reviews.llvm.org/D147890



More information about the llvm-commits mailing list