Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

macos

dlopen

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.

like image 674
V.S. Avatar asked Oct 28 '25 05:10

V.S.


2 Answers

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.

like image 193
R.. GitHub STOP HELPING ICE Avatar answered Oct 31 '25 00:10

R.. GitHub STOP HELPING ICE


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.

like image 43
Ken Thomases Avatar answered Oct 31 '25 02:10

Ken Thomases



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!