#include <stdio.h>

int dowhile(int n){
int i = 1;
int s = 0;
do{
s += i;
}while(i++ < n);
return s;
} int whiledo(int n){
int i = 1;
int s = 0;
while(i <= n){
s += i++;
}
return s;
} int main(int argc, char* argv[]){
printf("dowhile:%d\n", dowhile(100));
printf("while:%d\n", whiledo(100));
return 0;
}

.text:00008570 ; =============== S U B R O U T I N E =======================================
.text:00008570
.text:00008570
.text:00008570 doWhile ; CODE XREF: main+8↓p
.text:00008570 ; __unwind {
.text:00008570 MOV R2, #0
.text:00008574 MOV R3, #1 ; i = 1 s=0
.text:00008578
.text:00008578 loc_8578 ; CODE XREF: doWhile+18↓j
.text:00008578 ADD R2, R2, R3 ; s = s + i
.text:0000857C ADD R3, R3, #1 ; i++
.text:00008580 SUB R1, R3, #1 ; tmp = i -1
.text:00008584 CMP R0, R1
.text:00008588 BGT loc_8578 ; if arg0(n) > tmp continue继续循环
.text:0000858C MOV R0, R2 ; r0 为return值 r0 = s
.text:00008590 BX LR ; 使用LR的值跳转出函数
.text:00008590 ; } // starts at 8570
.text:00008590 ; End of function doWhile
.text:00008590
.text:00008594
.text:00008594 ; =============== S U B R O U T I N E =======================================
.text:00008594
.text:00008594
.text:00008594 whileDo ; CODE XREF: main+20↓p
.text:00008594 ; __unwind {
.text:00008594 SUBS R2, R0, #0
.text:00008598 MOVLE R0, #0
.text:0000859C BXLE LR ; if n <= 0 跳出函数
.text:000085A0 MOV R0, #0 ; s = 0
.text:000085A4 MOV R3, #1 ; i = 1
.text:000085A8
.text:000085A8 loc_85A8 ; CODE XREF: whileDo+20↓j
.text:000085A8 ADD R0, R0, R3 ; s += i
.text:000085AC ADD R3, R3, #1 ; i++
.text:000085B0 CMP R2, R3
.text:000085B4 BGE loc_85A8 ; if n >= i contiue
.text:000085B8 BX LR
.text:000085B8 ; } // starts at 8594
.text:000085B8 ; End of function whileDo
.text:000085B8
.text:000085BC
.text:000085BC ; =============== S U B R O U T I N E =======================================
.text:000085BC
.text:000085BC
.text:000085BC ;
.text:000085BC
.text:000085BC ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:000085BC main ; CODE XREF: j_main↑j
.text:000085BC ; __unwind {
.text:000085BC PUSH {R4,LR} ; 栈上保存R4 和 LR 的值
.text:000085C0 MOV R0, #0x64 ; 'd' ; 为RO 赋值100
.text:000085C4 BL doWhile ; 跳转到doWhile。同时给LR赋值为0x85C8
.text:000085C8 MOV R1, R0
.text:000085CC LDR R0, =(aDowhileD - 0x85D8) ; 获取字符串在GOT的偏移
.text:000085D0 ADD R0, PC, R0 ; 获取字符串实际首地址
.text:000085D4 BL printf
.text:000085D8 MOV R0, #0x64 ; 'd' ; 为R0 赋值100
.text:000085DC BL whileDo ; 跳转到doWhile。同时给LR赋值为0x85E0
.text:000085E0 MOV R1, R0
.text:000085E4 LDR R0, =(aWhileD - 0x85F0) ; "while:%d\n"
.text:000085E8 ADD R0, PC, R0 ; "while:%d\n"
.text:000085EC BL printf
.text:000085F0 MOV R0, #0
.text:000085F4 POP {R4,PC}
.text:000085F4 ; End of function main
.text:000085F4
.text:000085F4 ; -----

【Android 逆向】ARM while 逆向的更多相关文章

  1. 使用IDA pro逆向ARM M系核心的Bin固件

    使用IDA pro逆向ARM M系核心的Bin固件 ​ 物联网和智能设备这两年还是比较火的,我们的手中或多或少都有了几个智能设备,比如手环,智能手表,或者门锁什么之类的东西,但是同学们在做逆向的时候, ...

  2. 【基于Android的ARM汇编语言系列】之五:ARM指令集与Thumb指令集

    作者:郭嘉 邮箱:allenwells@163.com 博客:http://blog.csdn.net/allenwells github:https://github.com/AllenWell [ ...

  3. 【基于Android的ARM汇编语言系列】之三:ARM汇编语言程序结构

    作者:郭嘉 邮箱:allenwells@163.com 博客:http://blog.csdn.net/allenwells github:https://github.com/AllenWell [ ...

  4. 20145219《网络对抗技术》PC平台逆向破解之逆向与Bof基础

    20145219<网络对抗技术>PC平台逆向破解之逆向与Bof基础 实践目标 实践对象:一个名为pwn1的linux可执行文件. pwn1正常执行流程:main调用foo函数,foo函数会 ...

  5. 【android逆向】 ARM for 逆向

    C源码 #include <stdio.h> int nums[5] = {1, 2, 3, 4, 5}; int for1(int n){ //普通for循环 int i = 0; in ...

  6. 【Android 逆向】ARM switch 逆向

    #include <stdio.h> int switch1(int a, int b, int i){ switch (i){ case 1: return a + b; break; ...

  7. 一些Android程序的反逆向方法

    1.检测调试器 在代码中检测调试器的动态调试 首先在AndroidMainfest.xml文件中设置android:debuggable="false",让程序不可调试.这样别人想 ...

  8. [Android Security] Smali和逆向分析

    copy : https://blog.csdn.net/u012573920/article/details/44034397 1.Smali简介 Smali是Dalvik的寄存器语言,它与Java ...

  9. 【逆向工具】逆向工具101editor使用-游戏快速通关

    [渡者游戏简介] 船夫小江将运送客人的,羊.狐狸.草等物品过河,如果留下动物被其它种类吃掉任务就失败了.你需要帮助他做出正确的顺序选择.Ferryman是一款根据经典谜题改编的解谜游戏. 一.查看文件 ...

随机推荐

  1. SpringBoot之缓存

    一.准备工作 首先整合使用Spring整合MyBatis. 可参阅:SpringBoot整合MyBatis SpringBoot整合MyBatis完后后,我们需要在pom.xml中添加缓存相关的依赖. ...

  2. python小题目练习(二)

    题目:输出1-100之间不包括7的倍数,含有7的数的其他数 """Author:mllContent:输出1-100之间不包括7的倍数,含有7的数的其他数Date:202 ...

  3. Python:27行代码实现将多个Excel表格内容批量汇总合并到一个表格

    序言 (https://jq.qq.com/?_wv=1027&k=GmeRhIX0) 老板最近越来越过分了,快下班了发给我几百个表格让我把内容合并到一个表格内去.还好我会Python,分分钟 ...

  4. 项目中使用@Transactional需要注意的点

    项目如果是Spring Boot.或者Spring Cloud,切记需要在启动类上加入@EnableTransactionManagement该注解.否则事务不生效. @Transactional是一 ...

  5. CentOS7 No rule to make target

    由于缺少依赖包,需要安装以下包: yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freet ...

  6. 快来体验快速通道,netty中epoll传输协议详解

    目录 简介 epoll的详细使用 EpollEventLoopGroup EpollEventLoop EpollServerSocketChannel EpollSocketChannel 总结 简 ...

  7. nginx概述及配置

    Nginx是什么? Nginx是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器.因它的稳定性.丰富的功能集.示例配置文件和低系统资源的消耗而闻名.20 ...

  8. 【破解】设置 Codesys for Raspberry 每118分钟自动重启Runtime

    Codesys for Raspberry 无授权时,试用2小时后会自动退出,重启Runtime后就又恢复2小时试用时长. 官网授权购买地址: [单核] https://store.codesys.c ...

  9. Netty源码解读(三)-NioEventLoop

    先看看EventLoop类图 我们在Netty第二篇文章中的代码中,看到有多次用到eventLoop.execute()方法,这个方法就是EventLoop开启线程执行任务的关键,跟踪进去看看 // ...

  10. canal-1.1.5实时同步MySQL数据到Elasticsearch

    一.环境准备 1.jkd 8+ 2.mysql 5.7+ 3.Elasticsearch 7+ 4.kibana 7+ 5.canal.adapter 1.1.5 二.部署 一.创建数据库CanalD ...