lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On May 6, 2015, at 12:02 PM, William Ahern <william@25thandClement.com> wrote:

Most people consider Windows DLLs to be shared libraries, but they don't use
position independent code in that there's no GOT table or similar mechanism.
Rather, the linker literally has to hack the binary and the DLL in order to
change function addresses if there's a conflict. Sometimes it can't succeed.
This is one of the reasons for so-called DLL hell. It also means that
Windows often uses more memory than other systems because two processes
sharing the same DLL can't share the virtual memory pages for that DLL if
one of the processes had to rewrite the DLL at load time.

it’s a bit unfair to call fixups a “hack”, and in fact they never fail (DLL hell has another cause entirely). Fixing up object code at load time is no different to the routine relocations linkers routinely do when merging compiled object files (for example, when loading static object code libraries).

To be fair to Microsoft, the standard set of Windows system DLLs always had carefully predefined load addresses so that collisions were rare (and when they did occur they could be statically relocated at load time), which typically meant they COULD be shared across processes via shared copy-on-write pages. It was only when random-address loading was added as an anti-virus measure that pic became desirable/necessary.

And it should be remembered that pic has runtime overhead (slower execution) as the compiler must generate extra code in many cases.

—Tim