Question: 8 . You are charged with maintaining a large C program, and you come across the following code: ` ` ` typedef struct { int

8.
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 CNT 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 :
lc: c3
```
0: 8b 8e 20010000 mov 0x1C0(%rsi),%ecx
6: 030e add (%rsi),%ecx
8: 488d 04 bf lea (%rdi,%rdi,4),%rax
c: 488d 04 c6 lea (%rsi,%rax,8),%rax
10: 488b 5008 mov 0x8(%rax),%rdx
14:4863 c9 movslq %ecx,%rcx
17:48894c d010 mov %rcx,0x10(%rax, %rdx,8)
retq
Using your reverse engineering skills, deduce the following:
A. The value of CNT.
B. The size of a_struct and the size of b_struct.
C. 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.
8 . You are charged with maintaining a large C

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 Programming Questions!