{"id":4682,"date":"2021-09-03T10:32:25","date_gmt":"2021-09-03T02:32:25","guid":{"rendered":"http:\/\/122.152.205.50\/wordpress\/?p=4682"},"modified":"2021-09-03T10:32:25","modified_gmt":"2021-09-03T02:32:25","slug":"%e5%b0%9d%e8%af%95%e4%bf%ae%e6%94%b9mmap%e5%87%bd%e6%95%b0dump-dex%ef%bc%88%e5%a4%b1%e8%b4%a5%e5%91%8a%e7%bb%88%ef%bc%89","status":"publish","type":"post","link":"http:\/\/xinyiworld.top\/wordpress_it\/?p=4682","title":{"rendered":"\u5c1d\u8bd5\u4fee\u6539mmap\u51fd\u6570dump dex\uff08\u5931\u8d25\u544a\u7ec8\uff09"},"content":{"rendered":"<p>\u5728<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.jianshu.com\/p\/feecde9a9aee\">https:\/\/www.jianshu.com\/p\/feecde9a9aee<\/a>\u8fd9\u7bc7\u6587\u7ae0\u91cc\uff0c\u6211\u8bb2\u5230\u4e86\u5982\u4f55\u6210\u529fdump\u51fa360\u7684dex\u65b9\u6cd5\uff0c\u4f46\u662f\u6ca1\u6709dump\u51fa\u58f3\u5185\u771f\u6b63apk\u7684dex\u6587\u4ef6\u3002\u7f51\u4e0a\u6709\u4e00\u79cd\u8bf4\u6cd5\u662f\u4ecemmap\u51fd\u6570\u5165\u624b\uff0c\u6211\u5c1d\u8bd5\u4e86\u4e00\u4e0b\uff0c\u4f46\u662f\u5931\u8d25\u4e86\uff0c\u8fc7\u7a0b\u8bb0\u5f55\u4e00\u4e0b\uff1a<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_16 counter-hierarchy counter-decimal ez-toc-grey\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" style=\"display: none;\"><i class=\"ez-toc-glyphicon ez-toc-icon-toggle\"><\/i><\/a><\/span><\/div>\n<nav><ul class=\"ez-toc-list ez-toc-list-level-1\"><li class=\"ez-toc-page-1 ez-toc-heading-level-1\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4682\/#mmapcpp%E6%96%87%E4%BB%B6\" title=\"mmap.cpp\u6587\u4ef6\">mmap.cpp\u6587\u4ef6<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-1\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4682\/#ALOGE%E4%BD%BF%E7%94%A8%E4%B8%8D%E4%BA%86\" title=\"ALOGE\u4f7f\u7528\u4e0d\u4e86\">ALOGE\u4f7f\u7528\u4e0d\u4e86<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-1\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4682\/#mmap%E5%87%BD%E6%95%B0%E7%A0%94%E7%A9%B6\" title=\"mmap\u51fd\u6570\u7814\u7a76\">mmap\u51fd\u6570\u7814\u7a76<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-1\"><a class=\"ez-toc-link ez-toc-heading-4\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4682\/#memcmp%E5%87%BD%E6%95%B0%E7%A0%94%E7%A9%B6\" title=\"memcmp\u51fd\u6570\u7814\u7a76\">memcmp\u51fd\u6570\u7814\u7a76<\/a><ul class=\"ez-toc-list-level-2\"><li class=\"ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-5\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4682\/#%E9%87%8D%E6%96%B0%E7%A0%94%E7%A9%B6bioniclibcAndroidmk%E5%8F%91%E7%8E%B0%E7%AB%AF%E5%80%AA\" title=\"\u91cd\u65b0\u7814\u7a76bionic\/libc\/Android.mk\u53d1\u73b0\u7aef\u502a\">\u91cd\u65b0\u7814\u7a76bionic\/libc\/Android.mk\u53d1\u73b0\u7aef\u502a<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-6\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4682\/#Android%E6%BA%90%E7%A0%81%E4%B8%8ENDK%E7%9A%84%E5%85%B3%E7%B3%BB\" title=\"Android\u6e90\u7801\u4e0eNDK\u7684\u5173\u7cfb\">Android\u6e90\u7801\u4e0eNDK\u7684\u5173\u7cfb<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"mmapcpp%E6%96%87%E4%BB%B6\"><\/span>mmap.cpp\u6587\u4ef6<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>\u6240\u5728\u76ee\u5f55\uff1abionic\/libc\/bionic\/mmap.cpp<br \/>\n\u7f16\u8bd1\u76ee\u5f55\uff1abionic\/libc\/<\/p>\n<h1><span class=\"ez-toc-section\" id=\"ALOGE%E4%BD%BF%E7%94%A8%E4%B8%8D%E4%BA%86\"><\/span>ALOGE\u4f7f\u7528\u4e0d\u4e86<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>\u5728DvmDex.cpp\u91cc\uff0c\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528ALOGE\u6253\u5370android\u65e5\u5fd7\uff0c\u4f46\u662f\u5230\u4e86mmap.cpp\u5374\u6ca1\u6cd5\u76f4\u63a5\u4f7f\u7528\u3002\u7f51\u4e0a\u767e\u5ea6\u4e86\u5404\u79cd\u529e\u6cd5\u90fd\u4e0d\u884c\uff0c\u7f16\u8bd1\u867d\u7136\u901a\u8fc7\uff0c\u7cfb\u7edf\u8dd1\u4e0d\u8d77\u6765\uff0c\u5927\u6982\u662f<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/blog.csdn.net\/flydream0\/article\/details\/7344730\">https:\/\/blog.csdn.net\/flydream0\/article\/details\/7344730<\/a>\u91cc\u7684\u65b9\u6848\u7684\u7efc\u5408\uff0c\u6709\u7684\u662f\u6559\u600e\u4e48\u5728JNI\u7684cpp\u91cc\u5982\u4f55\u6253\u5370android\u65e5\u5fd7\uff0c\u6709\u7684\u867d\u7136\u662f\u6559\u6e90\u7801\u91cccpp\u5982\u4f55\u6253\u5370android\u65e5\u5fd7\u3002\u53ef\u80fd\u662f\u4e0d\u540c\u7684\u6a21\u5757\u4fee\u6539Android.mk\u7684\u65b9\u5f0f\u4e0d\u4e00\u6837\u3002<\/p>\n<p>\u6700\u7ec8\uff0c\u6211\u53c2\u7167DvmDex.cpp\u6240\u5728\u6a21\u5757\u7684Android.mk\uff0c\u4f9d\u846b\u82a6\u753b\u74e2\u627e\u5230\u4e86\u7b54\u6848\uff1a<\/p>\n<blockquote><p>\n  <strong>bionic\/libc\/Android.mk\u7684 libc_common.a\u5904\u589e\u52a0libcutils\u548cliblog\u4f9d\u8d56\uff0c\u5728mmap.cpp\u91cc\u589e\u52a0#include &lt;cutils\/log.h>\u5373\u53ef\u3002<\/strong>\n<\/p><\/blockquote>\n<p><img src=\"https:\/\/upload-images.jianshu.io\/upload_images\/18328858-037db738b01cc95a.png?imageMogr2\/auto-orient\/strip%7CimageView2\/2\/w\/1240\" alt=\"image.png\" \/><\/p>\n<ul>\n<li>\u4f9d\u846b\u82a6\u753b\u74e2\u7684\u8fc7\u7a0b\uff1a<br \/>\n\u9996\u5148\u770bDvmDex.cpp\u7684include\u7684.h\u6587\u4ef6\uff0c<\/li>\n<\/ul>\n<pre><code class=\"language-c line-numbers\">#include \"Dalvik.h\"\n#include &lt;sys\/mman.h&gt;\n<\/code><\/pre>\n<p>\u5148\u53bbDvmDex.cpp\u7684\u5f53\u524d\u76ee\u5f55\u4e0b\u627e\u8fd9\u4e24\u4e2a\u6587\u4ef6\uff0c\u53d1\u73b0Dalvik.h\u6709\u4e00\u4e2a<\/p>\n<pre><code class=\"language-c line-numbers\">#include \"Common.h\"\n<\/code><\/pre>\n<p>\u5728Common.h\u91cc\u53d1\u73b0<\/p>\n<pre><code class=\"language-c line-numbers\">#include \"cutils\/log.h\"\n<\/code><\/pre>\n<p>\u7136\u800c\uff0c\u5728\u5f53\u524d\u76ee\u5f55\u53d1\u73b0\u627e\u4e0d\u5230cutils\/log.h\u8fd9\u4e2a\u6587\u4ef6\uff0c\u4e3a\u4f55\uff1f\uff08\u5173\u4e8e\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u7814\u7a76\u53d1\u73b0\u8981\u5355\u72ec\u6210\u6587\uff0c\u60f3\u8981\u77e5\u9053libxxx.so xxx.a\u8fd9\u4e9b\u5171\u4eab\u5e93\u3001\u9759\u6001\u5e93\u90fd\u662f\u600e\u4e48\u751f\u6210\u7684\uff0c\u8bf7\u8f6c\u81f3\uff1a\uff09<br \/>\n\u770b\u5148\u53bbDvmDex.cpp\u7f16\u8bd1\u6a21\u5757\u7684Android.mk\u6587\u4ef6\uff1a<br \/>\n<img src=\"https:\/\/upload-images.jianshu.io\/upload_images\/18328858-18e9f1296302050e.png?imageMogr2\/auto-orient\/strip%7CimageView2\/2\/w\/1240\" alt=\"image.png\" \/><br \/>\n\u7136\u540e\u6587\u7ae0\u5f00\u5934\uff0c\u6211\u7167\u6837\u5c06libcutils\u3001liblog\u4e24\u4e2a<strong>\u9759\u6001\u5e93<\/strong>\u6dfb\u52a0\u5230bionic\/libc\/Android.mk\u4e2d\u3002<br \/>\n\u7f51\u4e0a\u7684\u5f88\u591a\u7684\u505a\u6cd5\u90fd\u662f\u5c06libcutils\u6dfb\u52a0\u5230LOCAL_SHARED_LIBRARIES\u7684\u540e\u9762\uff0c\u628a\u9759\u6001\u5e93\u6dfb\u52a0\u5230\u5171\u4eab\u5e93\u53d8\u91cf\u91cc\uff0c\u6211\u4e0d\u77e5\u9053\u7f16\u8bd1\u4e3a\u5565\u8fd8\u6210\u529f\u4e86\uff0c\u4f46\u662f\u7cfb\u7edf\u8dd1\u4e0d\u8d77\u6765\uff08Nexus\u51fa\u73b0Google\u9875\u97622\u6b21\u540e\u5361\u5728\u611f\u53f9\u53f7\u673a\u5668\u4eba\u9875\u9762\uff09\u3002<\/p>\n<p>\u6709\u4e86ALOG\uff0c\u5c31\u7b49\u4e8e\u6709\u4e86\u773c\u775b\uff0c\u7b49\u4e8e\u6211\u4eec\u79bb\u5e95\u5c42\u53c8\u66f4\u8fdb\u4e86\u4e00\u6b65\u3002<\/p>\n<h1><span class=\"ez-toc-section\" id=\"mmap%E5%87%BD%E6%95%B0%E7%A0%94%E7%A9%B6\"><\/span>mmap\u51fd\u6570\u7814\u7a76<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>void* mmap(void* addr, size_t size, int prot, int flags, int fd, off_t offset)<br \/>\n\u6211\u7684\u76ee\u7684\u8fd8\u662f\u5e0c\u671b\u901a\u8fc7addr\u548csize\u6765dump\u51fadex\u7684\u5185\u5b58\uff0c\u4f46\u662fmmap\u4f1a\u88ab\u9891\u7e41\u7684\u8c03\u7528\u5230\u3002<br \/>\n\u6211\u5728<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.jianshu.com\/p\/feecde9a9aee\">https:\/\/www.jianshu.com\/p\/feecde9a9aee<\/a>\u8fd9\u7bc7\u6587\u7ae0\u63d0\u5230\u8fc7\uff0cDvmDex.cpp\u6587\u4ef6\u4e2d\u7684dvmDexFileOpenPartial\u7684\u8c03\u7528\u65f6\u673a\u95ee\u9898\u6211\u5df2\u7ecf\u89e3\u51b3\u4e86\u3002\u4f46\u662fmmap\u51fd\u6570\uff0c\u6211\u5982\u4f55\u786e\u5b9a\u662f360\u58f3\u5185\u90e8\u7684\u5e94\u7528\u7684dex\u52a0\u8f7d\u65f6\u8c03\u7528\u4e86\u5462\uff1f\u6211\u60f3\u5230\u4e86\u51e0\u79cd\u89e3\u51b3\u65b9\u6848\uff1a<br \/>\n1\uff09\u5229\u7528Dex\u6587\u4ef6\u7ed3\u6784<br \/>\n<img src=\"https:\/\/upload-images.jianshu.io\/upload_images\/18328858-cc6dbad15e620812.png?imageMogr2\/auto-orient\/strip%7CimageView2\/2\/w\/1240\" alt=\"image.png\" \/><br \/>\n\u4e86\u89e3Dex\u6587\u4ef6\u7ed3\u6784\u7684\u90fd\u77e5\u9053Dex\u6587\u4ef6\u5f00\u5934\u76847\u4e2a\u5b57\u8282\u59cb\u7ec8\u662f\u56fa\u5b9a\u7684\uff1a64 65 78 0A 30 33 35\uff0c\u5bf9\u5e94\u7684\u5b57\u7b26\u4e32\u662fdex.035\u3002\u90a3\u4e48\u662f\u5426\u53ef\u4ee5\u901a\u8fc7addr\u548csize\u6765\u5224\u65ad\u5462\uff1f<\/p>\n<p>\u6211\u64cd\u4f5c\u661f(result+x)\u5224\u65ad\u5b57\u8282\uff0c\u7f16\u8bd1\u76f4\u63a5\u62a5\u9519\u3002<strong>void\u661f\u6307\u9488\u4e0d\u80fd\u76f4\u63a5\u62ff\u6765\u8fd0\u7b97<\/strong><\/p>\n<p>\u6211\u5199\u4e86\u4e0b\u9762\u7684\u8fd9\u4e9b\u7684\u51e0\u884c\u4ee3\u7801\uff0c\u53d1\u73b0\u7cfb\u7edf\u8d77\u4e0d\u6765\uff0c\u51fa\u73b02\u6b21Google\u9875\u9762\u540e\u5361\u5728\u611f\u53f9\u53f7\u673a\u5668\u4eba\u9875\u9762\u3002<br \/>\n<img src=\"https:\/\/upload-images.jianshu.io\/upload_images\/18328858-5d78c349c4f0458c.png?imageMogr2\/auto-orient\/strip%7CimageView2\/2\/w\/1240\" alt=\"image.png\" \/><br \/>\n\u539f\u6765mmap\u51fd\u6570\u7684\u53c2\u6570void* addr\uff0caddr\u53ef\u80fd\u662f\u4efb\u610f\u7684\u7c7b\u578b\uff0c\u76f4\u63a5\u5f3a\u8f6c\u6210int\u661f\u80af\u5b9a\u4f1a\u62a5\u9519\u3002\u4f46\u662f\u6211\u53d1\u73b0void*\u53ef\u4ee5\u5f3a\u8f6c\u6210unsiged char *\uff0c<br \/>\n\u770b\u4e0emmap.cpp\u540c\u7ea7\u7684\u76ee\u5f55\u7684memcmp.c\u6587\u4ef6\uff0cgoogle\u5b98\u65b9\u5c31\u662f\u8fd9\u4e48\u5e72\u7684\u3002<br \/>\n<img src=\"https:\/\/upload-images.jianshu.io\/upload_images\/18328858-67ae2f8735ebf311.png?imageMogr2\/auto-orient\/strip%7CimageView2\/2\/w\/1240\" alt=\"image.png\" \/><\/p>\n<p>\u6240\u4ee5\u5bf9\u4ee3\u7801\u518d\u4e00\u6b21\u505a\u4e86\u4f18\u5316\uff1a<br \/>\n<img src=\"https:\/\/upload-images.jianshu.io\/upload_images\/18328858-e393401e77e26a64.png?imageMogr2\/auto-orient\/strip%7CimageView2\/2\/w\/1240\" alt=\"image.png\" \/><br \/>\n\u8fd9\u6b21\u662f\u5361\u5728android\u5b57\u6837\u9875\u9762\u3002<br \/>\n\u5c06\u4e0b\u9762\u8fd9\u884c\u4ee3\u7801\u6ce8\u91ca\u6389\uff0c\u7cfb\u7edf\u8d77\u6765\u4e86\u3002<\/p>\n<pre><code class=\"line-numbers\">\/\/ALOGE(\"CZLog mmap find dex035\");\n<\/code><\/pre>\n<p>\u4e3a\u4ec0\u4e48\u9650\u5236\u4e86\u6761\u4ef6\u4e4b\u540e\u6253Log\u53cd\u800c\u6253\u4e0d\u51fa\u6765\u5462\uff1f\u4e0d\u5149\u9650\u5236\u6761\u4ef6\uff0c\u5c31\u5728\u6761\u4ef6\u91cc\u8fdb\u884c\u53d8\u91cf\u7684\u8fd0\u7b97\uff0c\u81ea\u589e\u3001\u81ea\u51cf\u8fd0\u7b97\uff0c\u7cfb\u7edf\u4e5f\u4f1a\u8d77\u4e0d\u6765\u3002<\/p>\n<h1><span class=\"ez-toc-section\" id=\"memcmp%E5%87%BD%E6%95%B0%E7%A0%94%E7%A9%B6\"><\/span>memcmp\u51fd\u6570\u7814\u7a76<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>\u8fd9\u7bc7https:\/\/www.52pojie.cn\/thread-648311-1-1.html\u535a\u5ba2\u89e3\u91ca\u4e86360\u6ca1\u6709\u4f7f\u7528 \u7cfb\u7edf\u7684dvmDexFileOpenPartial\u51fd\u6570\uff0c\u800c\u662f\u6a21\u4eff\u4e86\u7cfb\u7edf\u7684\u89e3\u6790dex\u7684\u65b9\u6cd5\uff1aDexFile.c\u4e2d\u7684dexFileParse\u65b9\u6cd5\uff0c\u7136\u540e\u4f7f\u7528\u4e86memcmp\u51fd\u6570\uff08<strong>\u7cfb\u7edf\u65b9\u6cd5<\/strong>\uff0c\u6211\u4eec\u627e\u7684\u5c31\u662f\u7cfb\u7edf\u65b9\u6cd5\u3002\uff09\uff0c\u6240\u4ee5mmap\u884c\u4e0d\u901a\uff0c\u5c1d\u8bd5\u4fee\u6539\u8fd9\u4e2a\u51fd\u6570\u3002<br \/>\n\u5173\u4e8e\u535a\u5ba2\u91cc\u67092\u4e2a\u5e38\u91cf\uff1aDEX_OPT_MAGIC\u548cDEX_OPT_MAGIC_VERS\uff0c\u8bf7\u770b<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/blog.csdn.net\/yhtppp\/article\/details\/44829449?locationNum=12\">https:\/\/blog.csdn.net\/yhtppp\/article\/details\/44829449?locationNum=12<\/a>\uff0c\u4f4d\u4e8e\/dalvik\/libdex\/DexFile.h \u6587\u4ef6\u4e2d\u3002<\/p>\n<p>memcmp.c\u4e00\u5f15\u5165\u4e86cutil\/log\uff0c\u7136\u540ebionic\/libc\/Android.mk\u589e\u52a0libcutil\u3001liblog\uff0c\u5c31\u4f1a\u5bfc\u81f4\u6574\u4e2amake\u90fd\u65e0\u6cd5\u4f7f\u7528\uff0c\u62a5\u9519\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-bash line-numbers\">\u6ca1\u6709\u89c4\u5219\u53ef\u4ee5\u521b\u5efa\u201cout\/host\/linux-x86\/obj\/SHARED_LIBRARIES\/libdvm_intermediates\/import_includes\u201d\u9700\u8981\u7684\u76ee\u6807\u201cout\/host\/linux-x86\/obj\/SHARED_LIBRARIES\/libcutils_intermediates\/export_includes\u201d\u3002 \u505c\u6b62\n<\/code><\/pre>\n<p>\u5728memcmp.c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528ALOGE\uff0c\u4e5f\u4e0d\u7528\u5f15\u5165cutil\/log\u5934\u6587\u4ef6\uff0c\u4e0d\u77e5\u9053\u662f\u4ec0\u4e48\u4e2a\u539f\u7406\u3002<br \/>\n\u4e0a\u9762\u8fd9\u6bb5\u5947\u9047\uff0c\u53ef\u80fd\u662f\u7531\u4e8e\u4ec0\u4e48\u7f13\u5b58\uff0c\u6216\u8005\u6e90\u7801\u7684\u67d0\u4e2a\u6587\u4ef6\u4e0d\u5c0f\u5fc3\u5220\u9664\u9020\u6210\u7684\u3002\u540e\u6765\u91cd\u65b0\u4e0b\u8f7d\u6e90\u7801\u91cd\u65b0\u8d70\u6d41\u7a0b\u5c31\u6ca1\u6709\u4ec0\u4e48\u95ee\u9898\u3002\u4f46\u662f\uff0c<strong>memcmp.c\u91cc\u7684android\u65e5\u5fd7\u6ca1\u6709\u8f93\u51fa\u3002<\/strong><br \/>\n\u9996\u5148\u6211\u6000\u7591360\u53ef\u80fd\u6839\u672c\u6ca1\u6709\u8c03\u7528\u8fd9\u4e2a\u65b9\u6cd5\uff0c\u4e3a\u4e86\u8bc1\u660e\u6211\u7684\u731c\u60f3\uff0c\u6211\u5199\u4e86\u4e00\u4e2aJNI\u7a0b\u5e8f\uff0c\u8c03\u7528\u4e86C\u7684memcmp\u65b9\u6cd5\uff0c<strong>memcmp.c\u91cc\u7684android\u65e5\u5fd7\u4ecd\u7136\u6ca1\u6709\u8f93\u51fa\u3002<\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E9%87%8D%E6%96%B0%E7%A0%94%E7%A9%B6bioniclibcAndroidmk%E5%8F%91%E7%8E%B0%E7%AB%AF%E5%80%AA\"><\/span>\u91cd\u65b0\u7814\u7a76bionic\/libc\/Android.mk\u53d1\u73b0\u7aef\u502a<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u5728Android.mk\u91cc\u641c\u7d22memcmp.c\uff0c\u53d1\u73b0\u53ea\u6709\u4e00\u5904\u5f15\u7528\uff1a<br \/>\n<img src=\"https:\/\/upload-images.jianshu.io\/upload_images\/18328858-6687134b79656065.png?imageMogr2\/auto-orient\/strip%7CimageView2\/2\/w\/1240\" alt=\"image.png\" \/><br \/>\nAndroid.mk\u6587\u4ef6\u91cc\u7684\u5173\u952e\u53d8\u91cf\uff1a<\/p>\n<blockquote><p>\n  <strong>TARGET_ARCH<\/strong>: \u76ee\u6807 CPU\u5e73\u53f0\u7684\u540d\u5b57,  \u548candroid \u5f00\u653e\u6e90\u7801\u4e2d\u6307\u5b9a\u7684\u90a3\u6837\u3002\u5982\u679c\u662f<br \/>\n  arm\uff0c\u8868\u793a\u8981\u751f\u6210 ARM \u517c\u5bb9\u7684\u6307\u4ee4\uff0c\u4e0e CPU\u67b6\u6784\u7684\u4fee\u8ba2\u7248\u65e0\u5173\u3002\n<\/p><\/blockquote>\n<p><strong>memcmp.c\u7f16\u8bd1mips\u67b6\u6784\u7684\u7ec4\u4ef6\u65f6\u624d\u4f1a\u88ab\u4f9d\u8d56\u3002<\/strong><br \/>\n\u4f7f\u7528<\/p>\n<pre><code class=\"language-bash line-numbers\">adb shell\ncat \/proc\/cpuinfo\n<\/code><\/pre>\n<p>\u53d1\u73b0\u6211\u7684\u8c03\u8bd5\u8bbe\u5907\u7684\u67b6\u6784\u662farmv7\uff0c\u6240\u4ee5memcmp.c\u4e0d\u4f1a\u88ab\u6211\u7684\u8bbe\u5907\u8c03\u7528\uff0c\u66f4\u522b\u8c08\u6253\u5370\u65e5\u5fd7\u4e86\u3002<br \/>\n- \u770b\u770barm\u67b6\u6784\u7684\u4f9d\u8d56\uff1a<br \/>\n\u6709\u4e00\u4e2awmemcmp.c\u548cmemcmp.c\u957f\u5f97\u5f88\u50cf\u3002<br \/>\n<img src=\"https:\/\/upload-images.jianshu.io\/upload_images\/18328858-75a53bb418d4d767.png?imageMogr2\/auto-orient\/strip%7CimageView2\/2\/w\/1240\" alt=\"image.png\" \/><br \/>\n\u5b9a\u4f4d\u5230\u6587\u4ef6<br \/>\n<img src=\"https:\/\/upload-images.jianshu.io\/upload_images\/18328858-c1caee28560ef1cb.png?imageMogr2\/auto-orient\/strip%7CimageView2\/2\/w\/1240\" alt=\"image.png\" \/><br \/>\n\u52a0\u4e0a\u65e5\u5fd7<\/p>\n<pre><code class=\"language-c line-numbers\">#include &lt;cutils\/log.h&gt;\nint\nwmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n)\n{\n    size_t i;\n    ALOGE(\"CZLog3333333333\"); \n    for (i = 0; i &lt; n; i++) {\n        if (*s1 != *s2) {\n            \/* wchar might be unsigned *\/\n            return *s1 &gt; *s2 ? 1 : -1; \n        }\n        s1++;\n        s2++;\n    }\n\n    return 0;\n}\n<\/code><\/pre>\n<p><strong>android\u65e5\u5fd7TM\u8fd8\u662f\u6ca1\u6709\u8f93\u51fa\uff0c\u6c14\u6b7b\u4eba\u4e86\u3002<\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Android%E6%BA%90%E7%A0%81%E4%B8%8ENDK%E7%9A%84%E5%85%B3%E7%B3%BB\"><\/span>Android\u6e90\u7801\u4e0eNDK\u7684\u5173\u7cfb<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u5728\u4e0a\u9762\uff0c\u6211\u5199\u4e86\u4e2aJNI\uff0c\u8c03\u7528memcmp()\u65b9\u6cd5\uff0c\u4ee5\u4e3a\u5c31\u662f\u8c03\u7528\u7684\u6e90\u7801\u91cc\u7684bionic\/libc\/upstream-freebsd\/lib\/libc\/string\/wmemcmp.c\u7684wmemcmp\u65b9\u6cd5\u3002<br \/>\n\u5176\u5b9e\uff0c\u8fd9\u91cc\u6211\u6709\u4e2a\u5f88\u5927\u7684\u8bef\u533a\uff1aJNI\u8c03\u7528\u7684\u5e93&lt;string.h>\u5e76\u975eAndroid\u6e90\u7801\u91cc\u7684&lt;string.h>\uff0c\u800c\u662fNDK\u91cc\u7684\u5e93\u3002\u800cNDK\u662f\u72ec\u7acb\u4e8eAndroid\u7cfb\u7edf\u7684\uff0c\u662f\u4e00\u4e2a\u5f00\u53d1\u5de5\u5177\u96c6\uff0c\u6709\u7740\u5f88\u591a\u548cAndroid\u6e90\u7801\u91cc\u76f8\u4f3c\u7684\u5e93\uff0c\u4f46\u662f\u5b83\u4e0d\u5c5e\u4e8eAndroid\u7cfb\u7edf\u672c\u8eab\u7684\u4e00\u90e8\u5206\u3002<\/p>\n<p>\u4f46\u662f\uff0c<strong>NDK\u5de5\u5177\u5305\u91cc\u7684\u90e8\u5206\u5185\u5bb9\u662f\u901a\u8fc7make ndk\u6307\u4ee4\u751f\u6210\u7684<\/strong>\u3002<\/p>\n<button class=\"simplefavorite-button\" data-postid=\"4682\" data-siteid=\"1\" data-groupid=\"1\" data-favoritecount=\"0\" style=\"\">\u6536\u85cf <i class=\"sf-icon-star-empty\"><\/i><\/button>","protected":false},"excerpt":{"rendered":"<p>\u5728https:\/\/www.jianshu.com\/p\/feecde9a9aee\u8fd9\u7bc7\u6587\u7ae0\u91cc\uff0c\u6211\u8bb2\u5230\u4e86\u5982 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[218],"tags":[],"_links":{"self":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/4682"}],"collection":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4682"}],"version-history":[{"count":1,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/4682\/revisions"}],"predecessor-version":[{"id":4683,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/4682\/revisions\/4683"}],"wp:attachment":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4682"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4682"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}