dlib.c 16 KB

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