Draw the stack in the following diagrams given the assembly code, read the instructions please
Consider the following assembly code. Here are 4 functions in the code, fun1, fun2, fun3 and main. In the code, the main function calls fun1 at first, then fun1 calls fun2, finally fun2 calls fun3. Please draw what gets placed on the stack by the following code. For those local variables in memory that you don't know their value exactly, just using 0x0 as placeholder Also, suppose the initial value of register rbp and rsp is 0x0 and 0x7fffffffea88 Draw the stack at the following point(s): Before fun20 starts execution, so after the call of fun20 in fun1 is executed but before the first instruction of fun20 has begun Before fun30 starts execution, so after the call of fun3) in fun20 is executed but before the first instruction of fun30 has begun When the most information is on the stack, so sometime during function3 when the most information has been placed on the stack. Here is the code fun3 0x400506: push 0x400507 : mov 0x40050a : mov 0x400511: mov 0x400516: pop 0x400517: retoq %rbp %rsp,%rbp $0x18,-0x8 (%rbp) $0x0,%eax %rbp fun2: 0x400518: push %rbp 0x400519: mov %rsp,%rbp 0x40051c: sub $0x18,%rsp 0x400520: mov %edi,-0x8 (%rbp) 0x400523: mov -0x8 ( %rbp ) ,%eax 0x400526 : add $0x3,%eax 0x400529 : mov %eax,-0x10 ( %rbp) 0x40052c: mov -0x8 ( %rbp ) ,%eax 0x4005 2f: mov %eax , %edi 0x400531: callq 0x400506
0x400536 : mov -0x8 ( %rbp ) ,%eax 0x400539 imul -0x8 (srbp),seax 0x40053d leaveq 0x40053e: retq fun1: 0x40053f: push %rbp 0x400540 : mov %rsp,%rbp 0x400543 : sub $0x18,%rsp 0x400547 : mov %edi,-0x14(%rbp) 0x40054a: mov %esi,-0x18 (%rbp) 0x40054d : mov -0x14 (%rbp ) ,%edx 0x400550: mov -0x18 ( %rbp),%eax 0x400553: add %edx,%eax 0x400555 : mov %eax,-0x4 (%rbp) 0x400558 : mov -0x4 ( %rbp ) ,%eax 0x4005 5b: mov %eax , %edi 0x40055d: callq 0x400518 0x400562 : mov %eax,-0x14 (%rbp) 0x400565 : mov -0x14 (%rbp ) ,%edx 0x400568 : mov -0x18 (%rbp ) ,%eax 0x40056b: add %edx,%eax 0x40056d eaveq 0x40056e: retq main 0x40056f: push %rbp 0x400570 : mov %rsp,%rbp 0x400573 sub $0x10,srsp 0x400577: movl $0x5,-0x4 (%rbp) 0x40057e: movl $0x3,-0x8 (%rbp) 0x400585 : mov -0x8(%rbp ) ,%edx 0x400588 : mov -0x4 (%rbp ) ,%eax 0x40058b : mov %edx,%esi 0x40058d : mov %eax,%edi 0x40058f callq 0x40053f 0x4005ab: mov $0x0,%eax 0x4005b0: leaveq 0x4005b1: retq example of stack before excuting instruction at 0x400585 in function main: Address 0x7fffffffea70 0x7fffffffea78 0x7fffffffea80 Value 0x0000000000000000 0x0000000500000003 0x0000000000000000 Diagram for sub-question 1 (may not use all entries) Address Value 0x7fffffffea70 0x7fffffffea78 0x7fffffffea80 0x0000000000000000 0x0000000500000003 0x0000000000000000 Diagram for sub-question 2 (may not use all entries): Value Address 0x7fffffffea70 0x7fffffffea78 0x7fffffffea80 0x0000000000000000 0x0000000500000003 0x0000000000000000 Diagram for sub-question 3 (may not use all entries): Value Address 0x7fffffffea70 0x7fffffffea78 0x7fffffffea80 0x0000000000000000 0x0000000500000003 0x0000000000000000 Consider the following assembly code. Here are 4 functions in the code, fun1, fun2, fun3 and main. In the code, the main function calls fun1 at first, then fun1 calls fun2, finally fun2 calls fun3. Please draw what gets placed on the stack by the following code. For those local variables in memory that you don't know their value exactly, just using 0x0 as placeholder Also, suppose the initial value of register rbp and rsp is 0x0 and 0x7fffffffea88 Draw the stack at the following point(s): Before fun20 starts execution, so after the call of fun20 in fun1 is executed but before the first instruction of fun20 has begun Before fun30 starts execution, so after the call of fun3) in fun20 is executed but before the first instruction of fun30 has begun When the most information is on the stack, so sometime during function3 when the most information has been placed on the stack. Here is the code fun3 0x400506: push 0x400507 : mov 0x40050a : mov 0x400511: mov 0x400516: pop 0x400517: retoq %rbp %rsp,%rbp $0x18,-0x8 (%rbp) $0x0,%eax %rbp fun2: 0x400518: push %rbp 0x400519: mov %rsp,%rbp 0x40051c: sub $0x18,%rsp 0x400520: mov %edi,-0x8 (%rbp) 0x400523: mov -0x8 ( %rbp ) ,%eax 0x400526 : add $0x3,%eax 0x400529 : mov %eax,-0x10 ( %rbp) 0x40052c: mov -0x8 ( %rbp ) ,%eax 0x4005 2f: mov %eax , %edi 0x400531: callq 0x400506 0x400536 : mov -0x8 ( %rbp ) ,%eax 0x400539 imul -0x8 (srbp),seax 0x40053d leaveq 0x40053e: retq fun1: 0x40053f: push %rbp 0x400540 : mov %rsp,%rbp 0x400543 : sub $0x18,%rsp 0x400547 : mov %edi,-0x14(%rbp) 0x40054a: mov %esi,-0x18 (%rbp) 0x40054d : mov -0x14 (%rbp ) ,%edx 0x400550: mov -0x18 ( %rbp),%eax 0x400553: add %edx,%eax 0x400555 : mov %eax,-0x4 (%rbp) 0x400558 : mov -0x4 ( %rbp ) ,%eax 0x4005 5b: mov %eax , %edi 0x40055d: callq 0x400518 0x400562 : mov %eax,-0x14 (%rbp) 0x400565 : mov -0x14 (%rbp ) ,%edx 0x400568 : mov -0x18 (%rbp ) ,%eax 0x40056b: add %edx,%eax 0x40056d eaveq 0x40056e: retq main 0x40056f: push %rbp 0x400570 : mov %rsp,%rbp 0x400573 sub $0x10,srsp 0x400577: movl $0x5,-0x4 (%rbp) 0x40057e: movl $0x3,-0x8 (%rbp) 0x400585 : mov -0x8(%rbp ) ,%edx 0x400588 : mov -0x4 (%rbp ) ,%eax 0x40058b : mov %edx,%esi 0x40058d : mov %eax,%edi 0x40058f callq 0x40053f 0x4005ab: mov $0x0,%eax 0x4005b0: leaveq 0x4005b1: retq example of stack before excuting instruction at 0x400585 in function main: Address 0x7fffffffea70 0x7fffffffea78 0x7fffffffea80 Value 0x0000000000000000 0x0000000500000003 0x0000000000000000 Diagram for sub-question 1 (may not use all entries) Address Value 0x7fffffffea70 0x7fffffffea78 0x7fffffffea80 0x0000000000000000 0x0000000500000003 0x0000000000000000 Diagram for sub-question 2 (may not use all entries): Value Address 0x7fffffffea70 0x7fffffffea78 0x7fffffffea80 0x0000000000000000 0x0000000500000003 0x0000000000000000 Diagram for sub-question 3 (may not use all entries): Value Address 0x7fffffffea70 0x7fffffffea78 0x7fffffffea80 0x0000000000000000 0x0000000500000003 0x0000000000000000