ACP_EXPORT acp_rc_t acpSymFind(acp_sym_table_t *aSymTable, acp_sym_info_t *aSymInfo, void *aAddr) { Dl_info sDlInfo; ACP_UNUSED(aSymTable); if (_rld_new_interface(_RLD_DLADDR, aAddr, &sDlInfo)) { acpStrSetConstCString(&aSymInfo->mFileName, sDlInfo.dli_fname); acpStrSetConstCString(&aSymInfo->mFuncName, sDlInfo.dli_sname); aSymInfo->mFileAddr = sDlInfo.dli_fbase; aSymInfo->mFuncAddr = sDlInfo.dli_saddr; return ACP_RC_SUCCESS; } else { acpStrSetConstCString(&aSymInfo->mFileName, NULL); acpStrSetConstCString(&aSymInfo->mFuncName, NULL); aSymInfo->mFileAddr = NULL; aSymInfo->mFuncAddr = NULL; return ACP_RC_ENOENT; } }
static int dladdr(void *address, Dl_info *dl) { return 0; #if 0 void *v; v = _rld_new_interface(_RLD_DLADDR, address, dl); return (int)v; #endif }
int dladdr(void *address, Dl_info *dl) { void *v = _rld_new_interface(_RLD_DLADDR,address,dl); return (int)v; }
void *_dll_next(int flags, _DLL_RLD_SYM_TYPE *here) { char *vp; void *lp; int found = 0; char *s; char *b; char *e; char dummy[256]; #if DEBUG Write_f wr = 0; Write_f xr; char buf[1024]; #endif #if DEBUG if (getenv("DLL_DEBUG") && (vp = (char *)_rld_new_interface(_RLD_FIRST_PATHNAME))) { do { if (strcmp(vp, "MAIN") && (lp = dllopen(vp, flags))) { xr = (Write_f)dlsym(lp, "write") if (xr) wr = xr; } } while (vp = (char *)_rld_new_interface(_RLD_NEXT_PATHNAME)); } #endif vp = (char *)_rld_new_interface(_RLD_FIRST_PATHNAME); if (vp) { do { lp = dllopen(strcmp(vp, "MAIN") ? vp : NULL, flags); if (lp) { if (found) { b = e = 0; s = vp; for (;;) { switch (*s++) { case 0: break; case '/': b = s; e = 0; continue; case '.': if (!e) e = s - 1; continue; default: continue; } break; } if (b && e) { s = dummy; *s++ = '_'; *s++ = '_'; while (b < e) *s++ = *b++; b = "_dummy"; while (*s++ = *b++) ; if (dlsym(lp, dummy)) { dlclose(lp); lp = 0; } } if (lp) { #if DEBUG if (wr) (*wr)(2, buf, sfsprintf(buf, sizeof(buf), "dll: next %s\n", vp)); #endif return lp; } #if DEBUG else if (wr) { (*wr)(2, buf, sfsprintf(buf, sizeof(buf), "dll: skip %s\n", vp)); } #endif } else if ((_DLL_RLD_SYM_TYPE *)dlsym(lp, _DLL_RLD_SYM_STR) == here) { #if DEBUG if (wr) (*wr)(2, buf, sfsprintf(buf, sizeof(buf), "dll: this %s\n", vp)); #endif found = 1; } } } while (vp = (char *)_rld_new_interface(_RLD_NEXT_PATHNAME)); } return dllnext(flags); }