I am trying to disassemble a file on Ubuntu and extract only the text section.
To do this I am using objdump -d executable_file > dump
. This gives me nice human-readable output.
However, I am looking for the binary bytes (which are displayed in the second column of the output):
MEM_ADDRESS <.text>:
MEM_ADDRESS: XX XX HUMAN_READABLE_DISASM
MEM_ADDRESS: XX XX XX XX HUMAN_READABLE_DISASM
What I want to extract is the XX
as a single stream of bytes, just as in the original binary.
Is it possible to do this without parsing the output file?
Yes. You can use the objcopy
utility to extract a section, e.g.
objcopy --output-target=binary --only-section=.text input.elf output.bin