On Wed, 7 Jun 2006, Igor Tandetnik wrote:

Dennis Jenkins
<[EMAIL PROTECTED]> wrote:
[EMAIL PROTECTED] wrote:
"Igor Tandetnik" <[EMAIL PROTECTED]> wrote:
On Windows, the loader works in a very different way. Basically,
export/import connections are established at link time, not at load
time. The loader does not perform a symbol search over all the
DLLs, the import tables in the executable image (emitted by the
linker) tell it exactly where to look.

That explanation does not seem entirely accurate (especially the
second sentence).  If that were true, it owuld not be possible to
release an updated DLL with re-arranged entry points and expect the
caller EXE or DLL to link to it properly; yet that works.

"Exactly where to look" was perhaps too strong a stateent. What I mean is the import table lists the name (just the file name, without path) of the DLL and the name (or ordinal number) of the exported function. The loader still needs to search the path for the DLL file, and search the DLL's export table for the symbol name. What it does not have to do is search all the DLLs in the system and all the symbols in them to resolve dependencies, as it appears to be the case under Unix-like scheme.

I don't really know how Unix loader works sufficiently well to engage in intelligent discussion.


Under Unix, run time linking is basically exactly that, a run time link. The exe is loaded, and unresolved symbols are searched for in the required libraries. The list of required libraries is maintained in the exe, so the linker doesn't have to search all the system libraries. Shared libraries may also depend on further shared libraries, symbols being resolved on the way, until no more symbols are left (or no more libraries are left or cannot be found, when an unresolved symbol error is thrown.)

The main difference appears that Unix just says "Symbol foo is unresolved, look in libx, liby and libz" whereas Windows says "Symbol foo from liby is unresolved." The Unix way is more flexible in that things like LD_PRELOAD can override symbols from libraries. Very useful.



Igor Tandetnik

Christian

Reply via email to