fix shared linking on macos
MODIFY
docs/Changelog.md
docs/Changelog.md
@@ -10,9 +10,11 @@ sending a mail to <afl-users+subscribe@googlegroups.com>.
### Version ++3.15a (dev)
- 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
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
custom_mutators
- added optimin, a faster and better corpus minimizer by

MODIFY
instrumentation/afl-compiler-rt.o.c
instrumentation/afl-compiler-rt.o.c
@@ -1273,7 +1273,12 @@ __attribute__((constructor(1))) void __afl_auto_second(void) {
if (__afl_already_initialized_second) return;
__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;
u8 *ptr;

MODIFY
src/afl-cc.c
src/afl-cc.c
@@ -793,6 +793,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
if (!strcmp(cur, "-x")) x_set = 1;
if (!strcmp(cur, "-E")) preprocessor_only = 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,-i")) 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);
#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__)

fix shared linking on macos