2 # Convert an asm source file to gdb commands.
3 # Useful for loading small programs in gdbinit scripts.
10 *) echo "Usage: $0 [arch] file address" >&2
18 ${ARCH}gcc -nostartfiles -nostdlib -Wl,-Ttext=$ADDR -o /tmp/asm2gdb.elf $INPUT || exit 1
19 ${ARCH}objcopy -O binary /tmp/asm2gdb.elf /tmp/asm2gdb.bin || exit 1
20 od -Ad -tx4 -w4 -v /tmp/asm2gdb.bin | awk "{ if (NF == 2) printf \"set *((unsigned long *) 0x%08x\1) = 0x%s\\n\", $ADDR + \$1, \$2 }"
21 echo "set \$pc = $ADDR"