[PATCH v1 0/6] TIMESTAMP output section command

Ulf Samuelsson binutils@emagii.com
Thu Oct 9 15:51:16 GMT 2025


Den 2025-10-09 kl. 13:55, skrev Jan Beulich:
> On 09.10.2025 11:39, Ulf Samuelsson wrote:
>> Den 2025-10-09 kl. 08:03, skrev Hans-Peter Nilsson:
>>> On Wed, 8 Oct 2025, Ulf Samuelsson wrote:
>>>> Den 2025-10-08 kl. 10:17, skrev Alan Modra:
>>>>> You can of course already insert a quad-word entry with the current
>>>>> time, so this is really just syntactic sugar.  One way is
>>>>> INCLUDE timestamp.ld
>>>>> in your script somewhere, then just before running the linker, run
>>>>> echo ".QUAD `date '+%s'`" > timestamp.ld
>>> I'll one-up Alan's suggestion: for your definition of a
>>> timestamp, use the ld command-line option
>>>    "--defsym my_timestamp=`date '+%s'`"
>>> and use
>>>    "QUAD(my_timestamp)" in the
>>> linker script.  Works with today's version.
>>> And yesterday's, and ten years ago: I checked.
>> It is possible to do it this way. That does not mean that it is a good
>> way to implement it this way.
>> The current linker decides on timestamp without having to specify
>> something as a command line
>> option when you generate the timestamp for an ELF header or similar.
> Just to mention - I'm unaware of ELF headers carrying timestamps. PE
> and COFF headers do, yes.
>
>>> That it works with today's (and yester-year's) linker version,
>>> not requiring any functionality, is important to embedded
>>> developers.
>> Assume that 10,000 projects implements timestamp this way.
>> Then, they are forced by regulations to use "SOURCE_DATE_EPOCH" to
>> implement timestamps.
>> Now you have 10,000 project with a technical debt.
> Surely a fair part of them would have found a way to embed timestamps,
> and hence ...
>
>> With the suggestion implemented, you have a much smaller technical debt
> ... it would be extra effort for them to convert to the new linker
> script syntax you suggest.
>
Noone needs to change the method they are using,
but anyone starting a new project,
or deciding to use SOURCE_DATE_EPOCH
would be able to clean up the old stuff.

Since the simplest way to modify the binary is to generate
a hex file which is then modified, I have seen a number of project do that.
This means that you cannot run the code in a debugger
because the hex file does not contain any debug information.


>
> Jan

-- 
Best Regards
Ulf Samuelsson



More information about the Binutils mailing list