Question: Consider the following source code, where k,l and m are constants declared with #define. The struct lnode is as defined as: struct lnode { char

Consider the following source code, where k,l and m are constants declared with #define. The struct lnode is as defined as:

struct lnode { char *str; // points to 32-character string struct lnode *next; // points to next node address struct lnode *prev; // points to prev node address };

You will need to determine the values for k, l and m, which are the dimensions of a 3-D array named A.

struct lnode A[k][l][m]; int store_ele(int h, int i, int j, struct lnode dest) { A[h][i][j] = dest; return sizeof(A); }

On compiling this program (with gcc -O2 -S -fno-asynchronous-unwind-tables) ,gcc generates the following assembly code for the store_ele function:

store_ele: endbr64 movslq %edi, %rdi movslq %edx, %rdx movslq %esi, %rsi movdqu 8(%rsp), %xmm0 movq %rdi, %rax leaq (%rdx,%rdx,2), %rdx salq $6, %rax subq %rdi, %rax salq $4, %rax leaq (%rax,%rdx,8), %rax leaq (%rsi,%rsi,4), %rdx leaq (%rsi,%rdx,4), %rdx leaq (%rax,%rdx,8), %rdx leaq A(%rip), %rax addq %rdx, %rax movq 24(%rsp), %rdx movups %xmm0, (%rax) movq %rdx, 16(%rax) movl $15120, %eax ret

Use your reverse engineering skills to determine the values of k,l and m, based on the assembly code. (Hint: The movdqu and movups instructions are dealing with the updating of the array element, not determining the location of the element being updated) Show your work for finding out these values in (HW6-show your work, worth 20 points)

1.k

2.l

3.m

4.upload your work for determining k, l, m

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!