[RFC v0 0/1] Add support for CRC64 generation in linker

Nick Clifton nickc@redhat.com
Fri Feb 17 11:11:10 GMT 2023


Hi Ulf,

>> Hi Ulf, can you state why a built-in support of ld is needed? If you
>> want to embed a checksum, you can use Output Section Data to reserve a
>> few bytes in the output, then use a post-link tool to compute the
>> checksum and rewrite the reserved bytes.

> In my experience, the post link tools usually work on the binary data and not the ELF file.

The objcopy program can do most of this for you though.  For example:

   % objcopy --dump-section .text=contents-of-text a.out
   % crc32 contents-of-text > crc32-of-text
   % objcopy --add-section .crc32=crc32-of-text a.out
   % readelf -x.crc32 a.out
   Hex dump of section '.crc32':
     0x00000000 32323064 37636339 0a                220d7cc9.

In this example the crc32 is stored as ascii text, but I am sure that
you can find a version of the crc32 program that generates binary output.


> Another thing is that the post-link tools I have seen are typically poorly maintained.

...and so you want to move that maintainership burden onto us, yes ?


> Adding a post-link step seems like a kludge if the linker can provide the CRC inside the ELF file.

But it also keeps things simple.  No new code in the linker = no new
bugs in the linker.  Solving a problem using existing tools = no need
for new versions of the linker when the already existing versions will
work just fine.

Cheers
   Nick




More information about the Binutils mailing list