Re: dlsym question
Re: dlsym question
- Subject: Re: dlsym question
- From: Nat! <email@hidden>
- Date: Sat, 09 Apr 2011 23:46:03 +0200
Am 09.04.2011 um 21:46 schrieb Peter O'Gorman:
> On 04/09/2011 10:04 AM, Shantonu Sen wrote:
>> What are you really trying to do?
>>
>> Shantonu
>>
>> On Apr 9, 2011, at 4:01 AM, Nat! wrote:
>
>>> 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.
>>>
>
> dlsym looks up C symbols, all of which have a leading underscore, the man page explains this:
>
> The symbol name passed to dlsym() is the name used in C source code. For example to find the address of function foo(), you would pass "foo" as the symbol name. This is unlike the older dyld APIs which required a leading underscore. If you looking up a C++ symbol, you need to use the mangled C++ symbol name.
>
> So, yeah, what Shantonu said.
>
> Peter
>
Well never mind, I just looked up the dyld source and there it is
// dlsym() assumes symbolName passed in is same as in C source code
// dyld assumes all symbol names have an underscore prefix
char underscoredName[strlen(symbolName)+2];
underscoredName[0] = '_';
strcpy(&underscoredName[1], symbolName);
Not that powerful, if your linker produces symbols, that do not start with an underscore. Probably that's why in x86_64 classes are now prefixed with '_'.
Anyway I am working around it now with dladdr, which is not so portable as it seems.
Ciao
Nat!
---------------------------------------------------
Why should I have to work for everything ?!
It's like saying I don't deserve it. -- Watterson
_______________________________________________
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