[PATCH v1 0/6] TIMESTAMP output section command

Ulf Samuelsson binutils@emagii.com
Thu Oct 9 09:39:27 GMT 2025


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.

If the SOURCE_DATE_EPOCH environment variable is set and valid it will 
be used.
If not, the current time will be used.
Is there any reason why we want to do this differently for embedded system?

> 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.

With the suggestion implemented, you have a much smaller technical debt

And with the TIMESTAMP command implemented, you can still do timestamps 
using
an include file or a command line option.
It is a bad idea of course, unless as you say you need to support an old 
compiler.
That is a problem that companies can manage and it will be getting 
smaller over time.

> brgds, H-P
> /embedded developer
> (mentioned only because I got the impression that was important)

-- 
Best Regards
Ulf Samuelsson



More information about the Binutils mailing list