Try add this line: extern void foo(void);
Sent from my iPhone > On 2013年10月19日, at 1:21, Charles Srstka <cocoa...@charlessoft.com> wrote: > >> On Oct 18, 2013, at 6:15 AM, Dmitry Markman <dmark...@me.com> 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 (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com