Re: DLL and external references by Victor
Victor
Thu Jul 15 17:12:43 CDT 2004
Carl Daniel [VC++ MVP] wrote:
> Victor Bazarov wrote:
>
>>alias.name wrote:
>>
>>>Thank you, I was trying mimic the shared library behavior from Unix,
>>>but since DLL are essentially EXE's and not just shared objects
>>>since it won't work for my purpose.
>>
>>I am not sure I understand that statement about shared objects. In
>>order to use shared objects on Unix, you still need to link them in.
>>Each .so object serves as its own import library. On Windows a DLL
>>is not its own .LIB, that information is pulled into a different
>>file, that's all.
>>
>>So, mimicking Unix behaviour is what Windows does with DLLs.
>
>
> Not quite. An .so can have unsatisfied externals while a DLL cannot. The
> dynamic linker will attempt to resolve those externals when the .so is
> loaded using symbols available in all the other modules loaded into the
> image.
>
> The key difference is that windows doesn't have a dynamic linker - only a
> dynamic loader that does little more than update a fixed table of
> entry-point addresses when a module (DLL) is loaded.
OK, let me understand something... If I remove a .so file from my
disk and try to run an application that needs it, the dynamic linker
won't be able to resolve some references, right? If I remove a DLL
from my disk and try to run the EXE that needs it, the dynamic loader
won't be able to locate the DLL, right? So, that's one difference.
Or is it?
If I replace a .so file with a different one that has a symbol with
the same name, but different content, I can be screwed because it
will attempt to use that symbol in the way the old symbol was supposed
to be used. If I replace a DLL with another one that has an exported
symbol with the same name, the dynamic loader will resolve the address
but I can be screwed basically for the same reason as in Unix. No
difference here. Or is there?
If on Unix I have
link -o executable executable.o object1.so object2.so
./executable
, and when 'executable' needs 'symbol1', and it's not found in
'object1.so', it _might_ be found in 'object2.so' during _run-time_,
while on Windows if I have
link executable.obj object1.lib object2.lib -o exe.exe
exe.exe
finding the symbol has to happen during link-time, right? I am baffled
a bit. So, where's the real difference? If after linking I suddenly
replace 'object1.so' and 'object2.so' with new versions, such that
'Symbol1' _migrated_ from 'object1.so' to the other SO, then I don't have
to re-link, while on Windows I will have to relink, right? Is that the
real difference?
Thanks.
V