From: Jay Freeman (saurik) <saurik@saurik.com>
Date: Sat, 31 Oct 2009 23:31:27 +0000 (+0000)
Subject: Redid the trampoline generator in what will hopefully be a more portable fashion.
X-Git-Tag: v0.9.432~212
X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/032e971ea180d9e7f9df03887bedd233c8d5c537

Redid the trampoline generator in what will hopefully be a more portable fashion.
---

diff --git a/Darwin.mk b/Darwin.mk
index 9c480e2..5f27a00 100644
--- a/Darwin.mk
+++ b/Darwin.mk
@@ -15,6 +15,6 @@ inject += Mach/Inject.o
 Mach/Inject.o: Trampoline.t.hpp Baton.hpp
 
 %.t.hpp: %.t.cpp
-	$(target)gcc -c -o $*.t.o $< && { $(target)otool -l $*.t.o | sed -e '/^ *segname __TEXT$$/ { x; s/^ *sectname //; p; }; /^ *sectname / x; d;' | while read -r sect; do $(target)otool -s __TEXT "$$sect" Trampoline.t.o; done | sed -e '/:$$/ d; / section$$/ d; s/^[^ \t]*[ \t]*//;s/ $$//;s/ /\n/g' | sed -e 's/\(..\)\(..\)\(..\)\(..\)/0\x\4,0\x\3,0\x\2,0\x\1/' | tr '\n' ',' | sed -e '$$ s/,$$//; s/^/static const char $*_[] = {/;s/$$/};\n/' && echo && echo "/*" && $(target)otool -vVt $*.t.o && echo "*/"; } >$@ && rm -f $*.t.o
+	file=($$($(target)otool -l $*.t.o | sed -e 'x; /^1/ { x; /^ *filesize / { s/^.* //; p; }; /^ *fileoff / { s/^.* //; p; }; x; }; x; /^ *cmd LC_SEGMENT$$/ { s/.*/1/; x; }; d;')); { od -t x1 -j $${file[0]} -N $${file[1]} $*.t.o | sed -e 's/^[^ ]*//' | tr $$'\n' ' ' | sed -e 's/  */ /g;s/^ *//;s/ $$//;s/ /,/g;s/\([^,][^,]\)/0x\1/g' | sed -e 's/^/static const char $*_[] = {/;s/$$/};\n/' && echo && echo "/*" && $(target)otool -vVt $*.t.o && echo "*/"; } >$@ && rm -f $*.t.o
 
 include ObjectiveC.mk