Skip to content

3.67

Solution

A.

image

B.

stack pointer + 64

C.

Relative to the stack pointer.

But there is an extra offset of 8 added due to call (occupied by the return address), so an offset of 24 from %rsp would refer to s.p from the answer to A, and s.a[0] would be at an offset of 8.

D.

By moving elements of s to addresses relative to the argument.

E.

image

F.

Structs can be passed as part of the "Argument build" area on the stack frame of the caller. The argument that is passed in %rdi register was the memory address of where the return struct should be stored. The space for it was allocated by the caller before hand. This was also the address that was returned.