Extra Credit 2 Assembly 15 points You are charged with maintaining a large C

Extra credit 2 assembly 15 points you are charged

This preview shows page 18 - 20 out of 20 pages.

Extra Credit 2: Assembly (15 points)You are charged with maintaining a large C program and you come across the following code.typedef struct{int left;a_struct a[CNT];int right;} b_struct;void test(int i, b_struct *bp){int n = bp->left + bp->right;a_struct* ap = &bp->a[i];ap->x[ap->idx] = n;}The declaration of the compile time constant CNT and the structure astruct are in a file for which youdon’t have necessary access privilege. Fortunately you have a copy of the ’.o’ version of code, which youare able to disassemble with objdump program yielding the disassembly shown below.test:pushl%ebpmovl%esp, %ebppushl%ebxmovl8(%ebp), %edxmovl12(%ebp), %eaximull$28, %edx, %ecxleal(%eax,%ecx), %ecxleal0(,%edx,8), %ebxsubl%edx, %ebxmovl%ebx, %edxaddl4(%ecx), %edxmovl312(%eax), %ebxaddl(%eax), %ebxaddl8(%ecx), %ebxmovl%ebx, 12(%eax,%edx,4)popl%ebxpopl%ebpretClearly show your reasoning for your answers.Using your reverse engineering skills, deduce thefollowing:1. The value of CNT. 18
Image of page 18
2. A complete declaration of structure astruct. 19
Image of page 19
/* show work here */ 20
Image of page 20

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture