head/libexec/rtld-elf/rtld.c
/* Search for symbol using GNU hash function */
Search for symbol using GNU hash function
Search for symbol using GNU hash function
static int
symlook_obj1_gnu(SymLook *req, const Obj_Entry *obj)
{
	Elf_Addr bloom_word;
	const Elf32_Word *hashval;
	Elf32_Word bucket;
	Sym_Match_Result matchres;
	unsigned int h1, h2;
	unsigned long symnum;
	matchres.sym_out = NULL;
	matchres.vsymp = NULL;
	matchres.vcount = 0;
	bloom_word = obj->bloom_gnu[(req->hash_gnu / __ELF_WORD_SIZE) &
	    obj->maskwords_bm_gnu];
	h1 = req->hash_gnu & (__ELF_WORD_SIZE - 1);
	h2 = ((req->hash_gnu >> obj->shift2_gnu) & (__ELF_WORD_SIZE - 1));
	if (((bloom_word >> h1) & (bloom_word >> h2) & 1) == 0)
		return (ESRCH);
	bucket = obj->buckets_gnu[req->hash_gnu % obj->nbuckets_gnu];
	if (bucket == 0)
		return (ESRCH);
	hashval = &obj->chain_zero_gnu[bucket];
	do {
		if (((*hashval ^ req->hash_gnu) >> 1) == 0) {
			symnum = hashval - obj->chain_zero_gnu;
			if (matched_symbol(req, obj, &matchres, symnum)) {
				req->sym_out = matchres.sym_out;
				req->defobj_out = obj;
				return (0);
			}
		}
	} while ((*hashval++ & 1) == 0);
	if (matchres.vcount == 1) {
		req->sym_out = matchres.vsymp;
		req->defobj_out = obj;
		return (0);
	}
	return (ESRCH);
}
static int symlook_obj1_gnu ( SymLook * req , const Obj_Entry * obj ) { Elf_Addr bloom_word ; const Elf32_Word * hashval ; Elf32_Word bucket ; Sym_Match_Result matchres ; unsigned int h1 , h2 ; unsigned long symnum ; matchres . sym_out = NULL ; matchres . vsymp = NULL ; matchres . vcount = 0 ; bloom_word = obj -> bloom_gnu [ ( req -> hash_gnu / __ELF_WORD_SIZE ) & obj -> maskwords_bm_gnu ] ; h1 = req -> hash_gnu & ( __ELF_WORD_SIZE - 1 ) ; h2 = ( ( req -> hash_gnu >> obj -> shift2_gnu ) & ( __ELF_WORD_SIZE - 1 ) ) ; if ( ( ( bloom_word >> h1 ) & ( bloom_word >> h2 ) & 1 ) == 0 ) return ( ESRCH ) ; bucket = obj -> buckets_gnu [ req -> hash_gnu % obj -> nbuckets_gnu ] ; if ( bucket == 0 ) return ( ESRCH ) ; hashval = & obj -> chain_zero_gnu [ bucket ] ; do { if ( ( ( * hashval ^ req -> hash_gnu ) >> 1 ) == 0 ) { symnum = hashval - obj -> chain_zero_gnu ; if ( matched_symbol ( req , obj , & matchres , symnum ) ) { req -> sym_out = matchres . sym_out ; req -> defobj_out = obj ; return ( 0 ) ; } } } while ( ( * hashval ++ & 1 ) == 0 ) ; if ( matchres . vcount == 1 ) { req -> sym_out = matchres . vsymp ; req -> defobj_out = obj ; return ( 0 ) ; } return ( ESRCH ) ; }
Search for symbol using GNU hash function
Search for symbol using GNU hash function
/* Pick right bitmask word from Bloom filter array */ /* Calculate modulus word size of gnu hash and its derivative */ /* Filter out the "definitely not in set" queries */ /* Locate hash chain and corresponding value element*/