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 $ rax
movl rspeax
movl rspedi
shl $ 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 main function.
void printmsg printf hit
;
int main
foo ;
and the following assembly code for foo:
foo:
leaq riprbx # rbx is calleesaved
call printmsg
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.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
