Last active
August 1, 2018 15:24
-
-
Save michaeljclark/a0b0e8039884a581e788e027a5e93185 to your computer and use it in GitHub Desktop.
emulating indirect weak aliases with strong direct aliases for Mach-O
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#if HAVE_ALIASES | |
#define weak_alias(old, new) \ | |
extern __typeof(old) new __attribute__((weak, alias(#old))) | |
#else | |
#define weak_alias(old, new) \ | |
__asm__(".globl _" #new); \ | |
__asm__("_" #new " = _" #old); \ | |
extern __typeof(old) new __attribute__((weak_import)) | |
#endif | |
void __foo() | |
{ | |
printf("foo\n"); | |
} | |
weak_alias(__foo, foo); | |
int main() | |
{ | |
foo(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment