Skip to content

Instantly share code, notes, and snippets.

@mikeash
Created May 22, 2018 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeash/e570ca36b42c18657b5196c53eea5a3b to your computer and use it in GitHub Desktop.
Save mikeash/e570ca36b42c18657b5196c53eea5a3b to your computer and use it in GitHub Desktop.
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
Dl_info info;
int success = dladdr(main, &info);
if (success == 0) abort();
printf("main is at %p and the mach-o header that contains it is at %p\n", main, info.dli_fbase);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment