dlib.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. /*
  2. * libdl.c
  3. *
  4. * Functions required for dlopen et. al.
  5. */
  6. #include <stdlib.h>
  7. #include <features.h>
  8. #include "dlfcn.h"
  9. #include "linuxelf.h"
  10. #include "ld_syscall.h"
  11. #include "ld_hash.h"
  12. #include "ld_string.h"
  13. extern int _dl_error_number;
  14. extern struct r_debug *_dl_debug_addr;
  15. extern void *(*_dl_malloc_function) (size_t size);
  16. static int do_fixup(struct elf_resolve *tpnt, int flag);
  17. static int do_dlclose(void *, int need_fini);
  18. void *dlopen(const char *, int) __attribute__ ((__weak__, __alias__ ("_dlopen")));
  19. const char *dlerror(void) __attribute__ ((__weak__, __alias__ ("_dlerror")));
  20. void *dlsym(void *, const char *) __attribute__ ((__weak__, __alias__ ("_dlsym")));
  21. int dlclose(void *) __attribute__ ((__weak__, __alias__ ("_dlclose")));
  22. int dladdr(void *, Dl_info *) __attribute__ ((__weak__, __alias__ ("_dladdr")));
  23. /* This is a real hack. We need access to the dynamic linker, but we
  24. also need to make it possible to link against this library without any
  25. unresolved externals. We provide these weak symbols to make the link
  26. possible, but at run time the normal symbols are accessed. */
  27. static void __attribute__ ((unused)) foobar(void)
  28. {
  29. const char msg[]="libdl library not correctly linked\n";
  30. _dl_write(2, msg, _dl_strlen(msg));
  31. _dl_exit(1);
  32. }
  33. static int __attribute__ ((unused)) foobar1 = (int) foobar; /* Use as pointer */
  34. extern void _dl_dprintf(int, const char *, ...) __attribute__ ((__weak__, __alias__ ("foobar")));
  35. extern char *_dl_find_hash(const char *, struct dyn_elf *, struct elf_resolve *, enum caller_type)
  36. __attribute__ ((__weak__, __alias__ ("foobar")));
  37. extern struct elf_resolve * _dl_load_shared_library(int, struct dyn_elf **, struct elf_resolve *, char *)
  38. __attribute__ ((__weak__, __alias__ ("foobar")));
  39. extern int _dl_parse_relocation_information(struct elf_resolve *, unsigned long, unsigned long, int)
  40. __attribute__ ((__weak__, __alias__ ("foobar")));
  41. extern void _dl_parse_lazy_relocation_information(struct elf_resolve *, unsigned long, unsigned long, int)
  42. __attribute__ ((__weak__, __alias__ ("foobar")));
  43. #ifdef __mips__
  44. extern void _dl_perform_mips_global_got_relocations(struct elf_resolve *tpnt)
  45. __attribute__ ((__weak__, __alias__ ("foobar")));
  46. #endif
  47. #ifdef USE_CACHE
  48. int _dl_map_cache(void) __attribute__ ((__weak__, __alias__ ("foobar")));
  49. int _dl_unmap_cache(void) __attribute__ ((__weak__, __alias__ ("foobar")));
  50. #endif
  51. extern struct dyn_elf *_dl_symbol_tables __attribute__ ((__weak__, __alias__ ("foobar1")));
  52. extern struct dyn_elf *_dl_handles __attribute__ ((__weak__, __alias__ ("foobar1")));
  53. extern struct elf_resolve *_dl_loaded_modules __attribute__ ((__weak__, __alias__ ("foobar1")));
  54. extern struct r_debug *_dl_debug_addr __attribute__ ((__weak__, __alias__ ("foobar1")));
  55. extern int _dl_error_number __attribute__ ((__weak__, __alias__ ("foobar1")));
  56. extern void *(*_dl_malloc_function)(size_t) __attribute__ ((__weak__, __alias__ ("foobar1")));
  57. static const char *dl_error_names[] = {
  58. "",
  59. "File not found",
  60. "Unable to open /dev/zero",
  61. "Not an ELF file",
  62. #if defined (__i386__)
  63. "Not i386 binary",
  64. #elif defined (__sparc__)
  65. "Not sparc binary",
  66. #elif defined (__mc68000__)
  67. "Not m68k binary",
  68. #else
  69. "Unrecognized binary type",
  70. #endif
  71. "Not an ELF shared library",
  72. "Unable to mmap file",
  73. "No dynamic section",
  74. #ifdef ELF_USES_RELOCA
  75. "Unable to process REL relocs",
  76. #else
  77. "Unable to process RELA relocs",
  78. #endif
  79. "Bad handle",
  80. "Unable to resolve symbol"
  81. };
  82. static void __attribute__ ((destructor)) dl_cleanup(void)
  83. {
  84. struct dyn_elf *d;
  85. for (d = _dl_handles; d; d = d->next_handle)
  86. if (d->dyn->libtype == loaded_file && d->dyn->dynamic_info[DT_FINI]) {
  87. (* ((int (*)(void)) (d->dyn->loadaddr + d->dyn->dynamic_info[DT_FINI]))) ();
  88. d->dyn->dynamic_info[DT_FINI] = 0;
  89. }
  90. }
  91. void *_dlopen(const char *libname, int flag)
  92. {
  93. struct elf_resolve *tpnt, *tfrom;
  94. struct dyn_elf *rpnt = NULL;
  95. struct dyn_elf *dyn_chain;
  96. struct dyn_elf *dpnt;
  97. static int dl_init = 0;
  98. char *from;
  99. void (*dl_brk) (void);
  100. int (*dl_elf_init) (void);
  101. from = __builtin_return_address(0);
  102. /* Have the dynamic linker use the regular malloc function now */
  103. if (!dl_init) {
  104. dl_init++;
  105. _dl_malloc_function = malloc;
  106. }
  107. /* Cover the trivial case first */
  108. if (!libname)
  109. return _dl_symbol_tables;
  110. #ifdef USE_CACHE
  111. _dl_map_cache();
  112. #endif
  113. /*
  114. * Try and locate the module we were called from - we
  115. * need this so that we get the correct RPATH. Note that
  116. * this is the current behavior under Solaris, but the
  117. * ABI+ specifies that we should only use the RPATH from
  118. * the application. Thus this may go away at some time
  119. * in the future.
  120. */
  121. tfrom = NULL;
  122. for (dpnt = _dl_symbol_tables; dpnt; dpnt = dpnt->next) {
  123. tpnt = dpnt->dyn;
  124. if (tpnt->loadaddr < from
  125. && (tfrom == NULL || tfrom->loadaddr < tpnt->loadaddr))
  126. tfrom = tpnt;
  127. }
  128. if (!(tpnt = _dl_load_shared_library(0, &rpnt, tfrom, (char*)libname))) {
  129. #ifdef USE_CACHE
  130. _dl_unmap_cache();
  131. #endif
  132. return NULL;
  133. }
  134. dyn_chain = rpnt = (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
  135. _dl_memset(rpnt, 0, sizeof(*rpnt));
  136. rpnt->dyn = tpnt;
  137. rpnt->flags = flag;
  138. if (!tpnt->symbol_scope)
  139. tpnt->symbol_scope = dyn_chain;
  140. rpnt->next_handle = _dl_handles;
  141. _dl_handles = rpnt;
  142. /*
  143. * OK, we have the requested file in memory. Now check for
  144. * any other requested files that may also be required.
  145. */
  146. {
  147. struct elf_resolve *tcurr;
  148. struct elf_resolve * tpnt1;
  149. Elf32_Dyn * dpnt;
  150. char * lpnt;
  151. tcurr = tpnt;
  152. do{
  153. for(dpnt = (Elf32_Dyn *) tcurr->dynamic_addr; dpnt->d_tag; dpnt++)
  154. {
  155. if(dpnt->d_tag == DT_NEEDED)
  156. {
  157. lpnt = tcurr->loadaddr + tcurr->dynamic_info[DT_STRTAB] +
  158. dpnt->d_un.d_val;
  159. if(!(tpnt1 = _dl_load_shared_library(0, &rpnt, tcurr, lpnt)))
  160. goto oops;
  161. rpnt->next = (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
  162. _dl_memset (rpnt->next, 0, sizeof (*(rpnt->next)));
  163. rpnt = rpnt->next;
  164. if (!tpnt1->symbol_scope) tpnt1->symbol_scope = dyn_chain;
  165. rpnt->dyn = tpnt1;
  166. };
  167. }
  168. tcurr = tcurr->next;
  169. } while(tcurr);
  170. }
  171. /*
  172. * OK, now attach the entire chain at the end
  173. */
  174. rpnt->next = _dl_symbol_tables;
  175. /*
  176. * MIPS is special *sigh*
  177. */
  178. #ifdef __mips__
  179. _dl_perform_mips_global_got_relocations(tpnt);
  180. #endif
  181. if (do_fixup(tpnt, flag)) {
  182. _dl_error_number = LD_NO_SYMBOL;
  183. goto oops;
  184. }
  185. dl_brk = (void (*)(void)) _dl_debug_addr->r_brk;
  186. if (dl_brk != NULL) {
  187. _dl_debug_addr->r_state = RT_ADD;
  188. (*dl_brk) ();
  189. _dl_debug_addr->r_state = RT_CONSISTENT;
  190. (*dl_brk) ();
  191. }
  192. for (rpnt = dyn_chain; rpnt; rpnt = rpnt->next) {
  193. tpnt = rpnt->dyn;
  194. /* Apparently crt1 for the application is responsible for handling this.
  195. * We only need to run the init/fini for shared libraries
  196. */
  197. if (tpnt->libtype == program_interpreter)
  198. continue;
  199. if (tpnt->libtype == elf_executable)
  200. continue;
  201. if (tpnt->init_flag & INIT_FUNCS_CALLED)
  202. continue;
  203. tpnt->init_flag |= INIT_FUNCS_CALLED;
  204. if (tpnt->dynamic_info[DT_INIT]) {
  205. dl_elf_init = (int (*)(void)) (tpnt->loadaddr + tpnt->dynamic_info[DT_INIT]);
  206. (*dl_elf_init) ();
  207. }
  208. if (tpnt->dynamic_info[DT_FINI]) {
  209. atexit((void (*)(void)) (tpnt->loadaddr + tpnt->dynamic_info[DT_FINI]));
  210. }
  211. }
  212. #ifdef USE_CACHE
  213. _dl_unmap_cache();
  214. #endif
  215. return (void *) dyn_chain;
  216. oops:
  217. /* Something went wrong. Clean up and return NULL. */
  218. #ifdef USE_CACHE
  219. _dl_unmap_cache();
  220. #endif
  221. do_dlclose(dyn_chain, 0);
  222. return NULL;
  223. }
  224. static int do_fixup(struct elf_resolve *tpnt, int flag)
  225. {
  226. int goof = 0;
  227. if (tpnt->next)
  228. goof += do_fixup(tpnt->next, flag);
  229. if (tpnt->dynamic_info[DT_REL]) {
  230. #ifdef ELF_USES_RELOCA
  231. goof++;
  232. #else
  233. if (tpnt->init_flag & RELOCS_DONE)
  234. return goof;
  235. tpnt->init_flag |= RELOCS_DONE;
  236. goof += _dl_parse_relocation_information(tpnt,
  237. tpnt->dynamic_info[DT_REL], tpnt->dynamic_info[DT_RELSZ], 0);
  238. #endif
  239. }
  240. if (tpnt->dynamic_info[DT_RELA]) {
  241. #ifdef ELF_USES_RELOCA
  242. if (tpnt->init_flag & RELOCS_DONE)
  243. return goof;
  244. tpnt->init_flag |= RELOCS_DONE;
  245. goof += _dl_parse_relocation_information(tpnt,
  246. tpnt->dynamic_info[DT_RELA], tpnt->dynamic_info[DT_RELASZ], 0);
  247. #else
  248. goof++;
  249. #endif
  250. }
  251. if (tpnt->dynamic_info[DT_JMPREL]) {
  252. if (tpnt->init_flag & JMP_RELOCS_DONE)
  253. return goof;
  254. tpnt->init_flag |= JMP_RELOCS_DONE;
  255. if (flag == RTLD_LAZY)
  256. _dl_parse_lazy_relocation_information(tpnt,
  257. tpnt->dynamic_info[DT_JMPREL],
  258. tpnt->dynamic_info[DT_PLTRELSZ], 0);
  259. else
  260. goof += _dl_parse_relocation_information(tpnt,
  261. tpnt->dynamic_info[DT_JMPREL],
  262. tpnt->dynamic_info[DT_PLTRELSZ], 0);
  263. };
  264. return goof;
  265. }
  266. void *_dlsym(void *vhandle, const char *name)
  267. {
  268. struct elf_resolve *tpnt, *tfrom;
  269. struct dyn_elf *handle;
  270. char *from;
  271. struct dyn_elf *rpnt;
  272. void *ret;
  273. handle = (struct dyn_elf *) vhandle;
  274. /* First of all verify that we have a real handle
  275. of some kind. Return NULL if not a valid handle. */
  276. if (handle == NULL)
  277. handle = _dl_symbol_tables;
  278. else if (handle != RTLD_NEXT && handle != _dl_symbol_tables) {
  279. for (rpnt = _dl_handles; rpnt; rpnt = rpnt->next_handle)
  280. if (rpnt == handle)
  281. break;
  282. if (!rpnt) {
  283. _dl_error_number = LD_BAD_HANDLE;
  284. return NULL;
  285. }
  286. } else if (handle == RTLD_NEXT) {
  287. /*
  288. * Try and locate the module we were called from - we
  289. * need this so that we know where to start searching
  290. * from. We never pass RTLD_NEXT down into the actual
  291. * dynamic loader itself, as it doesn't know
  292. * how to properly treat it.
  293. */
  294. from = __builtin_return_address(0);
  295. tfrom = NULL;
  296. for (rpnt = _dl_symbol_tables; rpnt; rpnt = rpnt->next) {
  297. tpnt = rpnt->dyn;
  298. if (tpnt->loadaddr < from
  299. && (tfrom == NULL || tfrom->loadaddr < tpnt->loadaddr)) {
  300. tfrom = tpnt;
  301. handle = rpnt->next;
  302. }
  303. }
  304. }
  305. ret = _dl_find_hash((char*)name, handle, NULL, copyrel);
  306. /*
  307. * Nothing found.
  308. */
  309. if (!ret)
  310. _dl_error_number = LD_NO_SYMBOL;
  311. return ret;
  312. }
  313. int _dlclose(void *vhandle)
  314. {
  315. return do_dlclose(vhandle, 1);
  316. }
  317. static int do_dlclose(void *vhandle, int need_fini)
  318. {
  319. struct dyn_elf *rpnt, *rpnt1;
  320. struct dyn_elf *spnt, *spnt1;
  321. elf_phdr *ppnt;
  322. struct elf_resolve *tpnt;
  323. int (*dl_elf_fini) (void);
  324. void (*dl_brk) (void);
  325. struct dyn_elf *handle;
  326. unsigned int end;
  327. int i = 0;
  328. handle = (struct dyn_elf *) vhandle;
  329. rpnt1 = NULL;
  330. for (rpnt = _dl_handles; rpnt; rpnt = rpnt->next_handle) {
  331. if (rpnt == handle) {
  332. break;
  333. }
  334. rpnt1 = rpnt;
  335. }
  336. if (!rpnt) {
  337. _dl_error_number = LD_BAD_HANDLE;
  338. return 1;
  339. }
  340. /* OK, this is a valid handle - now close out the file.
  341. * We check if we need to call fini () on the handle. */
  342. spnt = need_fini ? handle : handle->next;
  343. for (; spnt; spnt = spnt1) {
  344. spnt1 = spnt->next;
  345. /* We appended the module list to the end - when we get back here,
  346. quit. The access counts were not adjusted to account for being here. */
  347. if (spnt == _dl_symbol_tables)
  348. break;
  349. if (spnt->dyn->usage_count == 1
  350. && spnt->dyn->libtype == loaded_file) {
  351. tpnt = spnt->dyn;
  352. /* Apparently crt1 for the application is responsible for handling this.
  353. * We only need to run the init/fini for shared libraries
  354. */
  355. if (tpnt->dynamic_info[DT_FINI]) {
  356. dl_elf_fini = (int (*)(void)) (tpnt->loadaddr +
  357. tpnt->dynamic_info[DT_FINI]);
  358. (*dl_elf_fini) ();
  359. }
  360. }
  361. }
  362. if (rpnt1)
  363. rpnt1->next_handle = rpnt->next_handle;
  364. else
  365. _dl_handles = rpnt->next_handle;
  366. /* OK, this is a valid handle - now close out the file */
  367. for (rpnt = handle; rpnt; rpnt = rpnt1) {
  368. rpnt1 = rpnt->next;
  369. /* We appended the module list to the end - when we get back here,
  370. quit. The access counts were not adjusted to account for being here. */
  371. if (rpnt == _dl_symbol_tables)
  372. break;
  373. rpnt->dyn->usage_count--;
  374. if (rpnt->dyn->usage_count == 0
  375. && rpnt->dyn->libtype == loaded_file) {
  376. tpnt = rpnt->dyn;
  377. /* Apparently crt1 for the application is responsible for handling this.
  378. * We only need to run the init/fini for shared libraries
  379. */
  380. #if 0
  381. /* We have to do this above, before we start closing objects.
  382. * Otherwise when the needed symbols for _fini handling are
  383. * resolved a coredump would occur. Rob Ryan (robr@cmu.edu)*/
  384. if (tpnt->dynamic_info[DT_FINI]) {
  385. dl_elf_fini = (int (*)(void)) (tpnt->loadaddr + tpnt->dynamic_info[DT_FINI]);
  386. (*dl_elf_fini) ();
  387. }
  388. #endif
  389. end = 0;
  390. for (i = 0, ppnt = rpnt->dyn->ppnt;
  391. i < rpnt->dyn->n_phent; ppnt++, i++) {
  392. if (ppnt->p_type != PT_LOAD)
  393. continue;
  394. if (end < ppnt->p_vaddr + ppnt->p_memsz)
  395. end = ppnt->p_vaddr + ppnt->p_memsz;
  396. }
  397. _dl_munmap(rpnt->dyn->loadaddr, end);
  398. /* Next, remove rpnt->dyn from the loaded_module list */
  399. if (_dl_loaded_modules == rpnt->dyn) {
  400. _dl_loaded_modules = rpnt->dyn->next;
  401. if (_dl_loaded_modules)
  402. _dl_loaded_modules->prev = 0;
  403. } else
  404. for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next)
  405. if (tpnt->next == rpnt->dyn) {
  406. tpnt->next = tpnt->next->next;
  407. if (tpnt->next)
  408. tpnt->next->prev = tpnt;
  409. break;
  410. }
  411. free(rpnt->dyn->libname);
  412. free(rpnt->dyn);
  413. }
  414. free(rpnt);
  415. }
  416. dl_brk = (void (*)(void)) _dl_debug_addr->r_brk;
  417. if (dl_brk != NULL) {
  418. _dl_debug_addr->r_state = RT_DELETE;
  419. (*dl_brk) ();
  420. _dl_debug_addr->r_state = RT_CONSISTENT;
  421. (*dl_brk) ();
  422. }
  423. return 0;
  424. }
  425. const char *_dlerror(void)
  426. {
  427. const char *retval;
  428. if (!_dl_error_number)
  429. return NULL;
  430. retval = dl_error_names[_dl_error_number];
  431. _dl_error_number = 0;
  432. return retval;
  433. }
  434. /*
  435. * Dump information to stderrr about the current loaded modules
  436. */
  437. static char *type[] = { "Lib", "Exe", "Int", "Mod" };
  438. void _dlinfo(void)
  439. {
  440. struct elf_resolve *tpnt;
  441. struct dyn_elf *rpnt, *hpnt;
  442. _dl_dprintf(2, "List of loaded modules\n");
  443. /* First start with a complete list of all of the loaded files. */
  444. for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) {
  445. _dl_dprintf(2, "\t%x %x %x %s %d %s\n",
  446. (unsigned) tpnt->loadaddr, (unsigned) tpnt,
  447. (unsigned) tpnt->symbol_scope,
  448. type[tpnt->libtype],
  449. tpnt->usage_count, tpnt->libname);
  450. }
  451. /* Next dump the module list for the application itself */
  452. _dl_dprintf(2, "\nModules for application (%x):\n",
  453. (unsigned) _dl_symbol_tables);
  454. for (rpnt = _dl_symbol_tables; rpnt; rpnt = rpnt->next)
  455. _dl_dprintf(2, "\t%x %s\n", (unsigned) rpnt->dyn, rpnt->dyn->libname);
  456. for (hpnt = _dl_handles; hpnt; hpnt = hpnt->next_handle) {
  457. _dl_dprintf(2, "Modules for handle %x\n", (unsigned) hpnt);
  458. for (rpnt = hpnt; rpnt; rpnt = rpnt->next)
  459. _dl_dprintf(2, "\t%x %s\n", (unsigned) rpnt->dyn,
  460. rpnt->dyn->libname);
  461. }
  462. }
  463. int _dladdr(void *__address, Dl_info * __dlip)
  464. {
  465. struct elf_resolve *pelf;
  466. struct elf_resolve *rpnt;
  467. #ifdef USE_CACHE
  468. _dl_map_cache();
  469. #endif
  470. /*
  471. * Try and locate the module address is in
  472. */
  473. pelf = NULL;
  474. #if 0
  475. _dl_dprintf(2, "dladdr( 0x%p, 0x%p )\n", __address, __dlip);
  476. #endif
  477. for (rpnt = _dl_loaded_modules; rpnt; rpnt = rpnt->next) {
  478. struct elf_resolve *tpnt;
  479. tpnt = rpnt;
  480. #if 0
  481. _dl_dprintf(2, "Module \"%s\" at 0x%p\n",
  482. tpnt->libname, tpnt->loadaddr);
  483. #endif
  484. if (tpnt->loadaddr < (char *) __address
  485. && (pelf == NULL || pelf->loadaddr < tpnt->loadaddr)) {
  486. pelf = tpnt;
  487. }
  488. }
  489. if (!pelf) {
  490. return 0;
  491. }
  492. /*
  493. * Try and locate the symbol of address
  494. */
  495. {
  496. char *strtab;
  497. Elf32_Sym *symtab;
  498. int hn, si;
  499. int sf;
  500. int sn = 0;
  501. void *sa = 0;
  502. symtab = (Elf32_Sym *) (pelf->dynamic_info[DT_SYMTAB] + pelf->loadaddr);
  503. strtab = (char *) (pelf->dynamic_info[DT_STRTAB] + pelf->loadaddr);
  504. sf = 0;
  505. for (hn = 0; hn < pelf->nbucket; hn++) {
  506. for (si = pelf->elf_buckets[hn]; si; si = pelf->chains[si]) {
  507. void *symbol_addr;
  508. symbol_addr = pelf->loadaddr + symtab[si].st_value;
  509. if (symbol_addr <= __address && (!sf || sa < symbol_addr)) {
  510. sa = symbol_addr;
  511. sn = si;
  512. sf = 1;
  513. }
  514. #if 0
  515. _dl_dprintf(2, "Symbol \"%s\" at 0x%p\n",
  516. strtab + symtab[si].st_name, symbol_addr);
  517. #endif
  518. }
  519. }
  520. if (sf) {
  521. __dlip->dli_fname = pelf->libname;
  522. __dlip->dli_fbase = pelf->loadaddr;
  523. __dlip->dli_sname = strtab + symtab[sn].st_name;
  524. __dlip->dli_saddr = sa;
  525. }
  526. return 1;
  527. }
  528. }