This is a probably a very basic question, please bear with me.

I'm starting to get into reverse engineering following this pdf I found online: https://beginners.re/
I am, however, stuck at the very basic steps.

The relevant part from the PDF: 1]

When I try to compile my c++ code (which is the same as in the book) with the following command:

gcc main.cpp -S -O

This is the output I get:


Which, as you can see, is very different, and a lot more complicated than the supposed output written in the pdf. I'm unsure what I'm doing wrong, could anyone help me?


Both outputs show the same effective assembly code. In both outputs, there is only a single instruction:


The second example output is a variation of ret the reason for which is listed in this answer on Stackoverflow.

The more complicated output has several code organizational assembler directives. These directives are not instructions.

  • Thank you! So if I understand correctly, assembler directives are to assembly what preprocessor directives are to C? Also, is there a way to generate a simplified output file similar to the one in the pdf (function names remaining, directives removed etc.), or did the author presumably manually clean up the codes himself? – Bobobot Dec 9 '17 at 19:57
  • 1
    The author probably cleaned up it himself. You can also use godbolt.org to quickly view disassembly for a given code – John Doe Dec 9 '17 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.