Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You are charged with maintaining a large C program, and you come across the following code: typedef struct { int first; a_struct a[CNT]; int last;
You are charged with maintaining a large C program, and you come across the following code: typedef struct { int first; a_struct a[CNT]; int last; } b_struct; void test(long i, b_struct *bp) { int n = bp first + bp last; a_struct *ap = &bp a[i] ; ap x[ap idx] = n; } The declarations of the compile-time constant CMT and the structure a_struct are in a file for which you do not have the necessary access privilege. Fortunately, you have a copy of the, o version of code, which you are able to disassemble with the objdump program, yielding the following disassembly; Void test (long i, b_struct *bp) i in %rdi, bp in %rsi 0000000000000000 : 0: 8b 8e 20 01 00 00 mov 0x120(%rsi), %ecx 6: 03 0e add (%rsi), %ecz 8: 48 8d 04 bf lea (%rdi, %rdi, 4), %rax c: 48 8d 04 c6 lea (%rsi, %rax, 8), %rax 10: 48 8b 50 08 mov 0x8(%rax), %rdx 14: 48 63 c9 movslq %ecx, %rcx 17: 48 89 4c d0 10 mov %rcx, 0x10(%rax, %rdx, 8) ac: c3 retq Using your reverse engineering skills, deduce the following: The value of CNT. A complete declaration of structure a_struct. Assume that the only fields in this structure are idx and x, and that both of these contain signed values. You are charged with maintaining a large C program, and you come across the following code: typedef struct { int first; a_struct a[CNT]; int last; } b_struct; void test(long i, b_struct *bp) { int n = bp first + bp last; a_struct *ap = &bp a[i] ; ap x[ap idx] = n; } The declarations of the compile-time constant CMT and the structure a_struct are in a file for which you do not have the necessary access privilege. Fortunately, you have a copy of the, o version of code, which you are able to disassemble with the objdump program, yielding the following disassembly; Void test (long i, b_struct *bp) i in %rdi, bp in %rsi 0000000000000000 : 0: 8b 8e 20 01 00 00 mov 0x120(%rsi), %ecx 6: 03 0e add (%rsi), %ecz 8: 48 8d 04 bf lea (%rdi, %rdi, 4), %rax c: 48 8d 04 c6 lea (%rsi, %rax, 8), %rax 10: 48 8b 50 08 mov 0x8(%rax), %rdx 14: 48 63 c9 movslq %ecx, %rcx 17: 48 89 4c d0 10 mov %rcx, 0x10(%rax, %rdx, 8) ac: c3 retq Using your reverse engineering skills, deduce the following: The value of CNT. A complete declaration of structure a_struct. Assume that the only fields in this structure are idx and x, and that both of these contain signed values
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