1 /* $NetBSD: symbol.c,v 1.75 2023/04/18 22:42:52 christos Exp $ */
2
3 /*
4 * Copyright 1996 John D. Polstra.
5 * Copyright 1996 Matt Thomas <matt@3am-software.com>
6 * Copyright 2002 Charles M. Hannum <root@ihack.net>
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by John Polstra.
20 * 4. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 /*
36 * Dynamic linker for ELF.
37 *
38 * John Polstra <jdp@polstra.com>.
39 */
40
41 #include <sys/cdefs.h>
42 #ifndef lint
43 __RCSID("$NetBSD: symbol.c,v 1.75 2023/04/18 22:42:52 christos Exp $");
44 #endif /* not lint */
45
46 #include <err.h>
47 #include <errno.h>
48 #include <fcntl.h>
49 #include <stdarg.h>
50 #include <stdio.h>
51 #include <stdlib.h>
52 #include <string.h>
53 #include <unistd.h>
54 #include <sys/types.h>
55 #include <sys/mman.h>
56 #include <sys/bitops.h>
57 #include <dirent.h>
58
59 #include "debug.h"
60 #include "rtld.h"
61
62 /*
63 * If the given object is already in the donelist, return true. Otherwise
64 * add the object to the list and return false.
65 */
66 static bool
_rtld_donelist_check(DoneList * dlp,const Obj_Entry * obj)67 _rtld_donelist_check(DoneList *dlp, const Obj_Entry *obj)
68 {
69 unsigned int i;
70
71 for (i = 0; i < dlp->num_used; i++)
72 if (dlp->objs[i] == obj)
73 return true;
74 /*
75 * Our donelist allocation may not always be sufficient as we're not
76 * thread safe. We'll handle it properly anyway.
77 */
78 if (dlp->num_used < dlp->num_alloc)
79 dlp->objs[dlp->num_used++] = obj;
80 return false;
81 }
82
83 /*
84 * SysV hash function for symbol table lookup. It is a slightly optimized
85 * version of the hash specified by the System V ABI.
86 */
87 Elf32_Word
_rtld_sysv_hash(const char * name)88 _rtld_sysv_hash(const char *name)
89 {
90 const unsigned char *p = (const unsigned char *) name;
91 Elf32_Word h = 0;
92
93 while (__predict_true(*p != '\0')) {
94 h = (h << 4) + *p++;
95 h ^= (h >> 24) & 0xf0;
96 }
97 return (h & 0x0fffffff);
98 }
99
100 /*
101 * Hash function for symbol table lookup. Don't even think about changing
102 * this. It is specified by the GNU toolchain ABI.
103 */
104 Elf32_Word
_rtld_gnu_hash(const char * name)105 _rtld_gnu_hash(const char *name)
106 {
107 const unsigned char *p = (const unsigned char *) name;
108 uint_fast32_t h = 5381;
109 unsigned char c;
110
111 for (c = *p; c != '\0'; c = *++p)
112 h = h * 33 + c;
113 return (h & 0xffffffff);
114 }
115
116 const Elf_Sym *
_rtld_symlook_list(const char * name,Elf_Hash * hash,const Objlist * objlist,const Obj_Entry ** defobj_out,u_int flags,const Ver_Entry * ventry,DoneList * dlp)117 _rtld_symlook_list(const char *name, Elf_Hash *hash, const Objlist *objlist,
118 const Obj_Entry **defobj_out, u_int flags, const Ver_Entry *ventry,
119 DoneList *dlp)
120 {
121 const Elf_Sym *symp;
122 const Elf_Sym *def;
123 const Obj_Entry *defobj;
124 const Objlist_Entry *elm;
125
126 def = NULL;
127 defobj = NULL;
128 SIMPLEQ_FOREACH(elm, objlist, link) {
129 if (_rtld_donelist_check(dlp, elm->obj))
130 continue;
131 rdbg(("search object %p (%s) for %s", elm->obj, elm->obj->path,
132 name));
133 symp = _rtld_symlook_obj(name, hash, elm->obj, flags, ventry);
134 if (symp != NULL) {
135 if ((def == NULL) ||
136 (ELF_ST_BIND(symp->st_info) != STB_WEAK)) {
137 def = symp;
138 defobj = elm->obj;
139 if (ELF_ST_BIND(def->st_info) != STB_WEAK)
140 break;
141 }
142 }
143 }
144 if (def != NULL)
145 *defobj_out = defobj;
146 return def;
147 }
148
149 /*
150 * Search the symbol table of a shared object and all objects needed by it for
151 * a symbol of the given name. Search order is breadth-first. Returns a pointer
152 * to the symbol, or NULL if no definition was found.
153 */
154 const Elf_Sym *
_rtld_symlook_needed(const char * name,Elf_Hash * hash,const Needed_Entry * needed,const Obj_Entry ** defobj_out,u_int flags,const Ver_Entry * ventry,DoneList * breadth,DoneList * depth)155 _rtld_symlook_needed(const char *name, Elf_Hash *hash,
156 const Needed_Entry *needed, const Obj_Entry **defobj_out, u_int flags,
157 const Ver_Entry *ventry, DoneList *breadth, DoneList *depth)
158 {
159 const Elf_Sym *def, *def_w;
160 const Needed_Entry *n;
161 const Obj_Entry *obj, *defobj, *defobj1;
162
163 def = def_w = NULL;
164 defobj = NULL;
165 for (n = needed; n != NULL; n = n->next) {
166 if ((obj = n->obj) == NULL)
167 continue;
168 if (_rtld_donelist_check(breadth, obj))
169 continue;
170 def = _rtld_symlook_obj(name, hash, obj, flags, ventry);
171 if (def == NULL)
172 continue;
173 defobj = obj;
174 if (ELF_ST_BIND(def->st_info) != STB_WEAK) {
175 *defobj_out = defobj;
176
177 return (def);
178 }
179 }
180 /*
181 * Either the symbol definition has not been found in directly needed
182 * objects, or the found symbol is weak.
183 */
184 for (n = needed; n != NULL; n = n->next) {
185 if ((obj = n->obj) == NULL)
186 continue;
187 if (_rtld_donelist_check(depth, obj))
188 continue;
189 def_w = _rtld_symlook_needed(name, hash, obj->needed, &defobj1,
190 flags, ventry, breadth, depth);
191 if (def_w == NULL)
192 continue;
193 if (def == NULL || ELF_ST_BIND(def_w->st_info) != STB_WEAK) {
194 def = def_w;
195 defobj = defobj1;
196 if (ELF_ST_BIND(def_w->st_info) != STB_WEAK)
197 break;
198 }
199 }
200 if (def != NULL)
201 *defobj_out = defobj;
202
203 return def;
204 }
205
206 static bool
_rtld_symlook_obj_matched_symbol(const char * name,const Obj_Entry * obj,u_int flags,const Ver_Entry * ventry,unsigned long symnum,const Elf_Sym ** vsymp,int * vcount)207 _rtld_symlook_obj_matched_symbol(const char *name,
208 const Obj_Entry *obj, u_int flags, const Ver_Entry *ventry,
209 unsigned long symnum, const Elf_Sym **vsymp, int *vcount)
210 {
211 const Elf_Sym *symp;
212 const char *strp;
213 Elf_Half verndx;
214
215 symp = obj->symtab + symnum;
216 strp = obj->strtab + symp->st_name;
217 rdbg(("check \"%s\" vs \"%s\" in %s", name, strp, obj->path));
218 if (name[1] != strp[1] || strcmp(name, strp))
219 return false;
220 #if defined(__mips__) || defined(__vax__)
221 if (symp->st_shndx == SHN_UNDEF)
222 return false;
223 #else
224 /*
225 * XXX DANGER WILL ROBINSON!
226 * If we have a function pointer in the executable's
227 * data section, it points to the executable's PLT
228 * slot, and there is NO relocation emitted. To make
229 * the function pointer comparable to function pointers
230 * in shared libraries, we must resolve data references
231 * in the libraries to point to PLT slots in the
232 * executable, if they exist.
233 */
234 if (symp->st_shndx == SHN_UNDEF &&
235 ((flags & SYMLOOK_IN_PLT) ||
236 symp->st_value == 0 ||
237 ELF_ST_TYPE(symp->st_info) != STT_FUNC))
238 return false;
239 #endif
240
241 if (ventry == NULL) {
242 if (obj->versyms != NULL) {
243 verndx = VER_NDX(obj->versyms[symnum].vs_vers);
244 if (verndx > obj->vertabnum) {
245 _rtld_error("%s: symbol %s references "
246 "wrong version %d", obj->path,
247 &obj->strtab[symnum], verndx);
248 return false;
249 }
250
251 /*
252 * If we are not called from dlsym (i.e. this
253 * is a normal relocation from unversioned
254 * binary), accept the symbol immediately
255 * if it happens to have first version after
256 * this shared object became versioned.
257 * Otherwise, if symbol is versioned and not
258 * hidden, remember it. If it is the only
259 * symbol with this name exported by the shared
260 * object, it will be returned as a match at the
261 * end of the function. If symbol is global
262 * (verndx < 2) accept it unconditionally.
263 */
264 if (!(flags & SYMLOOK_DLSYM) &&
265 verndx == VER_NDX_GIVEN) {
266 *vsymp = symp;
267 return true;
268 } else if (verndx >= VER_NDX_GIVEN) {
269 if (!(obj->versyms[symnum].vs_vers & VER_NDX_HIDDEN)) {
270 if (*vsymp == NULL)
271 *vsymp = symp;
272 (*vcount)++;
273 }
274 return false;
275 }
276 }
277 *vsymp = symp;
278 return true;
279 } else {
280 if (obj->versyms == NULL) {
281 if (_rtld_object_match_name(obj, ventry->name)){
282 _rtld_error("%s: object %s should "
283 "provide version %s for symbol %s",
284 _rtld_objself.path, obj->path,
285 ventry->name, &obj->strtab[symnum]);
286 return false;
287 }
288 } else {
289 verndx = VER_NDX(obj->versyms[symnum].vs_vers);
290 if (verndx > obj->vertabnum) {
291 _rtld_error("%s: symbol %s references "
292 "wrong version %d", obj->path,
293 &obj->strtab[symnum], verndx);
294 return false;
295 }
296 if (obj->vertab[verndx].hash != ventry->hash ||
297 strcmp(obj->vertab[verndx].name, ventry->name)) {
298 /*
299 * Version does not match. Look if this
300 * is a global symbol and if it is not
301 * hidden. If global symbol (verndx < 2)
302 * is available, use it. Do not return
303 * symbol if we are called by dlvsym,
304 * because dlvsym looks for a specific
305 * version and default one is not what
306 * dlvsym wants.
307 */
308 if ((flags & SYMLOOK_DLSYM) ||
309 (obj->versyms[symnum].vs_vers & VER_NDX_HIDDEN) ||
310 (verndx >= VER_NDX_GIVEN))
311 return false;
312 }
313 }
314 *vsymp = symp;
315 return true;
316 }
317 }
318
319 /*
320 * Search the symbol table of a single shared object for a symbol of
321 * the given name. Returns a pointer to the symbol, or NULL if no
322 * definition was found.
323 *
324 * SysV Hash version.
325 */
326 static const Elf_Sym *
_rtld_symlook_obj_sysv(const char * name,unsigned long hash,const Obj_Entry * obj,u_int flags,const Ver_Entry * ventry)327 _rtld_symlook_obj_sysv(const char *name, unsigned long hash,
328 const Obj_Entry *obj, u_int flags, const Ver_Entry *ventry)
329 {
330 unsigned long symnum;
331 const Elf_Sym *vsymp = NULL;
332 int vcount = 0;
333
334 for (symnum = obj->buckets[fast_remainder32(hash, obj->nbuckets,
335 obj->nbuckets_m, obj->nbuckets_s1, obj->nbuckets_s2)];
336 symnum != ELF_SYM_UNDEFINED;
337 symnum = obj->chains[symnum]) {
338 assert(symnum < obj->nchains);
339
340 if (_rtld_symlook_obj_matched_symbol(name, obj, flags,
341 ventry, symnum, &vsymp, &vcount)) {
342 return vsymp;
343 }
344 }
345 if (vcount == 1)
346 return vsymp;
347 return NULL;
348 }
349
350 /*
351 * Search the symbol table of a single shared object for a symbol of
352 * the given name. Returns a pointer to the symbol, or NULL if no
353 * definition was found.
354 *
355 * GNU Hash version.
356 */
357 static const Elf_Sym *
_rtld_symlook_obj_gnu(const char * name,unsigned long hash,const Obj_Entry * obj,u_int flags,const Ver_Entry * ventry)358 _rtld_symlook_obj_gnu(const char *name, unsigned long hash,
359 const Obj_Entry *obj, u_int flags, const Ver_Entry *ventry)
360 {
361 unsigned long symnum;
362 const Elf_Sym *vsymp = NULL;
363 const Elf32_Word *hashval;
364 Elf_Addr bloom_word;
365 Elf32_Word bucket;
366 int vcount = 0;
367 unsigned int h1, h2;
368
369 /* Pick right bitmask word from Bloom filter array */
370 bloom_word = obj->bloom_gnu[(hash / ELFSIZE) & obj->mask_bm_gnu];
371
372 /* Calculate modulus word size of gnu hash and its derivative */
373 h1 = hash & (ELFSIZE - 1);
374 h2 = ((hash >> obj->shift2_gnu) & (ELFSIZE - 1));
375
376 /* Filter out the "definitely not in set" queries */
377 if (((bloom_word >> h1) & (bloom_word >> h2) & 1) == 0)
378 return NULL;
379
380 /* Locate hash chain and corresponding value element*/
381 bucket = obj->buckets_gnu[fast_remainder32(hash, obj->nbuckets_gnu,
382 obj->nbuckets_m_gnu, obj->nbuckets_s1_gnu, obj->nbuckets_s2_gnu)];
383 if (bucket == 0)
384 return NULL;
385
386 hashval = &obj->chains_gnu[bucket];
387 do {
388 if (((*hashval ^ hash) >> 1) == 0) {
389 symnum = hashval - obj->chains_gnu;
390
391 if (_rtld_symlook_obj_matched_symbol(name, obj, flags,
392 ventry, symnum, &vsymp, &vcount)) {
393 return vsymp;
394 }
395 }
396 } while ((*hashval++ & 1) == 0);
397 if (vcount == 1)
398 return vsymp;
399 return NULL;
400 }
401
402 /*
403 * Search the symbol table of a single shared object for a symbol of
404 * the given name. Returns a pointer to the symbol, or NULL if no
405 * definition was found.
406 *
407 * The symbol's hash value is passed in for efficiency reasons; that
408 * eliminates many recomputations of the hash value.
409 *
410 * Redirect to either GNU Hash (whenever available) or ELF Hash.
411 */
412 const Elf_Sym *
_rtld_symlook_obj(const char * name,Elf_Hash * hash,const Obj_Entry * obj,u_int flags,const Ver_Entry * ventry)413 _rtld_symlook_obj(const char *name, Elf_Hash *hash,
414 const Obj_Entry *obj, u_int flags, const Ver_Entry *ventry)
415 {
416
417 assert(obj->sysv_hash || obj->gnu_hash);
418
419 /* Always prefer the GNU Hash as it is faster. */
420 if (obj->gnu_hash)
421 return _rtld_symlook_obj_gnu(name, hash->gnu, obj, flags, ventry);
422 else
423 return _rtld_symlook_obj_sysv(name, hash->sysv, obj, flags, ventry);
424 }
425
426 /*
427 * Given a symbol number in a referencing object, find the corresponding
428 * definition of the symbol. Returns a pointer to the symbol, or NULL if
429 * no definition was found. Returns a pointer to the Obj_Entry of the
430 * defining object via the reference parameter DEFOBJ_OUT.
431 */
432 const Elf_Sym *
_rtld_find_symdef(unsigned long symnum,const Obj_Entry * refobj,const Obj_Entry ** defobj_out,u_int flags)433 _rtld_find_symdef(unsigned long symnum, const Obj_Entry *refobj,
434 const Obj_Entry **defobj_out, u_int flags)
435 {
436 const Elf_Sym *ref;
437 const Elf_Sym *def;
438 const Obj_Entry *defobj;
439 const char *name;
440 Elf_Hash hash;
441
442 ref = refobj->symtab + symnum;
443 name = refobj->strtab + ref->st_name;
444
445 /*
446 * We don't have to do a full scale lookup if the symbol is local.
447 * We know it will bind to the instance in this load module; to
448 * which we already have a pointer (ie ref).
449 */
450 if (ELF_ST_BIND(ref->st_info) != STB_LOCAL) {
451 if (ELF_ST_TYPE(ref->st_info) == STT_SECTION) {
452 _rtld_error("%s: Bogus symbol table entry %lu",
453 refobj->path, symnum);
454 }
455
456 hash.sysv = _rtld_sysv_hash(name);
457 hash.gnu = _rtld_gnu_hash(name);
458 defobj = NULL;
459 def = _rtld_symlook_default(name, &hash, refobj, &defobj, flags,
460 _rtld_fetch_ventry(refobj, symnum));
461 } else {
462 rdbg(("STB_LOCAL symbol %s in %s", name, refobj->path));
463 def = ref;
464 defobj = refobj;
465 }
466
467 /*
468 * If we found no definition and the reference is weak, treat the
469 * symbol as having the value zero.
470 */
471 if (def == NULL && ELF_ST_BIND(ref->st_info) == STB_WEAK) {
472 rdbg((" returning _rtld_sym_zero@_rtld_objself"));
473 def = &_rtld_sym_zero;
474 defobj = &_rtld_objself;
475 }
476
477 if (def != NULL) {
478 *defobj_out = defobj;
479 } else {
480 rdbg(("lookup failed"));
481 _rtld_error("%s: Undefined %ssymbol \"%s\" (symnum = %ld)",
482 refobj->path, (flags & SYMLOOK_IN_PLT) ? "PLT " : "",
483 name, symnum);
484 }
485 return def;
486 }
487
488 const Elf_Sym *
_rtld_find_plt_symdef(unsigned long symnum,const Obj_Entry * obj,const Obj_Entry ** defobj,bool imm)489 _rtld_find_plt_symdef(unsigned long symnum, const Obj_Entry *obj,
490 const Obj_Entry **defobj, bool imm)
491 {
492 const Elf_Sym *def = _rtld_find_symdef(symnum, obj, defobj,
493 SYMLOOK_IN_PLT);
494 if (__predict_false(def == NULL))
495 return NULL;
496
497 if (__predict_false(def == &_rtld_sym_zero)) {
498 /* tp is set during lazy binding. */
499 if (imm) {
500 const Elf_Sym *ref = obj->symtab + symnum;
501 const char *name = obj->strtab + ref->st_name;
502
503 _rtld_error(
504 "%s: Trying to call undefined weak symbol `%s'",
505 obj->path, name);
506 return NULL;
507 }
508 }
509 return def;
510 }
511
512 /*
513 * Given a symbol name in a referencing object, find the corresponding
514 * definition of the symbol. Returns a pointer to the symbol, or NULL if
515 * no definition was found. Returns a pointer to the Obj_Entry of the
516 * defining object via the reference parameter DEFOBJ_OUT.
517 */
518 const Elf_Sym *
_rtld_symlook_default(const char * name,Elf_Hash * hash,const Obj_Entry * refobj,const Obj_Entry ** defobj_out,u_int flags,const Ver_Entry * ventry)519 _rtld_symlook_default(const char *name, Elf_Hash *hash,
520 const Obj_Entry *refobj, const Obj_Entry **defobj_out, u_int flags,
521 const Ver_Entry *ventry)
522 {
523 const Elf_Sym *def;
524 const Elf_Sym *symp;
525 const Obj_Entry *obj;
526 const Obj_Entry *defobj;
527 const Objlist_Entry *elm;
528 def = NULL;
529 defobj = NULL;
530 DoneList donelist;
531
532 _rtld_donelist_init(&donelist);
533
534 /* Look first in the referencing object if linked symbolically. */
535 if (refobj->symbolic && !_rtld_donelist_check(&donelist, refobj)) {
536 rdbg(("search referencing object for %s", name));
537 symp = _rtld_symlook_obj(name, hash, refobj, flags, ventry);
538 if (symp != NULL) {
539 def = symp;
540 defobj = refobj;
541 }
542 }
543
544 /* Search all objects loaded at program start up. */
545 if (def == NULL || ELF_ST_BIND(def->st_info) == STB_WEAK) {
546 rdbg(("search _rtld_list_main for %s", name));
547 symp = _rtld_symlook_list(name, hash, &_rtld_list_main, &obj,
548 flags, ventry, &donelist);
549 if (symp != NULL &&
550 (def == NULL || ELF_ST_BIND(symp->st_info) != STB_WEAK)) {
551 def = symp;
552 defobj = obj;
553 }
554 }
555
556 /* Search all RTLD_GLOBAL objects. */
557 if (def == NULL || ELF_ST_BIND(def->st_info) == STB_WEAK) {
558 rdbg(("search _rtld_list_global for %s", name));
559 symp = _rtld_symlook_list(name, hash, &_rtld_list_global,
560 &obj, flags, ventry, &donelist);
561 if (symp != NULL &&
562 (def == NULL || ELF_ST_BIND(symp->st_info) != STB_WEAK)) {
563 def = symp;
564 defobj = obj;
565 }
566 }
567
568 /* Search all dlopened DAGs containing the referencing object. */
569 SIMPLEQ_FOREACH(elm, &refobj->dldags, link) {
570 if (def != NULL && ELF_ST_BIND(def->st_info) != STB_WEAK)
571 break;
572 rdbg(("search DAG with root %p (%s) for %s", elm->obj,
573 elm->obj->path, name));
574 symp = _rtld_symlook_list(name, hash, &elm->obj->dagmembers,
575 &obj, flags, ventry, &donelist);
576 if (symp != NULL &&
577 (def == NULL || ELF_ST_BIND(symp->st_info) != STB_WEAK)) {
578 def = symp;
579 defobj = obj;
580 }
581 }
582
583 /*
584 * Finally, look in the referencing object if not linked symbolically.
585 * This is necessary for DF_1_NODELETE objects where the containing DAG
586 * has been unlinked, so local references are resolved properly.
587 */
588 if ((def == NULL || ELF_ST_BIND(def->st_info) == STB_WEAK) &&
589 !refobj->symbolic && !_rtld_donelist_check(&donelist, refobj)) {
590 rdbg(("search referencing object for %s", name));
591 symp = _rtld_symlook_obj(name, hash, refobj, flags, ventry);
592 if (symp != NULL) {
593 def = symp;
594 defobj = refobj;
595 }
596 }
597
598 /*
599 * Search the dynamic linker itself, and possibly resolve the
600 * symbol from there. This is how the application links to
601 * dynamic linker services such as dlopen.
602 */
603 if (def == NULL || ELF_ST_BIND(def->st_info) == STB_WEAK) {
604 rdbg(("Search the dynamic linker itself."));
605 symp = _rtld_symlook_obj(name, hash, &_rtld_objself, flags,
606 ventry);
607 if (symp != NULL) {
608 def = symp;
609 defobj = &_rtld_objself;
610 }
611 }
612
613 if (def != NULL)
614 *defobj_out = defobj;
615 return def;
616 }
617