Created
October 28, 2015 21:08
-
-
Save lenerd/26e553ac18384ad239d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
elf="$(mktemp)" | |
bin="$(mktemp)" | |
(echo ".intel_syntax noprefix"; cat "$1") | gcc -x assembler -m32 -masm=intel -c -o "$elf" - | |
objcopy -O binary --only-section=.text "$elf" "$bin" | |
echo -e "Assembly:\n" | |
echo -e "Raw Hex:\n" | |
od -A none -tx1 "$bin" | tr -d '\n ' | |
echo -e '\n' | |
echo -e "String Constant:\n" | |
echo -n '"' | |
od -A none -tx1 "$bin" | tr -d '\n' | sed -e 's/ /\\x/g' | |
echo -e '"\n' | |
echo -e "\nDisassembly:\n" | |
objdump -d -M intel "$elf" | tail -n +8 | |
rm -f "$elf" "$bin" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment