• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: C functions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C functions


  • Subject: Re: C functions
  • From: ChanMaxthon <email@hidden>
  • Date: Sat, 19 Oct 2013 07:42:40 +0800

Try add this line:

extern void foo(void);

Sent from my iPhone

> On 2013年10月19日, at 1:21, Charles Srstka <email@hidden> wrote:
>
>> 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


  • Follow-Ups:
    • Re: C functions
      • From: Charles Srstka <email@hidden>
References: 
 >C functions (From: Shane Stanley <email@hidden>)
 >Re: C functions (From: Charles Srstka <email@hidden>)
 >Re: C functions (From: Maxthon Chan <email@hidden>)
 >Re: C functions (From: Charles Srstka <email@hidden>)
 >Re: C functions (From: Charles Srstka <email@hidden>)

  • Prev by Date: modal window and quit menu item
  • Next by Date: Re: C functions
  • Previous by thread: Re: C functions
  • Next by thread: Re: C functions
  • Index(es):
    • Date
    • Thread