g++ -c xyz.cpp
creates an object file
But when I open it in vim editor it shows some crazy text...
How can I see the machine code?
What package can use to open and see that machine code?
Check out the
In it you'll find objdump - display information from object files.
Then try running
Machine code generated by your compiler is not supposed to be human readable, but rather completely optimized to run as fast as possible on your processor.
However, you can read symbols from the binary files like this:
I just realized my answer wasn't really answering your question about reading the actual machine code. However, I think it provides some useful information instead. For reading the assembly-level operations for your processor, use
You should use the
So for your example the code would be