fix shared linking on macos

This commit is contained in:
vanhauser-thc 2021-08-19 17:02:17 +02:00
parent 1959812e83
commit 591d6c59c7
3 changed files with 24 additions and 4 deletions

View File

@ -10,9 +10,11 @@ sending a mail to <afl-users+subscribe@googlegroups.com>.
### Version ++3.15a (dev) ### Version ++3.15a (dev)
- afl-fuzz: - afl-fuzz:
added AFL_IGNORE_PROBLEMS plus checks to identify and abort on - added AFL_IGNORE_PROBLEMS plus checks to identify and abort on
incorrect LTO usage setups and enhanced the READMEs for better incorrect LTO usage setups and enhanced the READMEs for better
information on how to deal with instrumenting libraries information on how to deal with instrumenting libraries
- afl-cc:
- fix for shared linking on MacOS
- added the very good grammar mutator "GramaTron" to the - added the very good grammar mutator "GramaTron" to the
custom_mutators custom_mutators
- added optimin, a faster and better corpus minimizer by - added optimin, a faster and better corpus minimizer by

View File

@ -1273,7 +1273,12 @@ __attribute__((constructor(1))) void __afl_auto_second(void) {
if (__afl_already_initialized_second) return; if (__afl_already_initialized_second) return;
__afl_already_initialized_second = 1; __afl_already_initialized_second = 1;
if (getenv("AFL_DEBUG")) { __afl_debug = 1; } if (getenv("AFL_DEBUG")) {
__afl_debug = 1;
fprintf(stderr, "DEBUG: debug enabled\n");
}
if (getenv("AFL_DISABLE_LLVM_INSTRUMENTATION")) return; if (getenv("AFL_DISABLE_LLVM_INSTRUMENTATION")) return;
u8 *ptr; u8 *ptr;

View File

@ -793,6 +793,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
if (!strcmp(cur, "-x")) x_set = 1; if (!strcmp(cur, "-x")) x_set = 1;
if (!strcmp(cur, "-E")) preprocessor_only = 1; if (!strcmp(cur, "-E")) preprocessor_only = 1;
if (!strcmp(cur, "-shared")) shared_linking = 1; if (!strcmp(cur, "-shared")) shared_linking = 1;
if (!strcmp(cur, "-dynamiclib")) shared_linking = 1;
if (!strcmp(cur, "-Wl,-r")) partial_linking = 1; if (!strcmp(cur, "-Wl,-r")) partial_linking = 1;
if (!strcmp(cur, "-Wl,-i")) partial_linking = 1; if (!strcmp(cur, "-Wl,-i")) partial_linking = 1;
if (!strcmp(cur, "-Wl,--relocatable")) partial_linking = 1; if (!strcmp(cur, "-Wl,--relocatable")) partial_linking = 1;
@ -1085,6 +1086,18 @@ static void edit_params(u32 argc, char **argv, char **envp) {
alloc_printf("-Wl,--dynamic-list=%s/dynamic_list.txt", obj_path); alloc_printf("-Wl,--dynamic-list=%s/dynamic_list.txt", obj_path);
#endif #endif
#if defined(__APPLE__)
if (shared_linking || partial_linking) {
cc_params[cc_par_cnt++] = "-Wl,-U";
cc_params[cc_par_cnt++] = "-Wl,___afl_area_ptr";
cc_params[cc_par_cnt++] = "-Wl,-U";
cc_params[cc_par_cnt++] = "-Wl,___sanitizer_cov_trace_pc_guard_init";
}
#endif
} }
#if defined(USEMMAP) && !defined(__HAIKU__) #if defined(USEMMAP) && !defined(__HAIKU__)