use objcopy to patch or poke an elf file?
John Breitenbach
breiten@lexmark.com
Tue Sep 22 19:15:00 GMT 2009
Hi,
I've got a program which contains a const static variable which is
intended to contain a checksum.
After linking, I process that file with a program and then I would like
to overwrite the contents of that
variable with the actual checksum. I was hoping that objcopy would give
me a method to poke that in but
I don't see it. I could place that variable in its own section, then
all I would have to do is something similar
to the --add-section sect=filename. But what I really need is
"--replace-section-contents sect=filename"
Two methods I can think of are:
1) declare the variable in its own file and own section. Construct a
file containing the correct checksum
then compile it and relink the executable.
2) process the file, searching for and replacing the initialized with
the computed checksum.
Is there a better idea out there?
John
More information about the Binutils
mailing list