
Can someone explain to me why in the second question proco2, that x-> b.i -> f[3]?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Actually on the stack you only have a pointer to the
struct s2(in8(%ebp)). Therefore afterin
%eaxyou have an address ofstruct s2.The 8th-11th bytes of
struct s2constitutef[0]and the 12th-15th bytes constitutef[1]and therefore you haveIn the second case after
in
%eaxyou have an address ofstruct s1.The 4th-7th bytes of
struct s1constitute thebfield of typeunion u1. Therefore afterin
%eaxyou haveunion u1. Since it’s aunionthe%eaxcontains all field values at the same time (h,iandj). Sois actually getting the 20th-23th byte of whatever pointer is in
%eax(it can’t be thejfield since it’s not a pointer). It can’t behfield since it points tostruct s1andsizeof (struct s1)is 12 which is <20. Therefore it must be theifield. The 20th-23th byte ofstruct s2isf[3]and therefore you have: