开发者

Does RTLD_FIRST on mac do the job of RTLD_DEEP_BIND on linux?

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();
}

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.


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.


No. RTLD_FIRST is simply a flag that affects how dlsym behaves when called with the resulting handle, while RTLD_DEEPBIND affects how symbols are resolved when loading the library. They're both rather poorly documented, but that's the information I found base on the man pages for OSX and Linux.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜