Mac上的RTLD_FIRST是否可以在Linux上执行RTLD_DEEP_BIND的工作? [英] Does RTLD_FIRST on mac do the job of RTLD_DEEP_BIND on linux?

查看:64
本文介绍了Mac上的RTLD_FIRST是否可以在Linux上执行RTLD_DEEP_BIND的工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Linux上的RTLD_DEEP_BIND的理解是,如果您的主程序中有一个函数A(),并且在动态链接库(称为lib)中有两个函数A()和B(),其中B定义为:

My understanding of RTLD_DEEP_BIND on linux is that if you have a function A() in your main program, and two functions A() and B() in a dynamically linked library (call it lib) where B is defined as:

B()
{
   A();
}

然后,对B()的调用将总是最终从库中调用A.这是RTLD_FIRST在Mac上执行的工作吗?抱歉-我对文档感到困惑.

Then a call to B() would ALWAYS end up calling A from the library. Is this the job that RTLD_FIRST does on a mac? Sorry - I am confused by the docs.

推荐答案

RTLD_DEEPBIND 似乎是OS X上的默认设置.默认.(您可以在链接时或加载时强制使用平面名称空间.)对于两级名称空间,符号引用不仅记录符号名称,还记录链接时解析符号所用的库.然后,在加载时,仅针对相同的库解析符号.

What RTLD_DEEPBIND seems to do is the default on OS X. OS X uses something called two-level namespace for dynamic libraries, by default. (You can force the use of flat namespaces either at link time or load time.) With two-level namespace, symbol references record not only the symbol name but the library with which the symbol was resolved at link time. Then, at load time, the symbol is only resolved against that same library.

这篇关于Mac上的RTLD_FIRST是否可以在Linux上执行RTLD_DEEP_BIND的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆