Mysterious compiler output
I was just debugging a program and noticed some _really_ strange assembler in the program. Look at this:
(Actually, addr2 is the end of the function just before the function that addr1 is part of)
mov (%esp), %ebp
Why ever would the compiler want to do something like that?! Why doesn't it satisfy with just push %ebp?! I've seen similar things before, like "mov %esi, %esi" and similar stuff, and I just don't get it. The call instruction happens to align the next instruction at an even multiple of 8, but that can't be it on a i386, right? Especially using a call instruction to meaningless code to align?! There isn't even a loop afterwards, not that it would matter anyway.
Can anyone think of a reason to do that, or has anyone seen the reason in the gcc sources or anything?
I'm really confused.