When dumping an executable file, I only want the code segment to be printed on the standard output, not offsets and binary form of the code. I cannot achieve it from
man objdump
Is there a way?
You can suppress the object code hex dump with
--no-show-raw-insn
If you have jumps in the code then you need the offsets to make sense of them, but if you really want to strip them, filter the code with something like:
objdump -d --no-show-raw-insn myfile.o | perl -p -e 's/^\s+(\S+):\t//;'
Example output:
0000000000000000 <foo>:
retq
lea 0x0(%rsi),%rsi
lea 0x0(%rdi),%rdi
Disassembly of section .gnu.linkonce.t.goo:
0000000000000000 <goo>:
retq
lea 0x0(%rsi),%rsi
lea 0x0(%rdi),%rdi