-
-
Save cormacrelf/11dcf1787fcc284ad69d28d5932e1928 to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
env MACOSX_DEPLOYMENT_TARGET=10.7 clang -o test10.7 test.c | |
objdump -s test10.7 | |
env MACOSX_DEPLOYMENT_TARGET=12.0 clang -o test12.0 test.c | |
objdump -s test12.0 | |
clang -o testunspec test.c | |
# note the replacement | |
objdump -s testunspec | |
# note the replacement of __DATA,__mod_init_func with __TEXT,__init_offsets | |
*/ | |
#include <stdio.h> | |
void myinit(int argc, char **argv, char **envp) { | |
printf("%s: %s\n", __FILE__, __FUNCTION__); | |
} | |
__attribute__((section("__DATA,__mod_init_func"))) typeof(myinit) *__init = myinit; | |
int main(int argc, char **argv, char **envp) { | |
/* the below __init doesn't link on macOS 12.0, with no deployment target env var set: | |
* ld: reference to symbol (which has not been assigned an address) ___init in '_main' | |
*/ | |
__init(argc, argv, envp); | |
printf("%s: %s\n", __FILE__, __FUNCTION__); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment