<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Soul Of Free Loop &#187; 动态库</title>
	<atom:link href="https://zohead.com/archives/tag/dynamic-library/feed" rel="self" type="application/rss+xml" />
	<link>https://zohead.com</link>
	<description>Uranus Zhou&#039;s Blog</description>
	<lastBuildDate>Sat, 19 Jul 2025 15:42:46 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.8</generator>
	<item>
		<title>Android x86对native ARM的支持</title>
		<link>https://zohead.com/archives/android-x86-arm-binary/</link>
		<comments>https://zohead.com/archives/android-x86-arm-binary/#comments</comments>
		<pubDate>Wed, 05 Dec 2012 17:20:37 +0000</pubDate>
		<dc:creator><![CDATA[Uranus Zhou]]></dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[binary translator]]></category>
		<category><![CDATA[Intel]]></category>
		<category><![CDATA[K800]]></category>
		<category><![CDATA[Medfield]]></category>
		<category><![CDATA[x86]]></category>
		<category><![CDATA[动态库]]></category>
		<category><![CDATA[原生]]></category>
		<category><![CDATA[手机]]></category>
		<category><![CDATA[联想]]></category>

		<guid isPermaLink="false">http://zohead.com/?p=352</guid>
		<description><![CDATA[本文同步自（最佳显示效果请点击）：https://zohead.com/archives/android-x86-arm-binary/ 之前入手联想 K800 这款使用 Intel x86 CPU 的手机时考虑过一个问题，就是 Android x86 对于已有的 Android 程序的兼容问题问题，特别是对于一些使用了 native ARM 代码的程序（以游戏居多），因为不可能原来所有的程序都可以及时更新来支持 x86 的 Android 手机（本来就很小众）。在我的想法中，Intel x86 环境下应该不可能直接运行 native 的 ARM 二进制代码（虚拟机那种不考虑），不过考虑到平时 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>本文同步自（最佳显示效果请点击）：<a href="https://zohead.com/archives/android-x86-arm-binary/" target="_blank">https://zohead.com/archives/android-x86-arm-binary/</a></p>
<p>之前入手联想 K800 这款使用 Intel x86 CPU 的手机时考虑过一个问题，就是 Android x86 对于已有的 Android 程序的兼容问题问题，特别是对于一些使用了 native ARM 代码的程序（以游戏居多），因为不可能原来所有的程序都可以及时更新来支持 x86 的 Android 手机（本来就很小众）。在我的想法中，Intel x86 环境下应该不可能直接运行 native 的 ARM 二进制代码（虚拟机那种不考虑），不过考虑到平时玩使用 native ARM 代码的游戏也不多，就没有在意。</p>
<p>我们先来看一个典型的使用了 native ARM library 的 Android 程序：《Bejeweled 2》，也就是大家在电脑上很熟悉的《宝石迷阵2》游戏的 Android 版本，查看 apk 安装文件里的内容，可以明显发现其使用了 ARM EABI 的动态库：</p>
<p><a href="http://zohead.com/wp-content/uploads/apk-native-arm.jpg" target="_blank"><img class="alignnone" title="使用 native ARM 代码的 Android 程序" src="http://zohead.com/wp-content/uploads/apk-native-arm.jpg" alt="使用 native ARM 代码的 Android 程序" width="371" height="213" /></a></p>
<p>但我在 K800 上安装此游戏，完全可以正常运行并使用，只是似乎没有在 ARM Android 手机上运行的那么顺畅。</p>
<p>这就比较疑惑了，接下来那就进一步验证一下，将之前静态编译的一个 ARM 可执行程序拷到手机，在终端中运行，竟然也可以正常运行，我们看看这个 ARM 可执行程序的格式：</p>
<pre class="brush: bash; title: ARM 可执行程序的格式; notranslate">
[root@fedora ~]# file /mnt/iptables
/mnt/iptables: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.14, statically linked, for GNU/Linux 2.6.14, stripped
</pre>
<p>经过一番搜寻之后，发现原来 Android x86 4.0 版本之后已经开始支持对 native ARM 的仿真，这对于之前用处似乎一直不是很大的 Android x86 来说绝对可以算是相当大的进步。</p>
<p>联想 K800 使用的 CPU 是 Intel Atom Z2460，基于 Intel Medfield 平台，尽管 Z2460 是一款使用 x86 指令集的 CPU，但可以兼容运行大部分带有 native ARM 代码的应用，关键就是靠 Intel 并未公开发表的技术 ARM binary code translator，而且 binary translator 对于应用程序来说是透明的，一般不需要做任何特殊的改动。</p>
<p>在 Android x86 上 Google 修改了 dalvik 虚拟机的加载 native code 的函数（修改 libdvm，增加 libdvm_houdini.so），通过 Intel ARM to Atom binary translator 实现 JNI 调用。Android x86 中引入了 libhoudini.so 来做这件事情，通过查看 K800 的根文件系统，我们可以看到除了 /system/lib 下的标准的 x86 的动态库文件之外，新增了 /system/lib/libhoudini.so 库，另外 /system/lib/arm 目录下还有很多 ARM 版本的库文件。</p>
<p>下面是我在 K800 上运行一个 native ARM 程序时的进程输出：</p>
<pre class="brush: bash; title: ps; notranslate">
root      9754  1     79064  3888  c136b03f 40060345 S /system/bin/houdini
root      10365 8204  1468   496   00000000 b76dca06 R ps
</pre>
<p>上面看到的 /system/bin/houdini 进程即为在 Android x86 上运行的 native ARM 程序的表现形式。</p>
<p>从现在在 K800 手机上实际的测试情况来看，在 K800 上运行使用 native ARM 的 Android 似乎都还比较顺畅，像愤怒的小鸟就可以很顺畅的运行，这和现在 K800 用的 Android 4.0.4 ROM 也有关系，相对于不支持 native ARM 的 Android 2.3.7，游戏的兼容性是有相当大的改善的。另外很有可能 Intel Medfield 平台硬件上就有对 ARM binary translator 的加速功能。</p>
<p>当然这种二进制的转换必然会有性能上的损失，无法和 x86 原生程序相比，因此越来越多的 Android 程序也开始集成了 x86 版本的程序和库文件，来看看最新版本的水果忍者 apk 安装程序中的库文件列表，就可以看到 x86 版本：</p>
<p><a href="http://zohead.com/wp-content/uploads/apk-multi-libs.jpg" target="_blank"><img class="alignnone" title="原生支持 x86 库的 Android 程序" src="http://zohead.com/wp-content/uploads/apk-multi-libs.jpg" alt="原生支持 x86 库的 Android 程序" width="300" height="257" /></a></p>
<p>有关 Android x86 运行 native ARM 程序的介绍：</p>
<p><a href="http://www.anandtech.com/show/5770/lava-xolo-x900-review-the-first-intel-medfield-phone/3" target="_blank">http://www.anandtech.com/show/5770/lava-xolo-x900-review-the-first-intel-medfield-phone/3</a></p>
<p>Android x86 下运行环境的搭建：</p>
<p><a href="http://www.buildroid.org/blog/?p=198" target="_blank">http://www.buildroid.org/blog/?p=198</a></p>
]]></content:encoded>
			<wfw:commentRss>https://zohead.com/archives/android-x86-arm-binary/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
