I need to change a couple of variables in a compiled ELF file. Trying to explain this clearly I'll use a simple C struct as an example.
The single source file is compiled and linked (@ 0x1000) into MyFile.elf from MyFile.c:
typedef struct {
uint32_t SerialNumber; /* Increments for every time it's programmed */
uint32_t PartNumber; /* Always the same */
char ProdDateTime[32]; /* "YYYY-MM-DD HH:MM:SS" date/time when programmed */
uint32_t CalcCrc32; /* Checksum of the above data */
} MyData_T;
const MyData_T MyData = {
/* SerialNumber */ 0x11111111,
/* PartNumber */ 0x12345678,
/* ProdDateTime[32] */ "2013-11-10 12:49:30",
/* CalcCrc32 */ 0xC0CAC01A
};
Now I need a "console-tool" that (without compiling):
I have not been able to find a tool (objcopy etc?) that even does the first (1) task. Seems this should be a rather common scenario? I've written my own tool for now but would prefer a open source tool or similar.
Any suggestions / ideas / comments / criticisms are highly appreciated :D Thanks you!!
"gdb --write /your/application/binary" should be able to change value of initialized data and write it back to the executable.
Add "-batch" and "-x command_file" and you should be able to get it to do what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With