This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

use objcopy to patch or poke an elf file?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]