objdump, displaying without offsets
-
19-03-2021 - |
Question
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?
Solution
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
OTHER TIPS
If you want to achieve same output as Peeter Joot showed but without using Perl command line. Then you can use Grep and Cut tool instead, like shown below.
objdump -d --no-show-raw-insn my_binary_file.o | grep "^ " | cut -f2,3
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow