Created
January 12, 2018 22:48
-
-
Save anonymous/bab9c0fcafd9a03acfaa89741f26eb36 to your computer and use it in GitHub Desktop.
fluxcapacitor os x patch WIP: https://idea.popcount.org/2013-07-19-how-to-sleep-a-million-years/
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
diff --git a/Makefile b/Makefile | |
index 60d0021..6a8d7a1 100644 | |
--- a/Makefile | |
+++ b/Makefile | |
@@ -1,8 +1,8 @@ | |
-LIBNAME=fluxcapacitor_preload.so | |
-TESTLIBNAME=fluxcapacitor_test.so | |
+LIBNAME=fluxcapacitor_preload.dylib | |
+TESTLIBNAME=fluxcapacitor_test.dylib | |
LOADERNAME=fluxcapacitor | |
-LDOPTS+=-lrt -ldl -rdynamic | |
+LDOPTS+=-ldl -rdynamic | |
COPTS+=$(CFLAGS) -g -ggdb -Wall -Wextra -Wno-unused-parameter -O3 -fPIC | |
TESTLIB_FILES=src/testlib.c | |
@@ -16,11 +16,11 @@ build: $(TESTLIBNAME) $(LIBNAME) $(LOADERNAME) | |
$(TESTLIBNAME): Makefile $(TESTLIB_FILES) | |
$(CC) $(COPTS) $(TESTLIB_FILES) \ | |
- -fPIC -shared -Wl,-soname,$(TESTLIBNAME) -o $(TESTLIBNAME) | |
+ -dynamiclib -Wl,-headerpad_max_install_names,-undefined,dynamic_lookup,-compatibility_version,1.0,-current_version,1.0,-install_name,/usr/local/lib/$(TESTLIBNAME) -o $(TESTLIBNAME) | |
$(LIBNAME): Makefile $(LIB_FILES) | |
$(CC) $(COPTS) $(LIB_FILES) $(LDOPTS) \ | |
- -fPIC -shared -Wl,-soname,$(LIBNAME) -o $(LIBNAME) | |
+ -dynamiclib -Wl,-headerpad_max_install_names,-undefined,dynamic_lookup,-compatibility_version,1.0,-current_version,1.0,-install_name,/usr/local/lib/$(LIBNAME) -o $(LIBNAME) | |
$(LOADERNAME): Makefile $(LOADER_FILES) | |
$(CC) $(COPTS) $(LOADER_FILES) $(LDOPTS) \ | |
diff --git a/src/preload.c b/src/preload.c | |
index f25d1ed..830ffdf 100644 | |
--- a/src/preload.c | |
+++ b/src/preload.c | |
@@ -47,7 +47,7 @@ int clock_gettime(clockid_t clk_id, struct timespec *tp) { | |
/* Translate to clock_gettime() */ | |
PUBLIC | |
-int gettimeofday(struct timeval *tv, struct timezone *tz) { | |
+int gettimeofday(struct timeval *tv, void *tz) { | |
long a = 0, b = 0; | |
if (tv) { | |
struct timespec ts; | |
@@ -97,6 +97,9 @@ int clock_nanosleep(clockid_t clk_id, int flags, | |
clock_gettime(CLOCK_REALTIME, &tmp); | |
u64 now = TIMESPEC_NSEC(&tmp); | |
u64 end, diff; | |
+#ifdef __APPLE__ && !defined(TIMER_ABSTIME) | |
+#define TIMER_ABSTIME 0 | |
+#endif | |
if (flags & TIMER_ABSTIME) { | |
end = TIMESPEC_NSEC(request); | |
if (end > now) { | |
diff --git a/src/wrapper.c b/src/wrapper.c | |
index c616aa8..2d16650 100644 | |
--- a/src/wrapper.c | |
+++ b/src/wrapper.c | |
@@ -2,7 +2,9 @@ | |
#include <stdlib.h> | |
#include <errno.h> | |
#include <time.h> | |
+#ifndef __APPLE__ | |
#include <sys/prctl.h> | |
+#endif | |
#include "list.h" | |
#include "types.h" | |
@@ -58,6 +60,7 @@ void wrapper_syscall_enter(struct child *child, struct trace_sysarg *sysarg) { | |
type = TYPE_TIMESPEC; value = sysarg->arg1; | |
break; | |
+#ifndef __APPLE__ | |
/* Anti-debugging machinery. Prevent processes from disabling ptrace. */ | |
case __NR_prctl: | |
if (sysarg->arg1 == PR_SET_DUMPABLE && sysarg->arg2 == 0) { | |
@@ -67,6 +70,7 @@ void wrapper_syscall_enter(struct child *child, struct trace_sysarg *sysarg) { | |
trace_setregs(child->process, sysarg); | |
} | |
break; | |
+#endif | |
} | |
if (!type) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment