[PATCH v1 3/6] ld:TIMESTAMP command, ldlang.*
binutils@emagii.com
binutils@emagii.com
Tue Oct 7 12:39:34 GMT 2025
From: Ulf Samuelsson <ulf@emagii.com>
Add TIMESTAMP command to linker.
The TIMESTAMP command inserts a QUAD-word entry with the current time
into the image at the current location.
The value is the number of seconds since the Epoch,
1970-01-01 00:00:00 +0000 (UTC)
Signed-off-by: Ulf Samuelsson <ulf@emagii.com>
---
ld/ldlang.c | 8 ++++++++
ld/ldlang.h | 2 ++
2 files changed, 10 insertions(+)
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 3c57bf7541c..9841bc4a4e6 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -20,6 +20,7 @@
#include "sysdep.h"
#include <limits.h>
+#include <time.h>
#include "bfd.h"
#include "libiberty.h"
#include "filenames.h"
@@ -8835,6 +8836,13 @@ lang_add_data (int type, union etree_union *exp)
new_stmt->type = type;
}
+/* Store the time of linking in the image */
+void
+lang_add_timestamp (void)
+{
+ lang_add_data (QUAD, exp_intop ((bfd_vma) time (0)));
+}
+
void
lang_add_string (const char *s)
{
diff --git a/ld/ldlang.h b/ld/ldlang.h
index a9607bef765..0bc78f83143 100644
--- a/ld/ldlang.h
+++ b/ld/ldlang.h
@@ -651,6 +651,8 @@ extern void pop_stat_ptr
(void);
extern void lang_add_data
(int, union etree_union *);
+extern void lang_add_timestamp
+ (void);
extern void lang_add_string
(const char *);
extern void lang_add_reloc
--
2.17.1
More information about the Binutils
mailing list