• 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:36:22 -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)

Trying to set the symbol to external doesn't seem to change things:

#import <Foundation/Foundation.h>
#include <dlfcn.h>

extern __attribute__((visibility("default"))) 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;
}

Debug mode:

2013-10-18 12:28:41.565 dlsymtest[95471:303] The correct address is 0x100000e40
2013-10-18 12:28:41.576 dlsymtest[95471:303] dlsym returns 0x100000e40

Archived:

2013-10-18 12:30:42.232 dlsymtest[95518:707] The correct address is 0x10cd74e6a
2013-10-18 12:30:42.236 dlsymtest[95518:707] dlsym returns 0x0

Looking at the Mach-O binary, _foo is listed as an external symbol in the binary built in Debug mode, but not for the archived binary. It may be that the strip program removes external symbols that it sees as unnecessary.

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


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: C functions
  • Next by Date: Re: C functions
  • Previous by thread: Re: C functions
  • Next by thread: Re: C functions
  • Index(es):
    • Date
    • Thread