<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>compiler-optimizations &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/compiler-optimizations/</link>
	<description>Feed of posts on WordPress.com tagged "compiler-optimizations"</description>
	<pubDate>Tue, 21 May 2013 13:30:08 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[One Touch Optimize Android Apk App]]></title>
<link>http://freeapkforandroid.wordpress.com/2012/11/03/one-touch-optimize-android-apk-app-2/</link>
<pubDate>Sat, 03 Nov 2012 12:56:19 +0000</pubDate>
<dc:creator>Bams Winarso</dc:creator>
<guid>http://freeapkforandroid.wordpress.com/2012/11/03/one-touch-optimize-android-apk-app-2/</guid>
<description><![CDATA[One Touch Optimize Android Apk App One Touch to Optimize Quickly! One Touch Optimize is a cell phone]]></description>
<content:encoded><![CDATA[<p>One Touch Optimize Android Apk App<br />
One Touch to Optimize Quickly!<br />
One Touch Optimize is a cell phone tool which can help you to optimize the phone system effectively by ending unnecessary processes and clearing cache data generated in the process to achieve system optimization function. You can&#8230;</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[One Touch Optimize Android Apk App]]></title>
<link>http://freeapkforandroid.wordpress.com/2012/11/03/one-touch-optimize-android-apk-app/</link>
<pubDate>Sat, 03 Nov 2012 12:56:10 +0000</pubDate>
<dc:creator>Bams Winarso</dc:creator>
<guid>http://freeapkforandroid.wordpress.com/2012/11/03/one-touch-optimize-android-apk-app/</guid>
<description><![CDATA[One Touch Optimize Android Apk App One Touch to Optimize Quickly! One Touch Optimize is a cell phone]]></description>
<content:encoded><![CDATA[<p>One Touch Optimize Android Apk App<br />
One Touch to Optimize Quickly!<br />
One Touch Optimize is a cell phone tool which can help you to optimize the phone system effectively by ending unnecessary processes and clearing cache data generated in the process to achieve system optimization function. You can&#8230;</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[DeCV -- a decompiler for Code Virtualizer by Oreans]]></title>
<link>http://gdtr.wordpress.com/2012/10/03/decv-a-decompiler-for-code-virtualizer-by-oreans/</link>
<pubDate>Wed, 03 Oct 2012 15:49:22 +0000</pubDate>
<dc:creator>p_k</dc:creator>
<guid>http://gdtr.wordpress.com/2012/10/03/decv-a-decompiler-for-code-virtualizer-by-oreans/</guid>
<description><![CDATA[Code Virtualizer is a software protection solution using heavy obfuscation. Citing the author&#8217;]]></description>
<content:encoded><![CDATA[<p style="text-align:left;">Code Virtualizer is a software protection solution using heavy obfuscation. Citing the author&#8217;s website [5]:</p>
<p style="text-align:left;"><em>Code Virtualizer is a powerful code-obfuscation system that helps developers protect their sensitive code areas against Reverse Engineering while requiring minimum system resources.</em></p>
<p style="text-align:left;"><em>Code Virtualizer can generate multiple types of virtual machines with a different instruction set for each one. This means that a specific block of Intel x86 instructions can be converted into different instruction set for each</em> <em>machine, preventing an attacker from recognizing any generated virtual opcode after the transformation from x86 instructions.</em></p>
<p style="text-align:center;"><a href="http://gdtr.files.wordpress.com/2012/10/obfu1.png"><img class="aligncenter size-full wp-image-567" title="obfu" src="http://gdtr.files.wordpress.com/2012/10/obfu1.png?w=600&#038;h=351" alt="" width="600" height="351" /></a></p>
<p style="text-align:left;">This post describes DeCV &#8212; a decompiler for Code Virtualizer.</p>
<p style="text-align:left;"><!--more--></p>
<h1 style="text-align:center;"></h1>
<h1 style="text-align:center;">DeCV</h1>
<p>&#160;</p>
<p>This is a high-level description. For a detailed discussion of CV internals see &#8220;Inside Code Virtualizer&#8221; by scherzo [6].</p>
<p>CV obfuscates the original x86 code by translating it to a custom stack oriented language [1]. CVL (CV&#8217;s language) has around 150 instructions but a lot of them are byte/word/dword variants of the same operation.</p>
<p>For example, consider this simple x86 code:</p>
<blockquote><p>xor eax, 1111h</p></blockquote>
<p>Its equivalent in CVL is:</p>
<blockquote><p>load ptr eax<br />
store addr<br />
load dword [addr]<br />
load dword 0x1111L<br />
xor dword<br />
store dword eflags<br />
load ptr eax<br />
store addr<br />
store dword [addr]</p></blockquote>
<p>To emulate x86 registers, CVL uses a table. Each dword in this table corresponds to one x86 register, so &#8216;<em>load ptr &#60;reg&#62;</em>&#8216; places a pointer to a variable holding &#60;reg&#8217;s&#62; value on the stack.</p>
<p>&#8216;<em>store addr</em>&#8216; pops a value from the stack and places in a &#8216;built in&#8217; variable called &#8216;addr&#8217;.</p>
<p>&#8216;<em>load dword [addr]</em>&#8216; pushes a dword pointed by &#8216;addr&#8217; on the stack.</p>
<p>The cumulative effect of the three instructions above is to push the value of eax on the stack.</p>
<p>Let&#8217;s emulate the rest of the code:</p>
<pre>Instruction         &#124; Stack
----------------------------
load dword 0x1111   &#124; eax
xor dword           &#124; eax, 0x1111
store dword eflags  &#124; eax ^ 0x1111, new_flags
load ptr eax        &#124; eax ^ 0x1111
store addr          &#124; eax ^ 0x1111, ptr eax
store dword [addr]  &#124; eax ^ 0x1111
--                  &#124; -</pre>
<p>Notice that &#8216;xor&#8217; pushes two values on the stack: the xor&#8217;s result and the new value of EFLAGS register.</p>
<p>In order to recover the original x86 code, it&#8217;s sufficient to emulate CVL&#8217;s execution using symbolic registers instead of concrete values and emit x86 assembly on instructions like &#8216;store dword [addr]&#8216;. For example, if &#8216;addr&#8217; equals &#8216;eax&#8217; and there is &#8216;eax XOR ebx&#8217; on top of the stack, the instruction to emit is &#8216;xor eax, ebx&#8217;. This is tree munching is disguise btw <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  [2].</p>
<p>DeCV does not implement full x86 recovery. I included an example of how this should be implemented, if anyone is interested &#8212; recover_x86.py reads a short CVL snippet and translates it back to assembly using the method described above.</p>
<p>CVL -&#62; x86 translation is the easiest part of the CV puzzle, the real problem is to extract the CVL given just an obfuscated binary.</p>
<h1 style="text-align:center;"><strong>Deobfuscation</strong></h1>
<p>Each protected binary contains a virtual machine capable of executing a CVL program &#8216;compiled&#8217; to bytecode. The interpreter doesn&#8217;t differ from other virtual machines:</p>
<blockquote><p>dispatch: ;(deobfuscated and simplified version)<br />
lodsb<br />
movzx eax, al<br />
jmp dword ptr [edi+eax*4]</p></blockquote>
<p>&#8216;esi&#8217; points to the bytecode, &#8216;edi&#8217; points to a table of handlers for different virtual instructions. For example, the &#8216;load ptr &#60;reg&#62;&#8217; instruction is implemented as:</p>
<blockquote><p>lodsb<br />
movzx eax, al<br />
lea eax, [edi+eax*4]<br />
push eax</p></blockquote>
<p>Byte pointed by &#8216;esi&#8217; is the register&#8217;s offset in the register structure pointed by &#8216;edi&#8217;.</p>
<p>The decompilation process seems obvious &#8212; just take the bytecode, analyze which handlers are executed, get the CVL and then translate it back to x86. This indeed works, assuming we can tell which handlers implement which CVL instructions. There are two problems:</p>
<p>- all handlers are obfuscated to the point where it&#8217;s not possible to identify their semantics,<br />
- handlers&#8217; parameters and the bytecode itself are encrypted with a dynamic key (ebx), so even after all handlers are identified, their parameters are still unknown.</p>
<p>In order to deobfuscate handlers, DeCV performs a set of compiler optimizations on them, like constant propagation and folding, dead code elimination, peephole optimizations, etc. When the handler&#8217;s implementation stops changing (a fixpoint is reached), we can compare it to a set of original handlers extracted from the CV protector binary. Finding a match is equivalent to identifying the CVL instruction implemented by a handler. This is the same method as described in [3]. In [4] Rolf applies compiler opts during a different stage (CVL-&#62;x86).</p>
<p>There&#8217;s one problem with this approach that isn&#8217;t mentioned anywhere &#8212; CV can obfuscate the handlers&#8217; control flow, by inserting random conditional jumps in its body. Fortunately, this obfuscation isn&#8217;t very complex &#8212; there&#8217;s only one correct path through the handler and it doesn&#8217;t change between executions. This means that the conditions tested during branching do not depend on variables, but on constants (in other words, they evaluate to constants). It should be possible to simply emulate all code up to the branch point to decide which path should be taken. It turns out it&#8217;s not that simple. Consider this code:</p>
<blockquote><p>xor eax, ebx<br />
xor ebx, eax<br />
xor eax, ebx</p></blockquote>
<p>or the xor-swap trick. The above sequence is equivalent to &#8216;xchg eax, ebx&#8217;.</p>
<p>My first attempt at emulation was to have three types of values: symbolic registers, concrete constants and unknowns. The above sequence is problematic, because if eax=const, ebx=unknown, then eax turns into an unknown after the first xor and there&#8217;s no way to recover it. Notice that we can&#8217;t just set all registers to concrete values at the beginning, because then we would miss real conditional jumps (there are handlers that have &#8216;real&#8217; branches in them) and we need to identify branches that really do depend conditionally on input.</p>
<p>DeCV solves this problem by applying optimizations to code before a branch and then emulating the result. This way all nasty corner cases like the swap trick are removed and it&#8217;s possible to compute the conditions (by simple emulation) and decide jumps. After all fake branches are removed, the deobfuscation process can proceed like in the branchless case. Note that only a single path in the control flow graph should be followed &#8212; it&#8217;s not necessary to deobfuscate all of the CFG nodes.</p>
<p>With all handlers deobfuscated it&#8217;s easy to extract their parameter decryption procedures. Every handler that requires a parameter decrypts it using a unique function consisting of a combination of add/sub/xor instructions. After collecting all of these decryption functions it&#8217;s possible to decrypt the whole CVL program and all parameters used by handlers. Having all of this information is equal to decompiling the obfuscated CVL program.</p>
<h1 style="text-align:center;">Usage notes</h1>
<p>DeCV will automatically perform all tasks including:<br />
- locating the handlers table,<br />
- locating the main dispatcher,<br />
- collecting the handlers&#8217; bodies split with unconditional jumps.</p>
<p>The decompilation takes few seconds max., depending on how complicated the VM is. The output is printed in IDA&#8217;s output window. DeCV was tested with IDA 6.2 and IDAPython 1.5.3. Example output:</p>
<blockquote><p>vms found: 1<br />
0x40740e<br />
vm: 0<br />
0&#215;00000000 000[07] load ptr eflags<br />
0&#215;00000002 001 store addr<br />
0&#215;00000003 018 store dword [addr]<br />
(&#8230;)</p></blockquote>
<p>0x40740e is the VM&#8217;s entry point. First column is the instructions offset (in bytecode), second is the handler&#8217;s id (see clean_handlers dir), values in brackets (like [07]) are parameters.</p>
<p>DeCV was well tested on small, synthetic binaries protected with Code Virtualizer 1.3.8.</p>
<p>There are some bugs in IDA that might require manual intervention during the deobfuscation process &#8212; see the README.</p>
<p>Sources on <a href="https://github.com/pakt/decv">github</a>. Typical decompilation output on <a href="http://pastebin.com/etzbaUhB">pastebin</a>.</p>
<p style="text-align:center;"><strong>References</strong></p>
<p>1. <a href="http://en.wikipedia.org/wiki/Stack-oriented_programming_language">http://en.wikipedia.org/wiki/Stack-oriented_programming_language</a><br />
2. <a href="http://www.eng.utah.edu/~cs5470/schedule/Lec21.pdf">http://www.eng.utah.edu/~cs5470/schedule/Lec21.pdf</a><br />
3. <a href="http://www.woodmann.com/forum/entry.php?115-Fighting-Oreans-VM-(code-virtualizer-flavour)">http://www.woodmann.com/forum/entry.php?115-Fighting-Oreans-VM-(code-virtualizer-flavour)</a><br />
4. <a href="http://static.usenix.org/event/woot09/tech/full_papers/rolles.pdf">http://static.usenix.org/event/woot09/tech/full_papers/rolles.pdf</a><br />
5. <a href="http://oreans.com/codevirtualizer.php">http://oreans.com/codevirtualizer.php</a><br />
6. <a href="http://tuts4you.com/download.php?view.2640">http://tuts4you.com/download.php?view.2640</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[A Few Ways To Get Better GWT Compile Times]]></title>
<link>http://supplychaintechnology.wordpress.com/2010/06/04/gwt_compile_times/</link>
<pubDate>Fri, 04 Jun 2010 18:43:34 +0000</pubDate>
<dc:creator>Jim</dc:creator>
<guid>http://supplychaintechnology.wordpress.com/2010/06/04/gwt_compile_times/</guid>
<description><![CDATA[We have dozens of GWT modules here at GT Nexus.  To many, that statement will raise red flags and pe]]></description>
<content:encoded><![CDATA[<p><a href="http://supplychaintechnology.files.wordpress.com/2010/06/istock_000008691068xsmall.jpg"><img class="alignleft size-thumbnail wp-image-701" title="iStock_000008691068XSmall" src="http://supplychaintechnology.files.wordpress.com/2010/06/istock_000008691068xsmall.jpg?w=150&#038;h=99" alt="" width="150" height="99" /></a>We have dozens of GWT modules here at GT Nexus.  To many, that statement will raise red flags and perhaps accusations of questionable architecture, but the fact is that we have a very large product suite and implementing products in their own modules is working very well for us.</p>
<p>The downside of this design is that compiling all our GWT modules takes a very, very long time, even on modern silicon (and germanium, etc.).</p>
<p>The Google Web Toolkit team is aware of how long compiles take, however their emphasis is on enhancing the user experience; if that comes at the expense of a longer compile for developers, that&#8217;s OK with them. For instance, they claim that &#8220;an extra 30 seconds of compiler time is worth it to get a 5% improvement in code size.&#8221;  I appreciate that perspective, but I also want faster compiles!</p>
<p>To start, there are two things that you can do with a modern multi-core machine to speed up your compiles;<!--more--> I do not have these in my notes from Google IO 2010, but they are well-advertised in the GWT community. Namely:</p>
<ul>
<li>If you are using Ant, use the &#60;parallel&#62; tag to compile modules in parallel.  This can yield phenominal results.</li>
<li>Use the GWT -localWorkers argument to use multiple threads during compilation.</li>
</ul>
<p>In addition, the GWT team recommends:</p>
<ul>
<li>Use two module definitions for each module; for instance, &#8220;MyProject.gwt.xml&#8221; and &#8220;MyProjectDev.gwt.xml,&#8221; and tune the &#8220;Dev&#8221; version to compile with Pretty formatting, for one browser (if possible), and other common methods for speeding up the compiler</li>
<li>Use the -draftCompile  compiler flag to avoid complicated optimizations (for development)</li>
<li>Use pretty output for development</li>
</ul>
<p>Their non-compiler-related suggestions are:</p>
<ul>
<li>Use better hardware.</li>
<li>Use RAID/SSD</li>
<li>Use <tt>-server</tt> JVM flag and more memory</li>
</ul>
<p>In addition, there are capabilities in the GWT compiler that have not yet been exposed or well documented.  For instance, there is support for parallelized and clustered builds by using the precompiler and certain &#8220;CompilePerms.&#8221;  See the Google IO 2010 presentation linked to below for more information on this option.</p>
<p>Beyond that, the old standby is to identify the modules that you are not interested in compiling and comment them out.  That is perhaps the most effective tool we currently have in our environment to speed up our compiles, short of not compiling the GWT modules at all.</p>
<p>The GWT compiler often works some wonderful magic, but that magic comes at the price of slow compile times.  We have had varying success with these techniques, but the GWT team appears to be aware of them and will hopefully toss us a bone in the future to help developers become even more productive with their toolkit.</p>
<p>Links:</p>
<ul>
<li>&#8220;<a href="http://code.google.com/events/io/2010/sessions/faster-apps-faster-gwt-compiler.html" target="_blank">Making Faster Apps Faster</a>&#8221; presentation at Google IO 2010</li>
<li><a href="http://lifeandcode.net/2009/07/stacking-gwt-1-6-workers-with-ant-parallel-for-super-fast-builds/" target="_blank">Using Ant parallel and multiple local threads</a> on lifeandcode.net</li>
<li><a href="http://jectbd.com/?p=313" target="_blank">Lombardi&#8217;s take on parallel and local threads</a></li>
<li><a href="http://www.summa-tech.com/blog/2011/02/22/structuring-gwt-modules-for-large-applications" target="_blank">Ben Northrup&#8217;s Article on Structuring GWT Applications</a> (Added 2/2011)</li>
</ul>
]]></content:encoded>
</item>

</channel>
</rss>
