Hi there,
I'm porting some optimization stuff from Windows to Mac OS X and found a pretty interesting trouble.
What I need is simply to load a constant into a XMM register (things like 0.5f, or 0x7FFFFFFF DWORD retyped to float to emulate absolute value...). Using MASM I just need to write something like
movss xmm0, [xxxxConstant]
This worked under Win32/Win64 and EXE/DLL. Now I moved to NASM, because I needed Mac OS X support and under Win32 it stays the some. Under Win64 I needed to use
mov rax, xxxxConstant
mov xmm0, [rax]
but ok, so be it, let's say NASM cannot generate 64-bit addresses or something (though it is weird, 'cos MASM could).
But the real trouble is on Mac OS X (macho), where it works only in executables, not shared libraries. In that case GCC linker generates error something like that it cannot use absolute addressing.
I know it uses some sort of rellocation, but why it cannot use some relative offsets it uses for jumps? Documentation says we can use some GOT stuff, but that is a huge mess and when I tried it, the NASM errors with "unknown symbol got".
So my question is, how can I simply load a constant (float/double) into a XMM register on Mac OS X shared library? And is that some way to do it on all platforms?
Thanks in advance!