You can use the commands
restore to copy data between target memory and a file. The
append commands write data to a file, and the
restore command reads data from a file back into the inferior’s
memory. Files may be in binary, Motorola S-record, Intel hex,
Tektronix Hex, or Verilog Hex format; however, GDB can only
append to binary files, and cannot read from Verilog Hex files.
dump [format] memory filename start_addr end_addr
dump [format] value filename expr
Dump the contents of memory from
or the value of
filename in the given format.
format parameter may be any one of:
GDB uses the same definitions of these formats as the
GNU binary utilities, like ‘
objdump’ and ‘
format is omitted, GDB dumps the data in raw binary
append [binary] memory filename start_addr end_addr
append [binary] value filename expr
Append the contents of memory from
or the value of
expr, to the file
filename, in raw binary form.
(GDB can only append data to files in raw binary form.)
restore filename [binary] bias start end
Restore the contents of file
filename into memory. The
restore command can automatically recognize any known BFD
file format, except for raw binary. To restore a raw binary file you
must specify the optional keyword
binary after the filename.
bias is non-zero, its value will be added to the addresses
contained in the file. Binary files always start at address zero, so
they will be restored at address
bias. Other bfd files have
a built-in location; they will be restored at offset
from that location.
end are non-zero, then only data between
start and file offset
end will be restored.
These offsets are relative to the addresses in the file, before
bias argument is applied.