dlsym question
dlsym question
- Subject: dlsym question
- From: Nat! <email@hidden>
- Date: Sat, 09 Apr 2011 13:01:36 +0200
Hi
I have this problem with dlsym locating a symbol. It works in x86_64 but fails in i386:
#include <dlfcn.h>
#include <stdio.h>
int main( int argc, char *argv[])
{
void *handle;
void *sym;
int step;
handle = dlopen( "/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation", RTLD_LAZY);
step = 0;
sym = dlsym( handle, "_OBJC_CLASS_$_NSThread");
if( ! sym)
{
++step;
sym = dlsym( handle, "OBJC_CLASS_$_NSThread");
if( ! sym)
{
++step;
sym = dlsym( handle, ".objc_class_name_NSThread");
}
}
printf( "@%d %p:%p\n", step, handle, sym);
return( 0);
}
Output in x86_64: @1 0x7fff5fc43d78:0x7fff709366d8
Output in i386 : @2 0x8fe467a8:0x0
If I look at the output of nm
$ nm Foundation.i386 | egrep '[oO][bB][jJ][cC].*NSThread$'
0028b3a4 S .objc_class_name_NSThread
$ nm Foundation.x86_64 | egrep '[oO][bB][jJ][cC].*NSThread$'
00000000002a76d8 S _OBJC_CLASS_$_NSThread
I speculate that the problem is, that in i386 the symbol starts with a "." instead of an underscore and that the possibly naive dlsym code gets confused by this.
Is there a simple workaround ? (removing the leading '.' doesn't work)
Ciao
Nat!
------------------------------------------------------
Companies have more than enough "idea guys" and
ideas in general than they ever have time to
produce. They certainly aren't going to pay
someone to sit around and come up with ideas
all day.
It's just not going to happen. -- K. Hoekstra
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden