Skip to main content
Visitor II
April 29, 2020
Question

is there a way to replace some hex values in .elf files?

  • April 29, 2020
  • 2 replies
  • 1084 views

Right now, i have generated a hex file using objcopy, added a crc etc to it.

Now, is there any way to add this hex information back to the original elf file? It would be nice to have it all packaged in one file back again.

    This topic has been closed for replies.

    2 replies

    Graduate II
    April 29, 2020

    The ELF object format is documented, you can work on it with the usual File IO functions.

    If adding data into sections you might have to expand and re-render the object file. If you've left space or a place holder via linker, etc you can do a more simple substitution or patch of the data in-place.

    Visitor II
    April 29, 2020

    I have heard that production programmer machines can put individual serial serial number into a hex data, but there must be a place for it. HEX file is a text file.

    Graduate II
    April 29, 2020

    Typically you can specify an address, or use substitution on a string constant "*SERIAL*" or whatever. Objects provide for sections and symbols to locate things by name.

    Traversing and modifying binary, object and hex files should be within the scope of a software engineer.