Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

It should look something like this: image text in transcribed 
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions