From c3700deebdbd94f6c9f336b90bb441e858a016a7 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 10 Nov 2015 00:58:35 -0800 Subject: [PATCH] Fix build of cycript when using g++-fsf from Fink. --- Inject.cpp | 5 ++++- Makefile.am | 2 ++ Makefile.in | 1 + ObjectiveC/Library.mm | 12 ++++++------ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Inject.cpp b/Inject.cpp index 051fc0c..eb85351 100644 --- a/Inject.cpp +++ b/Inject.cpp @@ -28,6 +28,8 @@ #include "Pooling.hpp" #if defined(__APPLE__) && (defined(__i386__) || defined(__x86_64__)) +#include + #include #include @@ -65,7 +67,8 @@ void InjectLibrary(int pid, int argc, const char *argv[]) { off_t offset; _assert(csops(pid, CS_OPS_PIDOFFSET, &offset, sizeof(offset)) != -1); - char path[PATH_MAX]; + // XXX: implement a safe version of this + char path[4096]; int writ(proc_pidpath(pid, path, sizeof(path))); _assert(writ != 0); diff --git a/Makefile.am b/Makefile.am index b9e7b64..57cdbdc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,6 +28,8 @@ ACLOCAL_AMFLAGS = -I m4 AM_CPPFLAGS = -DYYDEBUG=1 AM_CPPFLAGS += -include config.h -include $(srcdir)/unconfig.h +AM_OBJCXXFLAGS = -fobjc-exceptions + CY_LDFLAGS = -no-undefined -avoid-version -export-dynamic lib_LTLIBRARIES = diff --git a/Makefile.in b/Makefile.in index 429f043..f94d427 100644 --- a/Makefile.in +++ b/Makefile.in @@ -538,6 +538,7 @@ SUBDIRS = ACLOCAL_AMFLAGS = -I m4 AM_CPPFLAGS = -DYYDEBUG=1 -include config.h -include \ $(srcdir)/unconfig.h $(am__append_3) $(am__append_14) +AM_OBJCXXFLAGS = -fobjc-exceptions CY_LDFLAGS = -no-undefined -avoid-version -export-dynamic lib_LTLIBRARIES = libcycript.la libcycript_la_LDFLAGS = $(CY_LDFLAGS) diff --git a/ObjectiveC/Library.mm b/ObjectiveC/Library.mm index ee1f5bf..e68fb1b 100644 --- a/ObjectiveC/Library.mm +++ b/ObjectiveC/Library.mm @@ -159,7 +159,7 @@ const char *CYPoolCString(CYPool &pool, JSContextRef context, NSString *value) { return string; } -#ifdef __APPLE__ +#ifdef __clang__ JSStringRef CYCopyJSString(JSContextRef context, NSString *value) { return JSStringCreateWithCFString(reinterpret_cast(value)); } @@ -170,7 +170,7 @@ JSStringRef CYCopyJSString(JSContextRef context, NSObject *value) { return NULL; // XXX: this definition scares me; is anyone using this?! NSString *string([value description]); -#ifdef __APPLE__ +#ifdef __clang__ return CYCopyJSString(context, string); #else CYPool pool; @@ -767,7 +767,7 @@ NSObject *CYCopyNSObject(CYPool &pool, JSContextRef context, JSValueRef value) { [json appendString:@"@["]; bool comma(false); -#ifdef __APPLE__ +#ifdef __clang__ for (id object in self) { #else for (size_t index(0), count([self count]); index != count; ++index) { @@ -877,7 +877,7 @@ NSObject *CYCopyNSObject(CYPool &pool, JSContextRef context, JSValueRef value) { [json appendString:@"@{"]; bool comma(false); -#ifdef __APPLE__ +#ifdef __clang__ for (NSObject *key in self) { #else NSEnumerator *keys([self keyEnumerator]); @@ -908,7 +908,7 @@ NSObject *CYCopyNSObject(CYPool &pool, JSContextRef context, JSValueRef value) { - (void) cy$getPropertyNames:(JSPropertyNameAccumulatorRef)names inContext:(JSContextRef)context { [super cy$getPropertyNames:names inContext:context]; -#ifdef __APPLE__ +#ifdef __clang__ for (NSObject *key in self) { #else NSEnumerator *keys([self keyEnumerator]); @@ -2255,7 +2255,7 @@ static JSValueRef choose(JSContextRef context, JSObjectRef object, JSObjectRef _ CYGarbageCollect(context); CYPool pool; - Class _class(CYCastNSObject(&pool, context, arguments[0])); + id _class(CYCastNSObject(&pool, context, arguments[0])); vm_address_t *zones(NULL); unsigned size(0); -- 2.47.2