Esempio n. 1
0
/*
 * INPUT:
 *     sym: symbol that has been through BFD-demangling
 *
 * This function looks for the following indicators:
 *
 *  1. The hash must consist of "h" followed by 16 lowercase hex digits.
 *
 *  2. As a sanity check, the hash must use between 5 and 15 of the 16 possible
 *     hex digits. This is true of 99.9998% of hashes so once in your life you
 *     may see a false negative. The point is to notice path components that
 *     could be Rust hashes but are probably not, like "haaaaaaaaaaaaaaaa". In
 *     this case a false positive (non-Rust symbol has an important path
 *     component removed because it looks like a Rust hash) is worse than a
 *     false negative (the rare Rust symbol is not demangled) so this sets the
 *     balance in favor of false negatives.
 *
 *  3. There must be no characters other than a-zA-Z0-9 and _.:$
 *
 *  4. There must be no unrecognized $-sign sequences.
 *
 *  5. There must be no sequence of three or more dots in a row ("...").
 */
static Bool rust_is_mangled(const HChar *sym)
{
   SizeT len, len_without_hash;

   if (!sym)
      return False;

   len = VG_(strlen)(sym);
   if (len <= hash_prefix_len + hash_len)
      /* Not long enough to contain "::h" + hash + something else */
      return False;

   len_without_hash = len - (hash_prefix_len + hash_len);
   if (!is_prefixed_hash(sym + len_without_hash))
      return False;

   return looks_like_rust(sym, len_without_hash);
}
Esempio n. 2
0
int
rust_is_mangled (const char *sym)
{
  size_t len, len_without_hash;

  if (!sym)
    return 0;

  len = strlen (sym);
  if (len <= hash_prefix_len + hash_len)
    /* Not long enough to contain "::h" + hash + something else */
    return 0;

  len_without_hash = len - (hash_prefix_len + hash_len);
  if (!is_prefixed_hash (sym + len_without_hash))
    return 0;

  return looks_like_rust (sym, len_without_hash);
}