This code worked fine in the fixed-loading-location Windows world; it
would probably work fine if I was building an application. However,
my component's code needs to be position-independent, as I understand
it, and this means that the inline assembly can't access
g_Some_MMX_Global without offsetting from a base pointer.
Yes, indeed. Building a dylib, you'll get a link error from
g_Some_MMX_Global. Building an app, the code works as is.
What is the correct way to do this? The narrow questions I'm asking
are: How do I write an expression that evaluates to a global
variable's offset within the mach-o section, without creating a local
relocation entry? Can I then use that offset as a displacement from a
base pointer to access the global variable?
Compile (as a dylib) this function, modified from yours to read/write
the global without asm:
static long long gSomeGlobal = 12345678LL;
void SomeFunction( void )
{
long long t;
t = gSomeGlobal;
gSomeGlobal = t;
}
Then look at the disassembly, which shows the official method of
access, involving a little cutie named ___i686.get_pc_thunk.bx:
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/email@hidden