_assert(pthread_create(&client->thread_, NULL, &OnClient, client) == 0);
}
-extern "C" void CYHandleServer(pid_t pid, char *data, size_t size) {
+extern "C" void CYHandleServer(pid_t pid) {
CYInitializeDynamic();
int socket(_syscall(::socket(PF_UNIX, SOCK_STREAM, 0))); try {
library[flength] = '\0';
_assert(strcmp(library + flength - 6, ".dylib") == 0);
#if !TARGET_OS_IPHONE
- strcpy(library + flength - 6, "-any.dylib");
+ strcpy(library + flength - 6, "-###.dylib");
#endif
mach_port_t self(mach_task_self()), task;
lib_LTLIBRARIES =
-if CY_MACH
-lib_LTLIBRARIES += libcycript-any.la
-libcycript_any_la_SOURCES = Select.cpp
-libcycript_any_la_LDFLAGS = $(CY_LDFLAGS)
-libcycript_any_la_LIBADD = -ldl
-endif
-
lib_LTLIBRARIES += libcycript.la
libcycript_la_LDFLAGS = $(CY_LDFLAGS)
libcycript_la_LIBADD = $(LTLIBFFI) $(LTLIBGCC) -ldl
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-@CY_MACH_TRUE@am__append_1 = libcycript-any.la
@CY_CONSOLE_TRUE@bin_PROGRAMS = cycript$(EXEEXT)
-@CY_EXECUTE_TRUE@am__append_2 = sig/ffi_type.cpp sig/parse.cpp \
+@CY_EXECUTE_TRUE@am__append_1 = sig/ffi_type.cpp sig/parse.cpp \
@CY_EXECUTE_TRUE@ sig/copy.cpp Bridge.cpp Execute.cpp \
@CY_EXECUTE_TRUE@ JavaScriptCore.cpp
-@CY_EXECUTE_TRUE@am__append_3 = $(LTJAVASCRIPTCORE)
-@CY_EXECUTE_TRUE@am__append_4 = -DCY_EXECUTE
-@CY_EXECUTE_TRUE@am__append_5 = C
-@CY_EXECUTE_TRUE@am__append_6 = Bridge.gperf Bridge.hpp
-@CY_OBJECTIVEC_TRUE@am__append_7 = ObjectiveC
-@CY_OBJECTIVEC_TRUE@am__append_8 = ObjectiveC/Output.cpp ObjectiveC/Replace.cpp ObjectiveC/Library.mm
-@CY_OBJECTIVEC_TRUE@am__append_9 = $(LTOBJECTIVEC)
-@CY_MACH_TRUE@am__append_10 = Handler.mm
-@CY_CONSOLE_TRUE@@CY_MACH_TRUE@am__append_11 = Mach/Inject.cpp
-@CY_CONSOLE_TRUE@@CY_MACH_TRUE@am__append_12 = -DCY_ATTACH
-@CY_CONSOLE_TRUE@@CY_MACH_TRUE@am__append_13 = Trampoline.t.lo \
+@CY_EXECUTE_TRUE@am__append_2 = $(LTJAVASCRIPTCORE)
+@CY_EXECUTE_TRUE@am__append_3 = -DCY_EXECUTE
+@CY_EXECUTE_TRUE@am__append_4 = C
+@CY_EXECUTE_TRUE@am__append_5 = Bridge.gperf Bridge.hpp
+@CY_OBJECTIVEC_TRUE@am__append_6 = ObjectiveC
+@CY_OBJECTIVEC_TRUE@am__append_7 = ObjectiveC/Output.cpp ObjectiveC/Replace.cpp ObjectiveC/Library.mm
+@CY_OBJECTIVEC_TRUE@am__append_8 = $(LTOBJECTIVEC)
+@CY_MACH_TRUE@am__append_9 = Handler.mm
+@CY_CONSOLE_TRUE@@CY_MACH_TRUE@am__append_10 = Mach/Inject.cpp
+@CY_CONSOLE_TRUE@@CY_MACH_TRUE@am__append_11 = -DCY_ATTACH
+@CY_CONSOLE_TRUE@@CY_MACH_TRUE@am__append_12 = Trampoline.t.lo \
@CY_CONSOLE_TRUE@@CY_MACH_TRUE@ libTrampoline.t.la \
@CY_CONSOLE_TRUE@@CY_MACH_TRUE@ Trampoline.t.hpp
subdir = .
}
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
-libcycript_any_la_DEPENDENCIES =
-am__libcycript_any_la_SOURCES_DIST = Select.cpp
-@CY_MACH_TRUE@am_libcycript_any_la_OBJECTS = Select.lo
-libcycript_any_la_OBJECTS = $(am_libcycript_any_la_OBJECTS)
-AM_V_lt = $(am__v_lt_@AM_V@)
-am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
-am__v_lt_0 = --silent
-am__v_lt_1 =
-libcycript_any_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
- $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
- $(AM_CXXFLAGS) $(CXXFLAGS) $(libcycript_any_la_LDFLAGS) \
- $(LDFLAGS) -o $@
-@CY_MACH_TRUE@am_libcycript_any_la_rpath = -rpath $(libdir)
am__DEPENDENCIES_1 =
@CY_EXECUTE_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
@CY_OBJECTIVEC_TRUE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1)
Replace.lo Cycript.tab.lo lex.cy.lo $(am__objects_1) \
$(am__objects_2) $(am__objects_3)
libcycript_la_OBJECTS = $(am_libcycript_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 =
libcycript_la_LINK = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(OBJCXXLD) $(AM_OBJCXXFLAGS) \
$(OBJCXXFLAGS) $(libcycript_la_LDFLAGS) $(LDFLAGS) -o $@
am__v_OBJCXXLD_ = $(am__v_OBJCXXLD_@AM_DEFAULT_V@)
am__v_OBJCXXLD_0 = @echo " OBJCXXLD" $@;
am__v_OBJCXXLD_1 =
-SOURCES = $(libcycript_any_la_SOURCES) $(libcycript_la_SOURCES) \
- $(cycript_SOURCES)
-DIST_SOURCES = $(am__libcycript_any_la_SOURCES_DIST) \
- $(am__libcycript_la_SOURCES_DIST) $(am__cycript_SOURCES_DIST)
+SOURCES = $(libcycript_la_SOURCES) $(cycript_SOURCES)
+DIST_SOURCES = $(am__libcycript_la_SOURCES_DIST) \
+ $(am__cycript_SOURCES_DIST)
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = subdir-objects
-CLEANFILES = $(am__append_6) $(am__append_13) Cycript.yy Cycript.l \
+CLEANFILES = $(am__append_5) $(am__append_12) Cycript.yy Cycript.l \
lex.cy.cpp Cycript.tab.cc Cycript.tab.hh location.hh \
position.hh stack.hh Cycript.output
SUBDIRS =
ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS = -I$(srcdir)/include -DYYDEBUG=1 -include config.h \
- -include $(srcdir)/unconfig.h $(am__append_4) $(am__append_12)
+ -include $(srcdir)/unconfig.h $(am__append_3) $(am__append_11)
CY_LDFLAGS = -no-undefined -avoid-version -export-dynamic
-lib_LTLIBRARIES = $(am__append_1) libcycript.la
-@CY_MACH_TRUE@libcycript_any_la_SOURCES = Select.cpp
-@CY_MACH_TRUE@libcycript_any_la_LDFLAGS = $(CY_LDFLAGS)
-@CY_MACH_TRUE@libcycript_any_la_LIBADD = -ldl
+lib_LTLIBRARIES = libcycript.la
libcycript_la_LDFLAGS = $(CY_LDFLAGS)
-libcycript_la_LIBADD = $(LTLIBFFI) $(LTLIBGCC) -ldl $(am__append_3) \
- $(am__append_9)
+libcycript_la_LIBADD = $(LTLIBFFI) $(LTLIBGCC) -ldl $(am__append_2) \
+ $(am__append_8)
libcycript_la_SOURCES = ConvertUTF.c Decode.cpp Driver.cpp \
Highlight.cpp Library.cpp Network.cpp Output.cpp Parser.cpp \
- Replace.cpp Cycript.tab.cc lex.cy.cpp $(am__append_2) \
- $(am__append_8) $(am__append_10)
-filters = $(CY_FILTERS) $(am__append_5) $(am__append_7)
+ Replace.cpp Cycript.tab.cc lex.cy.cpp $(am__append_1) \
+ $(am__append_7) $(am__append_9)
+filters = $(CY_FILTERS) $(am__append_4) $(am__append_6)
@CY_CONSOLE_TRUE@cycript_SOURCES = Console.cpp Display.cpp \
-@CY_CONSOLE_TRUE@ $(am__append_11)
+@CY_CONSOLE_TRUE@ $(am__append_10)
@CY_CONSOLE_TRUE@cycript_LDADD = libcycript.la $(LTLIBAPR) $(LTLIBREADLINE) $(LTLIBTERMCAP) $(LTLIBGCC) -ldl
@CY_CONSOLE_TRUE@ldid = true
@CY_CONSOLE_TRUE@entitle = $(ldid) -S$(srcdir)/cycript.xml
echo rm -f $${locs}; \
rm -f $${locs}; \
}
-
-libcycript-any.la: $(libcycript_any_la_OBJECTS) $(libcycript_any_la_DEPENDENCIES) $(EXTRA_libcycript_any_la_DEPENDENCIES)
- $(AM_V_CXXLD)$(libcycript_any_la_LINK) $(am_libcycript_any_la_rpath) $(libcycript_any_la_OBJECTS) $(libcycript_any_la_LIBADD) $(LIBS)
sig/$(am__dirstamp):
@$(MKDIR_P) sig
@: > sig/$(am__dirstamp)
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Output.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Parser.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Replace.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Select.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lex.cy.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@Mach/$(DEPDIR)/Inject.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ObjectiveC/$(DEPDIR)/Library.Plo@am__quote@
+++ /dev/null
-/* Cycript - Optimizing JavaScript Compiler/Runtime
- * Copyright (C) 2009-2013 Jay Freeman (saurik)
-*/
-
-/* GNU General Public License, Version 3 {{{ */
-/*
- * Cycript is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation, either version 3 of the License,
- * or (at your option) any later version.
- *
- * Cycript is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Cycript. If not, see <http://www.gnu.org/licenses/>.
-**/
-/* }}} */
-
-#include <cstring>
-
-#include <stdint.h>
-
-#include <dlfcn.h>
-#include <syslog.h>
-#include <unistd.h>
-
-#include <mach-o/dyld.h>
-
-extern "C" void CYHandleServer(pid_t pid, char *data, size_t size) {
- Dl_info addr;
- if (dladdr(reinterpret_cast<void *>(&CYHandleServer), &addr) == 0)
- return;
-
- const char *fname(addr.dli_fname);
- size_t length(strlen(fname));
-
- const char *target;
-#ifdef __APPLE__
- // XXX: THIS IS HORRIBLE OMG I NEED TO FIX THIS ASAP
- bool simulator(false);
- for (uint32_t i(0), e(_dyld_image_count()); i != e; ++i) {
- if (strstr(_dyld_get_image_name(i), "/SDKs/iPhoneSimulator") != NULL)
- simulator = true;
- }
- if (simulator)
- target = "sim";
- else
-#endif
- // someone threw a fit about dangling #endif + else
- // the idea that this bothers someone gives me glee
- target = "sys";
-
- char library[length + 1];
- memcpy(library, fname, length);
- memcpy(library + length - 6 - 3, target, 3);
- library[length] = '\0';
-
- void *handle(dlopen(library, RTLD_LOCAL | RTLD_LAZY));
- if (handle == NULL) {
- strlcpy(data, dlerror(), size);
- return;
- }
-
- void *symbol(dlsym(handle, "CYHandleServer"));
- if (symbol == NULL) {
- strlcpy(data, dlerror(), size);
- return;
- }
-
- reinterpret_cast<void (*)(pid_t)>(symbol)(pid);
-}
bytes[i] = 0;
}
+__attribute__((__unused__))
+static void $memcpy(char *dst, const char *src, size_t size) {
+ for (size_t i(0); i != size; ++i)
+ dst[i] = src[i];
+}
+
static int $strcmp(const char *lhs, const char *rhs) {
while (*lhs == *rhs) {
if (*lhs == '\0')
} dst[i] = '\0';
}
+__attribute__((__unused__))
+static char *$strstr(const char *haystack, const char *needle) {
+ if (*needle == '\0')
+ return NULL;
+ for (; *haystack != '\0'; ++haystack)
+ for (size_t i(0); ; ++i)
+ if (needle[i] == '\0')
+ return const_cast<char *>(haystack);
+ else if (needle[i] != haystack[i])
+ break;
+ return NULL;
+}
+
+__attribute__((__unused__))
+static size_t $strlen(const char *data) {
+ for (size_t i(0); ; ++i)
+ if (data[i] == '\0')
+ return i;
+}
+
__attribute__((__unused__))
static void $snprintfp(char *dst, size_t size, const void *pointer) {
uintptr_t value(reinterpret_cast<uintptr_t>(pointer));
return Library(infos, name);
}
+#if defined(__i386__) || defined(__x86_64__)
+static bool Simulator(struct dyld_all_image_infos *infos) {
+ for (uint32_t i(0); i != infos->infoArrayCount; ++i) {
+ const dyld_image_info &info(infos->infoArray[i]);
+ const char *path(info.imageFilePath);
+ if ($strstr(path, "/SDKs/iPhoneSimulator") != NULL)
+ return true;
+ } return false;
+}
+
+static bool Simulator(Baton *baton) {
+ struct dyld_all_image_infos *infos(reinterpret_cast<struct dyld_all_image_infos *>(baton->dyld));
+ return Simulator(infos);
+}
+#endif
+
void *Routine(void *arg) {
Baton *baton(reinterpret_cast<Baton *>(arg));
void *(*$dlopen)(const char *, int);
cyset($dlopen, "_dlopen", dyld);
+#if defined(__i386__) || defined(__x86_64__)
+ size_t length($strlen(baton->library));
+ if (length >= 10 && $strcmp(baton->library + length - 10, "-###.dylib") == 0)
+ $memcpy(baton->library + length - 10, Simulator(baton) ? "-sim" : "-sys", 4);
+#endif
+
void *handle($dlopen(baton->library, RTLD_LAZY | RTLD_LOCAL));
if (handle == NULL) {
$strlcpy(baton->error, $dlerror(), sizeof(baton->error));
void *(*$dlsym)(void *, const char *);
cyset($dlsym, "_dlsym", dyld);
- void (*CYHandleServer)(pid_t, char *, size_t);
- CYHandleServer = reinterpret_cast<void (*)(pid_t, char *, size_t)>($dlsym(handle, "CYHandleServer"));
+ void (*CYHandleServer)(pid_t);
+ CYHandleServer = reinterpret_cast<void (*)(pid_t)>($dlsym(handle, "CYHandleServer"));
if (CYHandleServer == NULL) {
$strlcpy(baton->error, $dlerror(), sizeof(baton->error));
return NULL;
}
- CYHandleServer(baton->pid, baton->error, sizeof(baton->error));
+ CYHandleServer(baton->pid);
return NULL;
}
binary := Cycript_/cycript
-$(deb): $(binary) $(patsubst %,Cycript_/libcycript%dylib,. -any. -sim. -sys.) control
+$(deb): $(binary) $(patsubst %,Cycript_/libcycript%dylib,. -sim. -sys.) control
rm -rf package
mkdir -p package/DEBIAN
cp -pR control package/DEBIAN
cycript += Cycript.lib/cycript
cycript += Cycript.lib/cycript0.9
cycript += Cycript.lib/libcycript.dylib
-cycript += Cycript.lib/libcycript-any.dylib
cycript += Cycript.lib/libcycript-sys.dylib
cycript += Cycript.lib/libcycript-sim.dylib
define build_sim
$(call build_any,sim,$(1))
$(call build_lib,sim,$(1))
-build.sim-$(1)/.libs/libcycript-any.dylib: build-sim-$(1)
- @
endef
$(foreach arch,i386 x86_64,$(eval $(call build_sim,$(arch))))
$(foreach arch,armv6 arm64,$(eval $(call build_arm,$(arch))))
-Cycript.lib/libcycript-any.dylib: build.sim-i386/.libs/libcycript-any.dylib build.sim-x86_64/.libs/libcycript-any.dylib
- @mkdir -p $(dir $@)
- $(lipo) -create -output $@ $^
- codesign -s $(codesign) $@
-
Cycript.lib/libcycript.dylib: build.mac-i386/.libs/libcycript.dylib build.mac-x86_64/.libs/libcycript.dylib build.ios-armv6/.libs/libcycript.dylib build.ios-arm64/.libs/libcycript.dylib
@mkdir -p $(dir $@)
$(lipo) -create -output $@ $^
cp -af $< $@
chmod 755 $@
-install: Cycript.lib/cycript Cycript.lib/libcycript.dylib Cycript.lib/libcycript-sys.dylib Cycript.lib/libcycript-any.dylib Cycript.lib/libcycript-sim.dylib
+install: Cycript.lib/cycript Cycript.lib/libcycript.dylib Cycript.lib/libcycript-sys.dylib Cycript.lib/libcycript-sim.dylib
sudo cp -af $(filter-out %.dylib,$^) /usr/bin
sudo cp -af $(filter %.dylib,$^) /usr/lib