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.
objdump displays information about one or more object files. The options control what particular information to display. This information is mostly useful to programmers who are working on the compilation tools, as opposed to programmers who just want their program to compile and work.
Objdump displays information about one or more object files, either on their own, or inside libraries. It is commonly used as a disassembler, but it can also display information about file headers, symbol tables, relocations, debugging directives and more.
Passing --disassemble=SYMBOL to objdump will disassemble only the specified function. No need to pass the start address and the end address.
We have to specify the file format explicitly using the -I.
objcopy -I #file type format# -j #ELF segment contents to copy# -O #data type to output, binary, etc# #input file# #output file#
eg.
objcopy -I elf32-little -j .text -O binary firmware.ko content.bin
You can use objcopy instead
objcopy -O binary --only-section=.text /path/firmware.ko /content.bin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With