今天看alsa-lib的代码,发现一个场景是会调到

dlsym(RTLD_DEFAULT, name);

也就是说,handle=RTLD_DEFAULT,在网上查了下,这种情况下会发生的事情是,会在当前进程中按照 default library search order搜索name这个symbol,网上的介绍摘录如下:

http://www.qnx.de/developers/docs/6.4.0/neutrino/lib_ref/d/dlsym.html?lang=cn

If handle is a handle returned by dlopen(), you must not have closed that shared object by calling dlclose(). The dlsym() functions also searches for the named symbol in the objects loaded as part of the dependencies for that object.

If handle is RTLD_DEFAULT, dlsym() searches all objects in the current process, in load-order.

In the case of RTLD_DEFAULT, if the objects being searched were loaded with dlopen(), dlsym() searches the object only if the caller is part of the same dependency hierarchy, or if the object was loaded with global search access (using the RTLD_GLOBAL mode).

http://www.linux.com/learn/docs/man/2818-dlsym3

dlsym()

The function dlsym() takes a "handle" of a dynamic library returned by dlopen() and the null-terminated symbol name, returning the address where that symbol is loaded into memory. If the symbol is not found, in the specified library or any of the libraries that were automatically loaded by dlopen() when that library was loaded, dlsym() returns NULL. (The search performed by dlsym() is breadth first through the dependency tree of these libraries.) Since the value of the symbol could actually be NULL (so that a NULL return from dlsym() need not indicate an error), the correct way to test for an error is to call dlerror() to clear any old error conditions, then call dlsym(), and then call dlerror() again, saving its return value into a variable, and check whether this saved value is not NULL.

There are two special pseudo-handles, RTLD_DEFAULT and RTLD_NEXT. The former will find the first occurrence of the desired symbol using the default library search order. The latter will find the next occurrence of a function in the search order after the current library. This allows one to provide a wrapper around a function in another shared library.

dlsym RTLD_DEFAULT相关推荐

  1. dlsym RTLD_DEFAULT和RTLD_NEXT

    https://blog.csdn.net/ustcxiangchun/article/details/6310085 https://linux.die.net/man/3/dlsym http:/ ...

  2. 动态库加载函数dlsym 在C/C++编程中的使用

    dlsym函数的功能就是可以从共享库(动态库)中获取符号(全局变量与函数符号)地址,通常用于获取函数符号地址,这样可用于对共享库中函数的包装:下面是函数原型及需要包含的头文件. #include &l ...

  3. Mac下使用ABTestingGateway快速搭建灰度网关

    Mac下使用ABTestingGateway快速搭建灰度网关 ABTestingGateway简介 ABTestingGateway 是新浪开源的一个可以动态设置分流策略的灰度发布系统,工作在7层,基 ...

  4. 蓝牙地址的name为null_蓝牙, enable协议栈流程

    文章开始之前,先看两张图 原谅我这个不擅长美工没有艺术细菌的程序媛,图画的很简陋,但也算是勾勒出了大致的流程如果你对这两张图感兴趣,那么欢迎继续阅读本文,也期待多多提出意见如果无感,甚至感觉目前根本没 ...

  5. JVM CPU Profiler技术原理及源码深度解析

    本文介绍了JVM平台上CPU Profiler的实现原理,希望能帮助读者在使用类似工具的同时也能清楚其内部的技术实现. 引言 研发人员在遇到线上报警或需要优化系统性能时,常常需要分析程序运行行为和性能 ...

  6. Xposed是如何为所欲为的?

    本文通过分析 Xposed 的实现原理,对于 Java 方法的 Hook 原理有了一些了解,同时回顾了 Android zygote 进程相关的内容,对于 ART 虚拟机执行方法的过程也有了一个大概的 ...

  7. 使用LeakTracer检测android NDK C/C++代码中的memory leak

    Memory issue是C/C++开发中比较常遇到,经常带给人比较大困扰,debug起来又常常让人无从下手的一类问题,memory issue主要又分为memory leak,野指针,及其它非法访问 ...

  8. 从java的NIO版hello world看java源码,我们能看到什么?

    Java NIO服务端代码的hello world怎么写? public class NBTimeServer {public static void main(String[] args) {try ...

  9. 某些error page不加载_细说So动态库的加载流程

    本文为看雪论坛优秀文章 看雪论坛作者ID:sossai dlopen之内存装载dlopen用来打开一个动态链接库,并将其装入内存.它的定义在Android源码中的路径为/bionic/linker/d ...

最新文章

  1. 细谈Ehcache页面缓存的使用
  2. 你对JVM三色标记的理解嘛?
  3. h5的横线_CSS文字两边添加横线的几种方法
  4. es6 --- forEach的实现
  5. Spring注解——使用@ComponentScan自动扫描组件
  6. [CB]加快BCB编译速度
  7. JEECG - 基于代码生成器的J2EE智能开发框架 续六: JEECG 前台页面和后台交互讲解
  8. HTML_DOM简介
  9. Java案例:集合的Stream方法
  10. MarkdownPad2
  11. [渝粤教育] 西安工业大学 数字电子技术基础 参考 资料
  12. display:inline-block的应用及bug
  13. 表单提交中文时出现乱码的问题
  14. R语言常见报错及解决方法
  15. 用前端代码智能识别身份证的头像
  16. 微信公众号支付、支付查询、退款、退款查询、转账到零钱银行卡、转账查询接口整合(V2)
  17. web应用开发入门_Web应用程序监视入门
  18. Unity2D学习笔记Day12:敌人统一死亡动画+Class的继承(含虚函数virtual,重写override)
  19. 同步系统时间与硬件时钟
  20. 在SpringMVC项目中使用HIkariCP

热门文章

  1. layui制作二维码
  2. linux mailxdingding机器人报警
  3. Arduino实验二十九 PCF8591数模转换传感器实验
  4. selinux造成虚拟目录文件无法访问
  5. Knockout.js的简单使用
  6. Linux设置环境变量
  7. H5C3进阶——播放器
  8. 12.1 Prim算法
  9. python填充图像为方形
  10. zigbee以太网网关方案