objdump to extract contents of text segment to a binary format

Ursa Major picture Ursa Major · Jan 3, 2014 · Viewed 13.3k times · Source

How do we use objdump to output to a binary file?

This is definitely not the right way to do so:

objdump -s -j .text /path/firmware.ko > /content.bin

as it is only presenting text format. I only require the bytes of the text segment to be extracted and to be set in binary forms.

Answer

tristan picture tristan · Jan 3, 2014

You can use objcopy instead

objcopy -O binary --only-section=.text /path/firmware.ko /content.bin