参考链接:https://www.cnblogs.com/eniac1946/p/7462082.html
直接上代码:
static void *findSymbol(const char *path, const char *symbol) { void *handle = dlopen(path, RTLD_LAZY); if (!handle) { LOGE("handle %s is NULL", path); return NULL; } void *target = dlsym(handle, symbol); if (!target) { LOGE("symbol %s is NULL", symbol); } return target; } void *target = findSymbol("libc.so", "__system_property_get");
dlopen打开失败,可以用dlerror()查看错误,看代码:
void *dlh; dlh = dlopen("libdes3-32.so", RTLD_NOW | RTLD_GLOBAL); if (dlh == NULL) { printf("dlopen err:%s.\n", dlerror()); }