Create a gist now

Instantly share code, notes, and snippets.

@tangrs /
Last active Apr 15, 2018

What would you like to do?
Convert a memory dump/raw binary image into an ELF file
# Convert a raw binary image into an ELF file suitable for loading into a disassembler
cat > raw$$.ld <<EOF
echo " . = $3;" >> raw$$.ld
cat >> raw$$.ld <<EOF
.text : { *(.text) }
${CROSS_PREFIX}ld -b binary -r -o raw$$.elf $1
${CROSS_PREFIX}objcopy --rename-section .data=.text \
--set-section-flags .data=alloc,code,load raw$$.elf
${CROSS_PREFIX}ld raw$$.elf -T raw$$.ld -o $2
${CROSS_PREFIX}strip -s $2
rm -rf raw$$.elf raw$$.ld
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment