<br><br><div class="gmail_quote">On Sat, Jun 11, 2011 at 1:34 PM, Ludo Brands <span dir="ltr"><<a href="mailto:ludo.brands@free.fr">ludo.brands@free.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

The solution you propose to avoid the effect of loading dynamically a<br>
library which has already been marked for loading by the linker seems quite<br>
dangerous. Suppose the unit that caused the linker to include the library<br>
(call it lib1) executes some initialization routines. These will run in<br>
lib1. Now you load dynamically the same lib (lib2). From now on all calls to<br>
the library functions are executed in lib2.<br></blockquote></div><br><br>Hmm. CMIIW, but let's look at an example. I took a  quote from sqlite3.inc and from my own module<br><br>==== this one is from sqlite3.inc (lightly modified)<br>

function sqlite3_open(filename: pchar;ppDb: ppsqlite3): cint; cdecl;external Sqlite3Lib;<br><br>==== this one from my module<br>  Procs.DLLHandle := dlopen(PAnsiChar('mysqlite3.so'), RTLD_NOW  OR RTLD_DEEPBIND); <br>

 @Procs.SQLite3_Open := dlsym(Procs.DLLHandle, 'sqlite3_open');<br><br>I suppose that if I don't use RTLD_DEEPBIND, both (sqlite3_open and Procs.SQLite3_Open) will point to the same address (what is not so bad), but what worse they both internally will use the same global writable data (what is actually bad). But with RTLD_DEEPBIND both (sqlite3_open and Procs.SQLite3_Open) will get different addresses (maybe not, but it's safe for code or read-only data), but they will definitely get different copies of the global writable data they need. So any current module that uses sqlite3 will use the unchanged, safe context, no matter what I loaded on the second, third or whatever step as long as I use RTLD_DEEPBIND for them. <br>

<br>So what did you mean by saying 'dangerous'?<br><br>Max<br>