libdl.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. /*
  2. * libdl.c
  3. *
  4. * Functions required for dlopen et. al.
  5. */
  6. #include <stdlib.h>
  7. #include "dlfcn.h"
  8. #include "sysdep.h"
  9. #include "syscall.h"
  10. #include "hash.h"
  11. #include "string.h"
  12. #include "linuxelf.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 1
  394. #pragma weak dlopen = _dlopen
  395. #pragma weak dlerror = _dlerror
  396. #pragma weak dlclose = _dlclose
  397. #pragma weak dlsym = _dlsym
  398. #pragma weak dladdr = _dladdr
  399. #else
  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. #endif
  406. /* This is a real hack. We need access to the dynamic linker, but we
  407. also need to make it possible to link against this library without any
  408. unresolved externals. We provide these weak symbols to make the link
  409. possible, but at run time the normal symbols are accessed. */
  410. static void foobar()
  411. {
  412. _dl_fdprintf(2, "libdl library not correctly linked\n");
  413. _dl_exit(1);
  414. }
  415. static int __attribute__ ((unused)) foobar1 = (int) foobar; /* Use as pointer */
  416. #if 1
  417. #pragma weak _dl_find_hash = foobar
  418. #pragma weak _dl_symbol_tables = foobar1
  419. #pragma weak _dl_handles = foobar1
  420. #pragma weak _dl_loaded_modules = foobar1
  421. #pragma weak _dl_debug_addr = foobar1
  422. #pragma weak _dl_error_number = foobar1
  423. #pragma weak _dl_load_shared_library = foobar
  424. #ifdef USE_CACHE
  425. #pragma weak _dl_map_cache = foobar
  426. #pragma weak _dl_unmap_cache = foobar
  427. #endif
  428. #pragma weak _dl_malloc_function = foobar1
  429. #pragma weak _dl_parse_relocation_information = foobar
  430. #pragma weak _dl_parse_lazy_relocation_information = foobar
  431. #pragma weak _dl_fdprintf = foobar
  432. #else
  433. __asm__(".weak _dl_find_hash; _dl_find_hash = foobar");
  434. __asm__(".weak _dl_symbol_tables; _dl_symbol_tables = foobar1");
  435. __asm__(".weak _dl_handles; _dl_handles = foobar1");
  436. __asm__(".weak _dl_loaded_modules; _dl_loaded_modules = foobar1");
  437. __asm__(".weak _dl_debug_addr; _dl_debug_addr = foobar1");
  438. __asm__(".weak _dl_error_number; _dl_error_number = foobar1");
  439. __asm__(".weak _dl_load_shared_library; _dl_load_shared_library = foobar");
  440. #ifdef USE_CACHE
  441. __asm__(".weak _dl_map_cache; _dl_map_cache = foobar");
  442. __asm__(".weak _dl_unmap_cache; _dl_unmap_cache = foobar");
  443. #endif
  444. __asm__(".weak _dl_malloc_function; _dl_malloc_function = foobar1");
  445. __asm__
  446. (".weak _dl_parse_relocation_information; _dl_parse_relocation_information = foobar");
  447. __asm__
  448. (".weak _dl_parse_lazy_relocation_information; _dl_parse_lazy_relocation_information = foobar");
  449. __asm__(".weak _dl_fdprintf; _dl_fdprintf = foobar");
  450. #endif
  451. /*
  452. * Dump information to stderrr about the current loaded modules
  453. */
  454. static char *type[] = { "Lib", "Exe", "Int", "Mod" };
  455. void _dlinfo()
  456. {
  457. struct elf_resolve *tpnt;
  458. struct dyn_elf *rpnt, *hpnt;
  459. _dl_fdprintf(2, "List of loaded modules\n");
  460. /* First start with a complete list of all of the loaded files. */
  461. for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) {
  462. _dl_fdprintf(2, "\t%8.8x %8.8x %8.8x %s %d %s\n",
  463. (unsigned) tpnt->loadaddr, (unsigned) tpnt,
  464. (unsigned) tpnt->symbol_scope,
  465. type[tpnt->libtype],
  466. tpnt->usage_count, tpnt->libname);
  467. }
  468. /* Next dump the module list for the application itself */
  469. _dl_fdprintf(2, "\nModules for application (%x):\n",
  470. (unsigned) _dl_symbol_tables);
  471. for (rpnt = _dl_symbol_tables; rpnt; rpnt = rpnt->next)
  472. _dl_fdprintf(2, "\t%8.8x %s\n", (unsigned) rpnt->dyn, rpnt->dyn->libname);
  473. for (hpnt = _dl_handles; hpnt; hpnt = hpnt->next_handle) {
  474. _dl_fdprintf(2, "Modules for handle %x\n", (unsigned) hpnt);
  475. for (rpnt = hpnt; rpnt; rpnt = rpnt->next)
  476. _dl_fdprintf(2, "\t%8.8x %s\n", (unsigned) rpnt->dyn,
  477. rpnt->dyn->libname);
  478. }
  479. }
  480. int _dladdr(void *__address, Dl_info * __dlip)
  481. {
  482. struct elf_resolve *pelf;
  483. struct elf_resolve *rpnt;
  484. #ifdef USE_CACHE
  485. _dl_map_cache();
  486. #endif
  487. /*
  488. * Try and locate the module address is in
  489. */
  490. pelf = NULL;
  491. #if 0
  492. _dl_fdprintf(2, "dladdr( 0x%p, 0x%p )\n", __address, __dlip);
  493. #endif
  494. for (rpnt = _dl_loaded_modules; rpnt; rpnt = rpnt->next) {
  495. struct elf_resolve *tpnt;
  496. tpnt = rpnt;
  497. #if 0
  498. _dl_fdprintf(2, "Module \"%s\" at 0x%p\n",
  499. tpnt->libname, tpnt->loadaddr);
  500. #endif
  501. if (tpnt->loadaddr < (char *) __address
  502. && (pelf == NULL || pelf->loadaddr < tpnt->loadaddr)) {
  503. pelf = tpnt;
  504. }
  505. }
  506. if (!pelf) {
  507. return 0;
  508. }
  509. /*
  510. * Try and locate the symbol of address
  511. */
  512. {
  513. char *strtab;
  514. Elf32_Sym *symtab;
  515. int hn, si;
  516. int sf;
  517. int sn = 0;
  518. void *sa = 0;
  519. symtab = (Elf32_Sym *) (pelf->dynamic_info[DT_SYMTAB] + pelf->loadaddr);
  520. strtab = (char *) (pelf->dynamic_info[DT_STRTAB] + pelf->loadaddr);
  521. sf = 0;
  522. for (hn = 0; hn < pelf->nbucket; hn++) {
  523. for (si = pelf->elf_buckets[hn]; si; si = pelf->chains[si]) {
  524. void *symbol_addr;
  525. symbol_addr = pelf->loadaddr + symtab[si].st_value;
  526. if (symbol_addr <= __address && (!sf || sa < symbol_addr)) {
  527. sa = symbol_addr;
  528. sn = si;
  529. sf = 1;
  530. }
  531. #if 0
  532. _dl_fdprintf(2, "Symbol \"%s\" at 0x%p\n",
  533. strtab + symtab[si].st_name, symbol_addr);
  534. #endif
  535. }
  536. }
  537. if (sf) {
  538. __dlip->dli_fname = pelf->libname;
  539. __dlip->dli_fbase = pelf->loadaddr;
  540. __dlip->dli_sname = strtab + symtab[sn].st_name;
  541. __dlip->dli_saddr = sa;
  542. }
  543. return 1;
  544. }
  545. }