Use the patch command to correct bad data or instructions in executable disk files. You can patch the text, initialized data, or read-only data areas. You cannot patch the bss segment, or stack and register locations, because they do not exist on disk files.
Use this command exclusively when you need to change the on-disk binary. Use the assign command when you need only to modify debuggee memory. If the image is executing when you issue the patch command, the corresponding location in the debuggee address space is updated as well. (The debuggee is updated regardless of whether the patch to disk succeeded, as long as the source and destination expressions can be processed by the assign command.) If your program is loaded but not yet started, the patch to disk is performed without the corresponding assign to memory.
(idb) run
[1] stopped at [int main(void):24 0x120001324]
24 return 0;
(idb) patch i = 10
0x1400000d0 = 10
(idb) patch j = i + 12
0x1400000d8 = 22
(idb)
When you use the patch command, the original binary is not overwritten, but is saved with the string ~backup appended to the file name. This allows you to revert to the original binary if necessary. A file with the string ~temp appended to the file name may also be created. It may be deleted after the debugging session is over.