]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add new overload of dwarf5_djb_hash
authorTom Tromey <tom@tromey.com>
Sun, 21 Mar 2021 17:15:57 +0000 (11:15 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 12 Apr 2022 15:31:16 +0000 (09:31 -0600)
This adds a new overload of dwarf5_djb_hash.  This is used in
subsequent patches.

gdb/dwarf2/index-common.c
gdb/dwarf2/index-common.h

index c2bb1c6f78e02851efb3c2b6bdb0bf03c0d6b624..d8f9973d6ccab01de7b0da88b7e1c9b543c39670 100644 (file)
@@ -54,3 +54,17 @@ dwarf5_djb_hash (const char *str_)
     hash = hash * 33 + tolower (c);
   return hash;
 }
+
+/* See dwarf-index-common.h.  */
+
+uint32_t
+dwarf5_djb_hash (gdb::string_view str)
+{
+  /* Note: tolower here ignores UTF-8, which isn't fully compliant.
+     See http://dwarfstd.org/ShowIssue.php?issue=161027.1.  */
+
+  uint32_t hash = 5381;
+  for (char c : str)
+    hash = hash * 33 + tolower (c & 0xff);
+  return hash;
+}
index 049e1d894f194a2fbcbca37f27a63b2ba37eb457..cbfb88a4e98133781fb6c0b48b3a905956b5a7d2 100644 (file)
@@ -52,4 +52,8 @@ hashval_t mapped_index_string_hash (int index_version, const void *p);
 
 uint32_t dwarf5_djb_hash (const char *str_);
 
+/* Symbol name hashing function as specified by DWARF-5.  */
+
+uint32_t dwarf5_djb_hash (gdb::string_view str_);
+
 #endif /* DWARF_INDEX_COMMON_H */