Question: What happens when foo is called, with the following code. Note: jmp * % rax is a correct instruction that will jump at the address

What happens when foo is called, with the following code. Note: jmp *%rax is a correct instruction that will jump at the address given by %rax:
foo:
andq $0,% rax
movl (%rsp),%eax
movl 4(%rsp),%edi
shl $32,% rdi
orq % rdi, % rax
popq %rdi
jmp *%rax
A. The instructions of foo are executed and the function properly returns.
B. It creates an infinite loop.
C. This is not correct assembly, so this won't compile.
D. It crashes the program.
Consider the following C main function.
void print_msg (){ printf ("hit
"); }
int main (){
foo ();
}
and the following assembly code for foo:
foo:
leaq (%rip),%rbx # %rbx is callee-saved
call print_msg
pushq % rbx
pushq % rbx
ret
Compiling and running these files, what will it print?
A. Nothing, but it won't crash.
B. Nothing, and it crashes.
C. hit once.
D. hit twice.
E. hit in an infinite loop and does not crash.
F. hit in an infinite loop but crashes fast as the stack becomes too large.
 What happens when foo is called, with the following code. Note:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!