Re: C functions
Re: C functions
- Subject: Re: C functions
- From: Charles Srstka <email@hidden>
- Date: Fri, 18 Oct 2013 12:21:18 -0500
On Oct 18, 2013, at 6:15 AM, Dmitry Markman <email@hidden> wrote:
> I don't thinks strip remove info used by dynamic linker
> Thus dlsym should work
> As long as symbol is external (not with hidden visibility) dlsym is able to find the symbol
> (stripped or not)
Not in my testing:
#import <Foundation/Foundation.h>
#include <dlfcn.h>
void foo() {
}
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSLog(@"The correct address is %p", &foo);
NSLog(@"dlsym returns %p", dlsym(RTLD_SELF, "foo"));
}
return 0;
}
In debug mode:
2013-10-18 12:16:37.027 dlsymtest[95106:303] The correct address is 0x100000e40
2013-10-18 12:16:37.031 dlsymtest[95106:303] dlsym returns 0x100000e40
Program ended with exit code: 0
Doing an Archive in Xcode and running the resulting binary in the Terminal:
2013-10-18 12:17:17.891 dlsymtest[95151:707] The correct address is 0x10574fe6a
2013-10-18 12:17:17.902 dlsymtest[95151:707] dlsym returns 0x0
It won't work with the default build settings. Other commenters are correct, however, that it can work if you move the symbols you want to look up into a library.
Charles
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden