Question: 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

It should look something like this: a chance to reverse engineer a switch statement from machine code. In 

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 0xe00000000040059e : jmpq rax 0x00000000004005a8(+44); subqsexa,-0x8 (%rbp) 0x00000000004005ad : jmp x4005cb 0x00000000004005b7 : sarq $0x4,-0x8(rbp) 0x00000000004005bc64): jmp 0x4005cb 0x00000000004005be mov 0x8 (%rbp),%rax 0x00000000004005cf 83): pop %rbp 0x00000000004005de : retq mov -ex20(%rbp) ,%rax 2

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!