Back to index

glibc  2.9
Functions
dl-hash.h File Reference

Go to the source code of this file.

Functions

static unsigned int _dl_elf_hash (const char *name_arg)

Function Documentation

static unsigned int _dl_elf_hash ( const char *  name_arg) [static]

Definition at line 28 of file dl-hash.h.

{
  const unsigned char *name = (const unsigned char *) name_arg;
  unsigned long int hash = 0;
  if (*name != '\0')
    {
      hash = *name++;
      if (*name != '\0')
       {
         hash = (hash << 4) + *name++;
         if (*name != '\0')
           {
             hash = (hash << 4) + *name++;
             if (*name != '\0')
              {
                hash = (hash << 4) + *name++;
                if (*name != '\0')
                  {
                    hash = (hash << 4) + *name++;
                    while (*name != '\0')
                     {
                       unsigned long int hi;
                       hash = (hash << 4) + *name++;
                       hi = hash & 0xf0000000;

                       /* The algorithm specified in the ELF ABI is as
                          follows:

                          if (hi != 0)
                            hash ^= hi >> 24;

                          hash &= ~hi;

                          But the following is equivalent and a lot
                          faster, especially on modern processors.  */

                       hash ^= hi;
                       hash ^= hi >> 24;
                     }
                  }
              }
           }
       }
    }
  return hash;
}

Here is the call graph for this function:

Here is the caller graph for this function: