3.69 Struct
★★★
You are charged with maintaining a large C program, and you come across the following code:
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:
Using your reverse engineering skills, deduce the following:
A. The value of CNT
.
The offset of last
in b_struct
is 288, and in line 10, we retrive *(bp+8+40*i)
to %rdx, so a_struct
is align 8, and we know:
and L=40, so CNT=7.
B. A complete declaration of struture a_struct
. Assume that the only fields in this structure are idx
and x
, and that both of these contain signed values.
Line 7 converts %ecx to %rcx, convert n to long. And save n to 16+%rax+8*%rdx, %rax is bp+40i, and %rdx is bp+40i+8, so idx
has type of long, and is the first field of a_struct
. The type of x is also long, and has 4 elements.
Last updated