Assembler plugin for gdb
It is a script for gdb.
It lets you overwrite/modify assembly code in a location of choice.
First, load it in gdb by using the command source
. When debugging,
you can use the command asm [address]
to start assembling code at
the specified address. If no address is given, then the current
program counter is used. It will consume input until an empty line is
found.
(gdb) source gdbasm.py
(gdb) x/3i $eip
=> 0x8048a37 <main+3>: and $0xfffffff0,%esp
0x8048a3a <main+6>: sub $0x18bd0,%esp
0x8048a40 <main+12>: mov %gs:0x14,%eax
(gdb) asm
> nop
> xorl %eax, %eax
> nop
>
(gdb) x/3i $eip
=> 0x8048a37 <main+3>: nop
0x8048a38 <main+4>: xor %eax,%eax
0x8048a3a <main+6>: nop
(gdb)
It calls as
to assemble your code, and then overwrites the memory
with the generated opcodes. If you want to use nasm
, just modify
AsmGen to generate an AssemblerNASM object instead of an AssemblerAS
object.
BSD 3.
Just add the following line to the file .gdbinit in your home folder.
source gdbasm.py