What can i do to get results like book?
Just use the same version of the compiler and compile the code for the same architecture as the Author. Usually, there is explicitly stated which compiler version was used to get a particular assembly. For example:

or

So, there are several different versions of compiler used and if you want to get the same results, you have to use the version described at each listing.
or if getting results like author's is not the point
It's definitely not the point. The point is that you learn as much as possible when reading this book.
I would even say it may be better to get different results than these in the book. There are several reasons for it:
- You will learn how the newer versions of the GCC compiler deal with the same C code, so for example what are new optimization methods.
- You will see different assembly performing the same task as the previous one - when you'll see big differences, you will probably want to think or search for more information about it and this way you'll remember it better.
- It encourages you to understand the resulting assembly so you can compare it with the one presented by the Author - it's far more creative and productive work than just copying what you have already presented.
how can i get the most out of this lovely book?
I would say, by practice. If you don't practice what you have just learned, you will forget it very quickly. You can even omit some programs written there and just experiment on your own (like the Author suggested) - just write some code and try to find its fragments in disassembly.
-fno-stack-protector
(or generally check outgcc -dumpspecs
output to see what security-related default flags your GCC may be using). Last but not least try-O2
...-O2
on a recent GCC version may be closer to what-O3
used to be on older GCC versions. The simple reason being that several optimizations are given time to mature before they graduate up the optimization levels. In terms of library code (glibc
aka the C runtime) you may also want to pass-D_FORTIFY_SOURCE=n
to thegcc
driver. Also check out the individual options behind the optimization levels. This particular document may actually provide a nice way of diffing them across GCC versions, too ...