转自:[https://www.cnblogs.com/yangyi54920/p/15179035.html](https://www.cnblogs.com/yangyi54920/p/15179035.html) linux平台上查问题时,定位到出错的函数地址,但无法知道是哪个模块的函数,记录如下函数可实现: ```c #include int getFuncAddrByName(char *funcName, unsigned int nameLen) { void *handle = NULL; void *iptr = NULL; /* open the needed object */ handle = dlopen(NULL, RTLD_LOCAL | RTLD_LAZY); if(handle == NULL) { return NULL; } /* find the address of function and data objects */ iptr = dlsym(handle, funcName); dlclose(handle); if(iptr == NULL) { return NULL; } return (int)iptr; } int getFuncNameByAddr (FUNCPTR funcAddr, char *funcName, unsigned int funcNameLen) { void *handle = NULL; Dl_info dl; int ret = 0; /* open the needed object */ handle = dlopen(NULL, RTLD_LOCAL | RTLD_LAZY); if(handle == NULL) { return -1; } /* find the address of function and data objects */ ret = dladdr (funcAddr, &dl); dlclose(handle); if(ret == 0) { return -1; } strncpy(funcName, dl.dli_sname, funcNameLen - 1); return 0; } ```