• 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: 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


  • Follow-Ups:
    • Re: C functions
      • From: ChanMaxthon <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>)

  • Prev by Date: Re: Core Data with ODBC databases?
  • Next by Date: Re: C functions
  • Previous by thread: Re: C functions
  • Next by thread: Re: C functions
  • Index(es):
    • Date
    • Thread