cpp
int main(int argc, char** argv) { return 0; }
asm
dump: file format elf32-littlearm Disassembly of section .plt: 00008378 <.plt>: 8378: e52de004 push {lr} ; (str lr, [sp, #-4]!) 837c: e59fe004 ldr lr, [pc, #4] ; 8388 <_start-0x18> 8380: e08fe00e add lr, pc, lr 8384: e5bef008 ldr pc, [lr, #8]! 8388: 00000d40 andeq r0, r0, r0, asr #26 838c: e28fc600 add ip, pc, #0 ; 0x0 8390: e28cca00 add ip, ip, #0 ; 0x0 8394: e5bcfd40 ldr pc, [ip, #3392]! Disassembly of section .text: 000083a0 <_start>: 83a0: e1a0000d mov r0, sp 83a4: e3a01000 mov r1, #0 ; 0x0 83a8: e28f2004 add r2, pc, #4 ; 0x4 83ac: e28f3004 add r3, pc, #4 ; 0x4 83b0: eafffff5 b 838c <_start-0x14> 83b4: ea000006 b 83d4 <main+0x4> 83b8: 00009000 .word 0x00009000 83bc: 00009008 .word 0x00009008 83c0: 00009010 .word 0x00009010 83c4: 00009018 .word 0x00009018 83c8: e1a00000 .word 0xe1a00000 83cc: e1a00000 .word 0xe1a00000 000083d0 <main>: 83d0: 2000 movs r0, #0 83d2: 4770 bx lr 83d4: f004 e51f blx 40ce14 <_stack+0x38ce14> 83d8: 83d1 strh r1, [r2, #30]
c++
int add2(int i, int j) { return i+j; } int add(int i, int j) { return add2(i,j); } int main(int argc, char** argv) { int m = add(1,2); return m; }
asm
000083d0 <add2(int, int)>: 83d0: 1808 adds r0, r1, r0 83d2: 4770 bx lr 000083d4 <add(int, int)>: 83d4: b510 push {r4, lr} 83d6: f7ff fffb bl 83d0 <add2(int, int)> 83da: bd10 pop {r4, pc} 000083dc <main>: 83dc: b510 push {r4, lr} 83de: 2001 movs r0, #1 83e0: 2102 movs r1, #2 83e2: f7ff fff7 bl 83d4 <add(int, int)> 83e6: bd10 pop {r4, pc} 83e8: f004 e51f blx 40ce28 <_stack+0x38ce28> 83ec: 83dd strh r5, [r3, #30] ...
c++
int add2(int i, int j) { return i+j; } int add1(int i, int j) { return add2(i,j); } int add0() { return add1(2,3); } int main(int argc, char** argv) { int m = add0(); return m; }
asm
000083d0 <add2(int, int)>: 83d0: 1808 adds r0, r1, r0 83d2: 4770 bx lr 000083d4 <add1(int, int)>: 83d4: b510 push {r4, lr} 83d6: f7ff fffb bl 83d0 <add2(int, int)> 83da: bd10 pop {r4, pc} 000083dc <add0()>: 83dc: b510 push {r4, lr} 83de: 2002 movs r0, #2 83e0: 2103 movs r1, #3 83e2: f7ff fff7 bl 83d4 <add1(int, int)> 83e6: bd10 pop {r4, pc} 000083e8 <main>: 83e8: b510 push {r4, lr} 83ea: f7ff fff7 bl 83dc <add0()> 83ee: bd10 pop {r4, pc} 83f0: f004 e51f blx 40ce30 <_stack+0x38ce30> 83f4: 83e9 strh r1, [r5, #30] ...
c++
class Rect { public: Rect(); int getWidth(); int getHeight(); void setWidth(int width); void setHeight(int height); private: int m_width; int m_height; }; Rect::Rect() { m_width=1; m_height=2; } Rect *g_Rect = new Rect(); int Rect::getWidth() { return m_width; } int Rect::getHeight() { return m_height; } void Rect::setHeight(int height) { m_height = height; } void Rect::setWidth(int width) { m_width = width; } void change(Rect *p) { p->setHeight(g_Rect->getWidth()); } int main(int argc, char** argv) { Rect* myrect = new Rect(); change(myrect); //int o = m; return 0; }
asm
00008430 <Rect::Rect()>: 8430: 2101 movs r1, #1 8432: 6001 str r1, [r0, #0] 8434: 184b adds r3, r1, r1 8436: 6043 str r3, [r0, #4] 8438: 4770 bx lr 843a: bf00 nop 0000843c <Rect::getWidth()>: 843c: 6800 ldr r0, [r0, #0] 843e: 4770 bx lr 00008440 <Rect::setHeight(int)>: 8440: 6041 str r1, [r0, #4] 8442: 4770 bx lr 00008444 <change(Rect*)>: 8444: 4b06 ldr r3, [pc, #24] (8460 <change(Rect*)+0x1c>) 8446: b510 push {r4, lr} 8448: 447b add r3, pc 844a: 681b ldr r3, [r3, #0] 844c: 4604 mov r4, r0 844e: 6818 ldr r0, [r3, #0] 8450: f7ff fff4 bl 843c <Rect::getWidth()> 8454: 4601 mov r1, r0 8456: 4620 mov r0, r4 8458: f7ff fff2 bl 8440 <Rect::setHeight(int)> 845c: bd10 pop {r4, pc} 845e: bf00 nop 8460: 00000c80 .word 0x00000c80 00008464 <global constructors keyed to dumpclient.cpp>: 8464: b510 push {r4, lr} 8466: 2008 movs r0, #8 8468: f7ff efc4 blx 83f4 <_start-0xc> 846c: 4604 mov r4, r0 846e: f7ff ffdf bl 8430 <Rect::Rect()> 8472: 4b02 ldr r3, [pc, #8] (847c <global constructors keyed to dumpclient.cpp+0x18>) 8474: 447b add r3, pc 8476: 681b ldr r3, [r3, #0] 8478: 601c str r4, [r3, #0] 847a: bd10 pop {r4, pc} 847c: 00000c54 .word 0x00000c54 00008480 <main>: 8480: b510 push {r4, lr} 8482: 2008 movs r0, #8 8484: f7ff efb6 blx 83f4 <_start-0xc> 8488: 4604 mov r4, r0 848a: f7ff ffd1 bl 8430 <Rect::Rect()> 848e: 4620 mov r0, r4 8490: f7ff ffd8 bl 8444 <change(Rect*)> 8494: 2000 movs r0, #0 8496: bd10 pop {r4, pc} 8498: f004 e51f blx 40ced8 <_stack+0x38ced8> 849c: 8481 strh r1, [r0, #36] ...
class CPoint { public: CPoint(){width = 0; height =0;}; int getWidth(); int getHeight(); void testOne(int i, int ); private: int width; int height; }; int CPoint::getWidth() { return width; } int CPoint::getHeight() { return height; } void CPoint::testOne(int i, int j) { i = getWidth(); j = getHeight(); } int main() { CPoint *p = new CPoint(); p->testOne(2,3); return 0; }
asm
00008758 <CPoint::testOne(int, int)>: 8758: b510 push {r4, lr} 875a: 4604 mov r4, r0 875c: f7ff fff8 bl 8750 <CPoint::getWidth()> 8760: 4620 mov r0, r4 8762: f7ff fff7 bl 8754 <CPoint::getHeight()> 8766: 2300 movs r3, #0 8768: 2202 movs r2, #2 876a: 601a str r2, [r3, #0] 876c: bd10 pop {r4, pc} 876e: bf00 nop
07-19 23:35:58.160: INFO/DEBUG(2244): r0 00000000 r1 00000002 r2 00000002 r3 00000000
07-19 23:35:58.170: INFO/DEBUG(2244): r4 0012e008 r5 00000000 r6 00000001 r7 bec5fb6c
07-19 23:35:58.170: INFO/DEBUG(2244): r8 00000000 r9 00000000 10 00000000 fp 00000000
07-19 23:35:58.170: INFO/DEBUG(2244): ip bec5f570 sp bec5fb30 lr 00008767 pc 0000876a cpsr 20000030
for inline function
#include <stdio.h> class CPoint { public: CPoint(){width = 0; height =0;}; int getWidth(){int *p = NULL; return width+*p; } int getHeight(); void testOne(int i, int ); private: int width; int height; }; /*int CPoint::getWidth() { int *p = 0; return width+*p; } */ int CPoint::getHeight() { return height; } void CPoint::testOne(int i, int j) { i = getWidth(); j = getHeight(); printf("%d,%d\n",i,j); } int main() { CPoint *p = new CPoint(); p->testOne(2,3); return 0; }
asm
00008464 <CPoint::testOne(int, int)>: 8464: 2100 movs r1, #0 8466: b510 push {r4, lr} 8468: 680c ldr r4, [r1, #0] 846a: 6803 ldr r3, [r0, #0] 846c: 18e4 adds r4, r4, r3 846e: f7ff fff7 bl 8460 <CPoint::getHeight()> 8472: 4621 mov r1, r4 8474: 4602 mov r2, r0 8476: 4802 ldr r0, [pc, #8] (8480 <CPoint::testOne(int, int)+0x1c>) 8478: 4478 add r0, pc 847a: f7ff efcc blx 8414 <_start-0x1c> 847e: bd10 pop {r4, pc} 8480: 0000002c .word 0x0000002c