head/libexec/rtld-elf/rtld.c
/*
 * Given a symbol name in a referencing object, find the corresponding
 * definition of the symbol.  Returns a pointer to the symbol, or NULL if
 * no definition was found.  Returns a pointer to the Obj_Entry of the
 * defining object via the reference parameter DEFOBJ_OUT.
 */
Given a symbol name in a referencing object, find the corresponding
definition of the symbol.  Returns a pointer to the symbol, or NULL if
no definition was found.  Returns a pointer to the Obj_Entry of the
defining object via the reference parameter DEFOBJ_OUT.
Given a symbol name in a referencing object find the corresponding definition of the symbol . Returns a pointer to the symbol or NULL if no definition was found . Returns a pointer to the Obj_Entry of the defining object via the reference parameter DEFOBJ_OUT .
static int
symlook_default(SymLook *req, const Obj_Entry *refobj)
{
    DoneList donelist;
    const Objlist_Entry *elm;
    SymLook req1;
    int res;
    donelist_init(&donelist);
    symlook_init_from_req(&req1, req);
    if (refobj->symbolic && !donelist_check(&donelist, refobj)) {
	res = symlook_obj(&req1, refobj);
	if (res == 0) {
	    req->sym_out = req1.sym_out;
	    req->defobj_out = req1.defobj_out;
	    assert(req->defobj_out != NULL);
	}
    }
    symlook_global(req, &donelist);
    STAILQ_FOREACH(elm, &refobj->dldags, link) {
	if (req->sym_out != NULL &&
	  ELF_ST_BIND(req->sym_out->st_info) != STB_WEAK)
	    break;
	res = symlook_list(&req1, &elm->obj->dagmembers, &donelist);
	if (res == 0 && (req->sym_out == NULL ||
	  ELF_ST_BIND(req1.sym_out->st_info) != STB_WEAK)) {
	    req->sym_out = req1.sym_out;
	    req->defobj_out = req1.defobj_out;
	    assert(req->defobj_out != NULL);
	}
    }
    if (req->sym_out == NULL ||
      ELF_ST_BIND(req->sym_out->st_info) == STB_WEAK) {
	res = symlook_obj(&req1, &obj_rtld);
	if (res == 0) {
	    req->sym_out = req1.sym_out;
	    req->defobj_out = req1.defobj_out;
	    assert(req->defobj_out != NULL);
	}
    }
    return (req->sym_out != NULL ? 0 : ESRCH);
}
static int symlook_default ( SymLook * req , const Obj_Entry * refobj ) { DoneList donelist ; const Objlist_Entry * elm ; SymLook req1 ; int res ; donelist_init ( & donelist ) ; symlook_init_from_req ( & req1 , req ) ; if ( refobj -> symbolic && ! donelist_check ( & donelist , refobj ) ) { res = symlook_obj ( & req1 , refobj ) ; if ( res == 0 ) { req -> sym_out = req1 . sym_out ; req -> defobj_out = req1 . defobj_out ; assert ( req -> defobj_out != NULL ) ; } } symlook_global ( req , & donelist ) ; STAILQ_FOREACH ( elm , & refobj -> dldags , link ) { if ( req -> sym_out != NULL && ELF_ST_BIND ( req -> sym_out -> st_info ) != STB_WEAK ) break ; res = symlook_list ( & req1 , & elm -> obj -> dagmembers , & donelist ) ; if ( res == 0 && ( req -> sym_out == NULL || ELF_ST_BIND ( req1 . sym_out -> st_info ) != STB_WEAK ) ) { req -> sym_out = req1 . sym_out ; req -> defobj_out = req1 . defobj_out ; assert ( req -> defobj_out != NULL ) ; } } if ( req -> sym_out == NULL || ELF_ST_BIND ( req -> sym_out -> st_info ) == STB_WEAK ) { res = symlook_obj ( & req1 , & obj_rtld ) ; if ( res == 0 ) { req -> sym_out = req1 . sym_out ; req -> defobj_out = req1 . defobj_out ; assert ( req -> defobj_out != NULL ) ; } } return ( req -> sym_out != NULL ? 0 : ESRCH ) ; }
Given a symbol name in a referencing object, find the corresponding
 definition of the symbol.
Given a symbol name in a referencing object find the corresponding definition of the symbol .
/* Look first in the referencing object if linked symbolically. */ /* Search all dlopened DAGs containing the referencing object. */ /*
     * Search the dynamic linker itself, and possibly resolve the
     * symbol from there.  This is how the application links to
     * dynamic linker services such as dlopen.
     */