[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] mathx for Lua 5.3
- From: William Ahern <william@...>
- Date: Wed, 6 May 2015 12:02:08 -0700
On Wed, May 06, 2015 at 11:45:32AM +0100, Rob Kendrick wrote:
> On Wed, May 06, 2015 at 07:34:18AM -0300, Luiz Henrique de Figueiredo wrote:
> > > Strictly speaking, -fPIC is needed for any shared library. It just
> > > happens that there's a happy coincidence that means you can often get
> > > away without it on 32 bit x86.
> > Mac OS X does not need -fPIC, even in 64-bit machines.
> My guess here is that this is either that it is enabled by default there
> because they do ASLR, or it's some strange fall-out from OS X's bizarre
> binary format :)
Yes, PIC code is the default. OS X doesn't support static linking in as much
there are no static versions of any of the standard libraries--libcrt0,
> A shared library needs to be position independent code, that much is
> non-negotiable, but some tooling probably handles it for you. It
> should always be safe to add.
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.