Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Guru
    Join Date
    Oct 2001
    Täby, Sweden

    Mysterious compiler output

    I was just debugging a program and noticed some _really_ strange assembler in the program. Look at this:

    push %ebp
    call addr2
    mov (%esp), %ebp
    (Actually, addr2 is the end of the function just before the function that addr1 is part of)

    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.

  2. #2
    Linux Enthusiast
    Join Date
    Jun 2002
    San Antonio
    it might be a gcc bug, it also might be alignment code like you said. I don't play with gcc code much, there are many many bad dragons hanging around in there. To try and change things in gcc is bad mojo.
    I respectfully decline the invitation to join your delusion.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts