Going back through the code more carefully, and now using the 16-byte alignment it makes more sense.
Here is how I'm reading it now;
[----] := 4-bytes
w := "wasted" bytes
call pushes %eip to the indicated location
[%eip][%ebp][wwww][wwww] [----][----][----][----]
[----][----][----][----] [----][----][----][----]
[----][----][----][---*] [wwww][wwww][*str][buff]
then %ebp gets pushed to the stack, to make the array 16-byte aligned we need to subtract 0x40(char buff[64]) + 0x8(16-byte align stack from ebp and eip);
we get the buffer at -0x48(array start location indicated by
*).
Then to maintain the 16-byte alignment for the 2 parameters to strcpy we need to subtract another 0x10 from the stack, thus the 0x58.
Going through the function code the input address gets loaded to the location indicated by
*str and the address for the array(
*) gets loaded to the location indicated by
buff.
Code:
080483e4 <func>:
80483e4: 55 push %ebp
80483e5: 89 e5 mov %esp,%ebp
80483e7: 83 ec 58 sub $0x58,%esp
80483ea: 8b 45 08 mov 0x8(%ebp),%eax ;; mov *str to eax
80483ed: 89 44 24 04 mov %eax,0x4(%esp) ;; mov eax to [esp + 4]
80483f1: 8d 45 b8 lea -0x48(%ebp),%eax ;; load effective address of "buff" into eax
80483f4: 89 04 24 mov %eax,(%esp) ;; mov eax to [esp]
80483f7: e8 20 ff ff ff call 804831c <strcpy@plt>
80483fc: c9 leave
80483fd: c3 ret
Now main makes sense accounting for 16-byte alignment.
Code:
080483fe <main>:
80483fe: 55 push %ebp
80483ff: 89 e5 mov %esp,%ebp
8048401: 83 e4 f0 and $0xfffffff0,%esp ;; 16-byte align %esp (was wondering what this was for)
8048404: 83 ec 10 sub $0x10,%esp ;; 16-bytes (only 4-bytes are used)
8048407: 8b 45 0c mov 0xc(%ebp),%eax
804840a: 83 c0 04 add $0x4,%eax
804840d: 8b 00 mov (%eax),%eax
804840f: 89 04 24 mov %eax,(%esp)
8048412: e8 cd ff ff ff call 80483e4 <func>
8048417: b8 00 00 00 00 mov $0x0,%eax
804841c: c9 leave
804841d: c3 ret
804841e: 90 nop
804841f: 90 nop
Figured I'd give learning x86 another go, and that it'd be more effective for me to learn through disassembly than through forward engineering.
So quite a bit of this is new to me.