5

We have dump command in GDB which will dump a particular memory to a file. I want a command which will do exactly reverse of dump command i.e, which will read from a file of a particular length and dump it to specified address(memory).

Please help me on this regards, whether the command exists. If the command does not exists then please guide me how exactly i need to go ahead and implement it. As a am new to GDB.

I tried to use restore, but the problem is i need to load a file to a particular memory location some length. And in restore command syntax there is no such thing

jrturton
  • 118,105
  • 32
  • 252
  • 268
user1235791
  • 81
  • 2
  • 5
  • This question would invite more answers if you told us what research you already did. What did you read, where did you look for answers? Otherwise it seems like a google search away… – Holger Frohloff Jun 07 '12 at 15:20

2 Answers2

8

A raw file [PATH] can be loaded to target's memory address [ADDR] with:

restore [PATH] binary [ADDR]

cf: GDB documentation

3

See the restore command:

restore -- Restore the contents of FILE to target memory

with python there is also the Inferior.write_memory function

matt
  • 5,364
  • 1
  • 25
  • 25
  • I tried to use restore, but the problem is i need to load a file to a particular memory location some length. And in restore command syntax there is no such thing. – user1235791 Jun 08 '12 at 08:55