dlsym
来源:互联网 发布:linux调整home分区大小 编辑:程序博客网 时间:2024/06/06 08:52
dlopen()函数和dlsym()函数
1 dlopen()函数
用于打开一个.so库,原型如下:
void *dlopen(const char *filename, int flag)
{
soinfo *ret;
pthread_mutex_lock(&dl_lock);
ret = find_library(filename);
if (unlikely(ret == NULL)) {
set_dlerror(DL_ERR_CANNOT_LOAD_LIBRARY);
} else {
ret->refcount++;
}
pthread_mutex_unlock(&dl_lock);
return ret;
}
根据filename打开一个库,成功并返回一个句柄,出现错误返回为NULL。
其中的flag:
RTLD_LAZY 暂缓决定,等有需要时再解出符号 resolve undefined symbols as code from the dynamic library is executed
RTLD_NOW 立即决定,返回前解除所有未决定的符号。 resolve all undefined symbols before dlopen() returns and fail if this cannot be done
RTLD_LOCAL
RTLD_GLOBAL 允许导出符号
RTLD_GROUP
RTLD_WORLD
2 dlsym()函数
原型:
void *dlsym(void *handle, const char *symbol)
根据上面dlopen()函数放回的指针,获取函数(symbol)的地址,void*指向函数的地址,供接下来的调用。
用于打开一个.so库,原型如下:
void *dlopen(const char *filename, int flag)
{
soinfo *ret;
pthread_mutex_lock(&dl_lock);
ret = find_library(filename);
if (unlikely(ret == NULL)) {
set_dlerror(DL_ERR_CANNOT_LOAD_LIBRARY);
} else {
ret->refcount++;
}
pthread_mutex_unlock(&dl_lock);
return ret;
}
根据filename打开一个库,成功并返回一个句柄,出现错误返回为NULL。
其中的flag:
RTLD_LAZY 暂缓决定,等有需要时再解出符号 resolve undefined symbols as code from the dynamic library is executed
RTLD_NOW 立即决定,返回前解除所有未决定的符号。 resolve all undefined symbols before dlopen() returns and fail if this cannot be done
RTLD_LOCAL
RTLD_GLOBAL 允许导出符号
RTLD_GROUP
RTLD_WORLD
2 dlsym()函数
原型:
void *dlsym(void *handle, const char *symbol)
根据上面dlopen()函数放回的指针,获取函数(symbol)的地址,void*指向函数的地址,供接下来的调用。
- dlsym
- dlsym
- dlsym函数
- dlsym RTLD_DEFAULT
- dlsym函数
- dlopen dlsym dlclose解析
- dlopen, dlsym 的简介
- dlopen dlsym dlclose dlerror
- dlopen dlsym dlclose dlerror
- linux dlopen于dlsym
- dlopen和dlsym
- dlopen和dlsym
- dlopen和dlsym
- dlopen;dlclose;dlsym
- dlopen与dlsym用法
- HAL dlopen dlsym
- dlopen与dlsym
- dloepn dlsym使用
- c++支持课-----求根
- 关于VS中区分debug与release,32位与64位编译的宏定义
- maven将依赖包打进一个jar包
- 程序异常crash捕获与拦截
- 界面原型设计工具开源软件
- dlsym
- 数字证书中keytool命令使用说明
- 求图像镜像的函数
- PHP服务器变量$_SERVER介绍
- [Android] SurfaceView使用实例(正余弦移动)
- jquery添加DropDowmList change事件,添加样式
- Nginx 服务并发过10万的Linux内核优化配置
- 在Java中如何使用execute()、executeQuery()、executeUpdate()三个方法
- WTL或MFC中ListView属性设置