Answered step by step
Verified Expert Solution
Question
1 Approved Answer
It should look something like this: This problem will give you a chance to reverse engineer a switch statement from machine code. In the following
It should look something like this:This problem will give you a chance to reverse engineer a switch statement from machine code. In the following procedure, the body of the long switch_prob(long x, long n) long result n; switch(x) /* The code for the cases goes here * return result; The disassembled machine code for the procedure is shown below. Recall parameter x is passed in register %rdi and parameter n is passed in register %rs. The jump table resides in a different area of memory. We can see from the mov at address Ox040059e that the jump table begins at address 0x0400698. Using the gdb debugger, we can examine the ten 8-byte words of memory comprising the jump table with the command x/10x 0x400698. gdb prints the following: 2 0x400698 0x00000000004005ad 0x00000000004005c3 0x4006a8: 0x00000000004005c3 0x00000000004005c3 0x4006b8: 0x00000000004005a8 0x00000000004005be 0x4006c8: 0x00000000004005a8 0x00000000004005b7 570 (+0); push %rbp 0x0000000000400574(+1); mov %rsp,%rbp 0x0000000000400580(+4); mov %rdi,-0x18 (%rbp) 0x0000000000400584 : 0x000000000040058c : mov -9x18(%rbp),%rax 0x0000000000400594(+24); sub $0x52,%rax 0x0000000000400598 ja x4005c3
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started